• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / qiskit / 19723813215

27 Nov 2025 02:39AM UTC coverage: 88.373% (-0.03%) from 88.406%
19723813215

push

github

web-flow
Port control-flow operations to Rust. (#14568)

* Port control flow operations to Rust.

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,
    },
}

* Fix Rust unit tests.

* Clean up ObjectRegistery.

* Fix perf/memory regression.

I'd forgotten to add the logic to use None instead of an empty
smallvec in extract_params after moving to using an Option
for OperationFromPython::params.

This meant we were allocating and keeping around extra smallvecs
which was tanking circuit copy and extend (and ballooning our
peak memory usage).

* Fix params regression in one more place.

* Make create_py_op methods take ingredients by value.

This lets us get rid of an extra clone in parameter assignment,
introduced when unpack_py_op moved to the circuit level.

* Also use instruction::create_py_op in DAGCircuit::unpack_py_op.

* Don't panic in PackedInstruction param and block view methods.

We don't *need* to panic... (continued)

2562 of 2918 new or added lines in 63 files covered. (87.8%)

112 existing lines in 20 files now uncovered.

95281 of 107817 relevant lines covered (88.37%)

1193527.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.5
/crates/circuit/src/variable_mapper.rs


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc