You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[python][test] Migrate Python tests + bridge widening for measure_handle single-API
Three concerns share this commit because they are exercised by the same
test sweep:
(1) Python MLIR FileCheck migrations (4 files):
Mechanical type rename `!quake.measure` -> `!cc.measure_handle` in
`bug_1777.py` and `call_qpu.py`; structural refresh in `bug_1775.py`
and `bug_1875.py` for the new `cc.if`-carries-handle / short-circuit
`else`-discriminate IR shape that the rewired bridge produces.
(2) New `test_measure_handle.py` (25 tests, 23 active + 2 skipped on
pre-existing bridge gaps `IfExp` / `AnnAssign`):
host-scope rejection, scalar / vector mz emission shape, every
bool-coercion site (`if`/`while`/`not`/`bool()`/`==`/`!=`/`return`),
`and`/`or` short-circuit RHS-discriminate placement, `to_bools`
vector lowering, `to_integer(to_bools(...))` composition,
`to_integer(handles)` rejection, `discriminating an unbound
measure_handle` for the default-constructed pattern, and the
`measure_handle cannot cross the host-device boundary; entry-point
kernels must discriminate first` diagnostic for direct + transitive
handle positions.
(3) Existing test migrations + a narrow bridge fix the sweep exposed:
Full pytest sweep on `python/tests/kernel/` after the bridge rewire
surfaced 11 failing tests that previously relied on `mz` returning
bool. Migrations:
* `test_to_integer.py`: compose `to_integer(to_bools(mz(q)))`.
* `test_assignments.py::test_disallow_value_updates`: invert the
now-supported reassign-handle-across-scopes case (the test's own
TODO from before predicted exactly this).
* `test_assignments.py::test_inner_functions`: explicit
`bool(mz(q))` for the tuple-return aggregate-element case
(FIXME inline; aggregate-element typing does not currently
auto-discriminate).
* `test_kernel_features.py::test_mid_circuit_measurements`:
declare `result` slots as `bool` so the bridge's handle->i1/i8
path discriminates element stores.
* `test_run_kernel.py` (3 tests): explicit `int(bool(mz(q)))` for
handle-in-arithmetic; change `-> int` returning `mz(q)` to
`-> bool`.
* `test_kernel_shift_operators.py` (5 tests): bulk-discriminate
with `cudaq.to_bools(mz(q))` so shift operands are integer-typed.
Bridge fix in `changeOperandToType`: also auto-discriminate when
the target type is `i8` (Python's storage representation for
`bool`-element lists / dataclass slots), not just `i1`. After
discriminate the recursive call promotes i1->i8 via the existing
cast logic.
Sanity gate: full `python/tests/kernel/` pytest sweep is 620 passed,
47 skipped, 1 xfailed (all pre-existing). Python MLIR lit suite runs
94/94 green.
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
0 commit comments