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

fix qiskit warnings related to .register, .index, and find_bit #112

Merged
merged 1 commit into from
May 10, 2024
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
2 changes: 1 addition & 1 deletion qiskit_research/utils/dynamical_decoupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def add_pulse_calibrations(
dag = circuit_to_dag(circuit)
for run in dag.collect_runs(["pi_phi"]):
for node in run:
qubit = node.qargs[0].index
qubit, _ = dag.find_bit(node.qargs[0])
phi = node.op.params[0]
x_sched = inst_sched_map.get("x", qubits=[qubit])
_, x_instruction = x_sched.instructions[0]
Expand Down
6 changes: 3 additions & 3 deletions qiskit_research/utils/gate_decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ def run(
dag: DAGCircuit,
) -> DAGCircuit:
for rzx_run in dag.collect_runs(["rzx"]):
control = rzx_run[0].qargs[0].index
target = rzx_run[0].qargs[1].index
control, _ = dag.find_bit(rzx_run[0].qargs[0])
target, _ = dag.find_bit(rzx_run[0].qargs[1])
cr_forward_dir = cr_forward_direction(
control, target, self._inst_map, self._ctrl_chans
)

for node in rzx_run:
mini_dag = DAGCircuit()
q0, q1 = QuantumRegister(2)
mini_dag.add_qreg(q0.register)
mini_dag.add_qubits([q0, q1])

rzx_angle = node.op.params[0]

Expand Down
2 changes: 1 addition & 1 deletion qiskit_research/utils/pauli_twirling.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def run(
if node.op.name in TWO_QUBIT_PAULI_GENERATORS:
mini_dag = DAGCircuit()
q0, q1 = node.qargs
mini_dag.add_qreg(q0.register)
mini_dag.add_qubits([q0, q1])

theta = node.op.params[0]
this_pauli = Pauli(
Expand Down
9 changes: 6 additions & 3 deletions qiskit_research/utils/pulse_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,12 @@ def run(self, dag: DAGCircuit) -> DAGCircuit:
gp1 = next(dag.bfs_successors(rz_node))
if cx2_node in gp1[1]:
if (
(cx1_node.qargs[0].index == cx2_node.qargs[0].index)
and (cx1_node.qargs[1].index == cx2_node.qargs[1].index)
and (cx2_node.qargs[1].index == rz_node.qargs[0].index)
dag.find_bit(cx1_node.qargs[0])[0]
== dag.find_bit(cx2_node.qargs[0])[0]
and dag.find_bit(cx1_node.qargs[1])[0]
== dag.find_bit(cx2_node.qargs[1])[0]
and dag.find_bit(cx2_node.qargs[1])[0]
== dag.find_bit(rz_node.qargs[0])[0]
):
dag = self.sub_zz_in_dag(
dag, cx1_node, rz_node, cx2_node
Expand Down
4 changes: 2 additions & 2 deletions test/utils/test_pulse_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def test_forced_rzz_template_match(self, backend: Backend):

theta_set = rng.uniform(-np.pi, np.pi)
self.assertTrue(
Operator(qc.bind_parameters({theta: theta_set})).equiv(
Operator(scale_qc_match.bind_parameters({theta: theta_set}))
Operator(qc.assign_parameters({theta: theta_set})).equiv(
Operator(scale_qc_match.assign_parameters({theta: theta_set}))
)
)

Expand Down
Loading