Program.get_qubit_indices() only reports qubits named by top-level instructions. A qubit that appears literally inside a DEFCIRCUIT body is not reported, even though invoking the circuit acts on it:
from pyquil import Program
from pyquil.gates import H, X
from pyquil.quilatom import FormalArgument, Qubit
from pyquil.quilbase import DefCircuit, Gate
q = FormalArgument("q")
dc = DefCircuit("C", [], [q], [X(q), X(Qubit(3))]) # body touches qubit 3 literally
p = Program(dc, Gate("C", [], [Qubit(0)]), H(1))
p.get_qubit_indices() # {0, 1} -- qubit 3 is missing
Anything that sizes a register from get_qubit_indices() (the experimental simulators in #1860, for one) therefore cannot see such a qubit. The simulators currently reject literal qubits in DEFCIRCUIT bodies outright to avoid silently mis-simulating; that check can be rolled back once get_qubit_indices expands circuit definitions (or reports their literal qubits) itself.
Raised from the review of #1860.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JfZKmgqinMhR4BS87y4G4F
Program.get_qubit_indices()only reports qubits named by top-level instructions. A qubit that appears literally inside aDEFCIRCUITbody is not reported, even though invoking the circuit acts on it:Anything that sizes a register from
get_qubit_indices()(the experimental simulators in #1860, for one) therefore cannot see such a qubit. The simulators currently reject literal qubits inDEFCIRCUITbodies outright to avoid silently mis-simulating; that check can be rolled back onceget_qubit_indicesexpands circuit definitions (or reports their literal qubits) itself.Raised from the review of #1860.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JfZKmgqinMhR4BS87y4G4F