Skip to content

Conversation

@david-pl
Copy link
Collaborator

@david-pl david-pl commented Oct 21, 2025

As discussed in #549, this restructures the qubit dialect. I also moved it to the top level of bloqade, since it's used in multiple places. It's still re-exported by squin, though.

I've got it down to a single failing test, where the AggressiveUnroll fails because the constant propagation doesn't hint the loop iterable as constant for some reason.

This breaks the syntax such that you have to change the function calls using lists such as squin.qubit.measure(q: IList[Qubit]) to squin.broadcast.measure(q: IList[Qubit]).

Edit: turns out I was just too eager to remove the type inference method @weinbe58 added in #508. That resolves the failing test.

Edit2: I've also changed QubitId and MeasurementId to be "broadcasted" (i.e., they now operate on lists of qubits / measurements and return lists). This means that now all statements except qubit.new are broadcasted, which is as consistent as we can have it, I think.

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 92.21557% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/bloqade/qubit/stdlib/simple.py 63.15% 7 Missing ⚠️
src/bloqade/qubit/stdlib/broadcast.py 77.77% 4 Missing ⚠️
src/bloqade/qubit/stdlib/_new.py 80.00% 1 Missing ⚠️
src/bloqade/qubit/stmts.py 97.36% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
9489 8371 88% 0% 🟢

New Files

File Coverage Status
src/bloqade/qubit/_init_.py 100% 🟢
src/bloqade/qubit/_dialect.py 100% 🟢
src/bloqade/qubit/_interface.py 100% 🟢
src/bloqade/qubit/_prelude.py 100% 🟢
src/bloqade/qubit/analysis/_init_.py 100% 🟢
src/bloqade/qubit/stdlib/_init_.py 100% 🟢
src/bloqade/qubit/stdlib/broadcast.py 78% 🟢
src/bloqade/qubit/stdlib/simple.py 63% 🟢
src/bloqade/qubit/stmts.py 97% 🟢
src/bloqade/squin/stdlib/broadcast/_qubit.py 100% 🟢
TOTAL 94% 🟢

Modified Files

File Coverage Status
src/bloqade/analysis/measure_id/impls.py 95% 🟢
src/bloqade/cirq_utils/emit/base.py 94% 🟢
src/bloqade/cirq_utils/emit/qubit.py 100% 🟢
src/bloqade/cirq_utils/lowering.py 92% 🟢
src/bloqade/native/_prelude.py 100% 🟢
src/bloqade/native/dialects/gates/_interface.py 100% 🟢
src/bloqade/native/dialects/gates/stmts.py 100% 🟢
src/bloqade/native/stdlib/broadcast.py 63% 🟢
src/bloqade/native/stdlib/simple.py 69% 🟢
src/bloqade/pyqrack/squin/qubit.py 95% 🟢
src/bloqade/squin/_init_.py 100% 🟢
src/bloqade/squin/analysis/_init_.py 100% 🟢
src/bloqade/squin/groups.py 100% 🟢
src/bloqade/squin/rewrite/remove_dangling_qubits.py 91% 🟢
src/bloqade/squin/rewrite/wrap_analysis.py 86% 🟢
src/bloqade/squin/stdlib/broadcast/_init_.py 100% 🟢
src/bloqade/stim/passes/squin_to_stim.py 100% 🟢
src/bloqade/stim/rewrite/qubit_to_stim.py 86% 🟢
src/bloqade/stim/rewrite/squin_measure.py 94% 🟢
TOTAL 93% 🟢

updated for commit: cc9fa9c by action🐍

@david-pl david-pl marked this pull request as ready for review October 21, 2025 10:32
@david-pl david-pl added the breaking breaking changes or proposed changes that would break existing APIs label Oct 21, 2025
Copy link
Contributor

@johnzl-777 johnzl-777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a dangling print statement and some (very) minor nitpicks. Thank you for doing this!

ctrls: ir.SSAValue = info.argument(ilist.IListType[qubit.QubitType, N])
qargs: ir.SSAValue = info.argument(ilist.IListType[qubit.QubitType, N])
ctrls: ir.SSAValue = info.argument(ilist.IListType[QubitType, N])
qargs: ir.SSAValue = info.argument(ilist.IListType[QubitType, N])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this isn't part of the PR (so feel free to just resolve this) but I'm curious, why is it a qarg here when we usually do something like controls vs. targets?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that was introduced by @weinbe58 somewhere. I think I even left a similar comment on the PR? Should we change it? (Not in this PR, of course).

@david-pl
Copy link
Collaborator Author

CI is now failing because of #566 :/

@david-pl david-pl merged commit dadcd37 into main Oct 27, 2025
11 checks passed
@david-pl david-pl deleted the david/549-qubit-restructure branch October 27, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking breaking changes or proposed changes that would break existing APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: qubit dialect structure conformity with gate/broadcasting Reset statement wrapper

3 participants