Skip to content

compose fails when front=True is provided and when the circuit to be composed has a different number of qubits #15834

@tnemoz

Description

@tnemoz

Environment

  • Qiskit version: 2.4.0.dev0
  • Python version: 3.14.3
  • Operating system: Arch Linux

What is happening?

When using the compose method of a QuantumCircuit with front=True on another, smaller, QuantumCircuit, compose fails with

ValueError: 'qubits' argument is the wrong length

How can we reproduce the issue?

The following code allows to reproduce the issue.

from qiskit import QuantumCircuit

qc_base = QuantumCircuit(2)
qc_base.h(0)
qc_x = QuantumCircuit(1)
qc_x.x(0)

qc_base.compose(qc_x, qubits=[0], front=True).draw()

What should happen?

The compose method should not raise an error.

Any suggestions?

The previous code runs when using Qiskit 2.3.0. It would seem that this bug was introduced in #15696, where compose was changed.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions