Skip to content

Conversation

@david-pl
Copy link
Collaborator

This simplifies the noise dialect a lot. I also cut down the supported semantics, so we now only support one- and two-qubit noise channels. Effectively, we now only have the following statements:

  • SingleQubitPauliChannel
  • TwoQubitPauliChannel
  • Depolarize
  • Depolarize2
  • QubitLoss

Technically, Depolarize(2) and Single(Two)QubitPauliChannel are redundant in that you can always rewrite Depolarize to the other channel. But I didn't want to burden the squin to stim pass with matching that (you'd need to look at runtime values of probabilities to make sure things are symmetric) when rewriting to Depolarize. At the same time, we need the asymmetric versions for cirq lowering.

One thing I realized: going the same stdlib approach as for the native and the clifford dialects, we end up needing broadcast again. And I didn't want to have squin.channel.broadcast.depolarize and similar things. So, for now, I just imported everything to the top level again, which means we have squin.depolarize and squin.broadcast.depolarize.

FYI @johnzl-777 I renamed the STIM tests, so they'll be skipped in the CI. If this gets merged before you get to the re-implementation of the squin to stim pass, keep that in mind.

Finally, I want to point out that it's not really possible to make the linter happy when going through a stdlib function that includes a list of probabilities, specifically two_qubit_pauli_channel. The problem is, that the linter complains that [0.01, 0.02, ...] isn't an ilist, but it's really lowered to one (the linter just doesn't know), so changing the type hint in the stdlib function to list[float] errors since it's a kernel. That said, we need some special handling anyway to improve the API here (see also #341 ). But let's do this in another PR.

@david-pl david-pl requested a review from Roger-luo September 30, 2025 11:55
@david-pl david-pl added breaking breaking changes or proposed changes that would break existing APIs rfc Request for Comments labels Sep 30, 2025
@codecov
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 91.04478% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/bloqade/squin/stdlib/broadcast/noise.py 75.00% 6 Missing ⚠️
src/bloqade/squin/stdlib/simple/noise.py 75.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Contributor

github-actions bot commented Sep 30, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
11046 8753 79% 0% 🟢

New Files

File Coverage Status
src/bloqade/squin/noise/_interface.py 100% 🟢
src/bloqade/squin/stdlib/broadcast/_init_.py 100% 🟢
src/bloqade/squin/stdlib/broadcast/noise.py 75% 🟢
src/bloqade/squin/stdlib/simple/_init_.py 100% 🟢
src/bloqade/squin/stdlib/simple/noise.py 75% 🟢
TOTAL 90% 🟢

Modified Files

File Coverage Status
src/bloqade/cirq_utils/emit/noise.py 41% 🟢
src/bloqade/pyqrack/squin/noise/native.py 100% 🟢
src/bloqade/squin/_init_.py 100% 🟢
src/bloqade/squin/analysis/nsites/impls.py 59% 🟢
src/bloqade/squin/noise/_init_.py 100% 🟢
src/bloqade/squin/noise/_dialect.py 100% 🟢
src/bloqade/squin/noise/stmts.py 100% 🟢
TOTAL 86% 🟢

updated for commit: cf2dbb4 by action🐍

@david-pl david-pl marked this pull request as ready for review October 1, 2025 09:38
assert all(0 <= x <= 1 for x in probs), "Invalid Pauli error probabilities"

for control, target in zip(controls, targets):
which = interp.rng_state.choice(self.two_pauli_choices, p=probs)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe with this we can close the issue #505

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, yeah I kept that in mind here. This already fixes it.

Copy link
Member

@weinbe58 weinbe58 left a comment

Choose a reason for hiding this comment

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

LGTM

@weinbe58 weinbe58 linked an issue Oct 1, 2025 that may be closed by this pull request
@johnzl-777 johnzl-777 merged commit e973ebe into main Oct 1, 2025
11 checks passed
@johnzl-777 johnzl-777 deleted the david/495-noise-refactor branch October 1, 2025 20:05
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 rfc Request for Comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass rng_state from PyQrackInterpreter into Squin noise operators.

4 participants