-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Only apply MCMT plugin on MCMTGate
#13596
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
fixes: | ||
- | | ||
Fixed a bug where any instruction called ``"mcmt"`` would be passed into the high-level | ||
synthesis routine for a :class:`.MCMTGate`, which causes a failure or invalid result. | ||
In particular, this could happen accidentally when handling the :class:`.MCMT` _circuit_, | ||
named ``"mcmt"``, and implicitly converting it into an instruction e.g. when appending | ||
it to a circuit. | ||
Fixed `#13563 <https://github.com/Qiskit/qiskit/issues/13563>`__. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,6 +285,19 @@ def test_gate_with_parameters_vchain(self): | |
self.assertEqual(circuit.num_parameters, 1) | ||
self.assertIs(circuit.parameters[0], theta) | ||
|
||
def test_mcmt_circuit_as_gate(self): | ||
"""Test the MCMT plugin is only triggered for the gate, not the same-named circuit. | ||
|
||
Regression test of #13563. | ||
""" | ||
circuit = QuantumCircuit(2) | ||
gate = RYGate(0.1) | ||
mcmt = MCMT(gate=gate, num_ctrl_qubits=1, num_target_qubits=1) | ||
circuit.append(mcmt, circuit.qubits) # append the MCMT circuit as gate called "MCMT" | ||
Comment on lines
+295
to
+296
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit off-topic. Here we are appending the quantum circuit |
||
|
||
transpiled = transpile(circuit, basis_gates=["u", "cx"]) | ||
self.assertTrue(Operator(transpiled).equiv(gate.control(1))) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there other gates that might be missing here? what about
PermutationGate
,MultiplierGate
?