Skip to content

Conversation

kevinhartman
Copy link
Contributor

@kevinhartman kevinhartman commented Oct 3, 2025

Summary

Built on top of #14568. This is just the mechanical change of moving CircuitData's block type to also be CircuitData instead of Py<PyAny>.

For a readable diff until that merges, see here:
kevinhartman/qiskit@oxidize-ctrl-flow...kevinhartman:qiskit:oxidize-circ-blocks

Details and comments

Todo:

  • Release note.
  • Improve this description a bit.

The change also moves ownership of basic blocks in Rust (the nested
circuits within control flow operations) to the containing circuit, i.e.
either CircuitData or DAGCircuit. As such, basic blocks now have the same
type as their container (no need to convert from CircuitData to a DAGCircuit
when you're accessing a control flow operation in a DAG context.

In Python, there is no change since we rebuild control flow operations
to avoid an API break.

Control flow instructions can be accessed by calling a
`try_view_control_flow` method of the circuit type, which provides the
following ergonomic view:

pub enum ControlFlowView<'a, T> {
    Box(Option<&'a Duration>, &'a T),
    BreakLoop,
    ContinueLoop,
    ForLoop {
        indexset: &'a [usize],
        loop_param: Option<&'a PyObject>,
        body: &'a T,
    },
    IfElse {
        condition: &'a Condition,
        true_body: &'a T,
        false_body: Option<&'a T>,
    },
    Switch {
        target: &'a Target,
        cases_specifier: Vec<(&'a Vec<CaseSpecifier>, &'a T)>,
    },
    While {
        condition: &'a Condition,
        body: &'a T,
    },
}
@kevinhartman kevinhartman requested a review from a team as a code owner October 3, 2025 21:27
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core
  • @levbishop

@jakelishman jakelishman added this to the 2.3.0 milestone Oct 7, 2025
@jakelishman jakelishman added on hold Can not fix yet Rust This PR or issue is related to Rust code in the repository labels Oct 7, 2025
@jakelishman jakelishman self-assigned this Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on hold Can not fix yet Rust This PR or issue is related to Rust code in the repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants