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

BlueprintCircuit subclasses rebuild out-of-order after _append #11180

Closed
jakelishman opened this issue Nov 2, 2023 · 0 comments · Fixed by #11181
Closed

BlueprintCircuit subclasses rebuild out-of-order after _append #11180

jakelishman opened this issue Nov 2, 2023 · 0 comments · Fixed by #11181
Labels
bug Something isn't working

Comments

@jakelishman
Copy link
Member

Environment

  • Qiskit Terra version: 0.25.3
  • Python version: 3.10
  • Operating system: macOS

What is happening?

Subclasses of BlueprintCircuit do not behave correctly when the inner-loop _append method is used; the circuit is not rebuilt prior to accepting the append.

How can we reproduce the issue?

from qiskit.circuit.library import RealAmplitudes, XGate
from qiskit.circuit import CircuitInstruction, ClassicalRegister

qc = RealAmplitudes(num_qubits=2, reps=2)
qc.add_register(ClassicalRegister(2, "meas"))
qc._append(CircuitInstruction(XGate(), (qc.qubits[0],), ()))
qc.draw()

gives

        ┌───┐┌────────────────────────────────────────────────┐
   q_0: ┤ X ├┤0                                               ├
        └───┘│  RealAmplitudes(θ[0],θ[1],θ[2],θ[3],θ[4],θ[5]) │
   q_1: ─────┤1                                               ├
             └────────────────────────────────────────────────┘
meas: 2/═══════════════════════════════════════════════════════

whereas using QuantumCircuit.append gives the expected:

from qiskit.circuit.library import RealAmplitudes, XGate
from qiskit.circuit import CircuitInstruction, ClassicalRegister

qc = RealAmplitudes(num_qubits=2, reps=2)
qc.add_register(ClassicalRegister(2, "meas"))
qc.append(XGate(), [qc.qubits[0]])
qc.draw()
        ┌────────────────────────────────────────────────┐┌───┐
   q_0: ┤0                                               ├┤ X ├
        │  RealAmplitudes(θ[0],θ[1],θ[2],θ[3],θ[4],θ[5]) │└───┘
   q_1: ┤1                                               ├─────
        └────────────────────────────────────────────────┘
meas: 2/═══════════════════════════════════════════════════════

What should happen?

Inner _append should handle enforcing the build, not append.

Any suggestions?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant