Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable/0.3: retrieving task if get empty counts in send(wait=True) #101

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/quafu/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ def send(self,
else:
self.submit_history[group].append(task_id)

return ExecResult(res_dict)
result = ExecResult(res_dict)
while wait and (self.shots > 0) and (not result.counts):
if verbose:
logging.warning('warning for quafu status: empty result.counts, retrieving task...')
result = self.retrieve(result.taskid)
Zhaoyilunnn marked this conversation as resolved.
Show resolved Hide resolved
return result

def retrieve(self, taskid: str) -> ExecResult:
"""
Expand Down
7 changes: 4 additions & 3 deletions src/quafu/visualisation/circuitPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ def _process_ins(self, ins: Instruction, append: bool = True):
elif name in r2_gate_names:
# TODO: combine into one box
self._ctrl_wire_points.append([[depth, ins.pos[0]], [depth, ins.pos[1]]])
self._proc_su2(name[:-1], depth, ins.pos[0], paras)
self._proc_su2(name[:-1], depth, ins.pos[1], paras)

self._proc_su2(name[:-1], depth, min(ins.pos), None)
self._proc_su2(name[:-1], depth, max(ins.pos), paras)
elif isinstance(ins, ControlledGate):
self._proc_ctrl(depth, ins)
elif name == 'delay':
Expand Down Expand Up @@ -363,7 +364,7 @@ def _proc_su2(self, id_name, depth, pos, paras):

if id_name in ['rx', 'ry', 'rz', 'p']:
# too long to display: r'$\theta=$' + f'{paras:.3f}' (TODO)
para_txt = f'({paras:.3f})'
para_txt = f'({paras:.3f})' if paras else None
else:
para_txt = None

Expand Down