Implement ZNE local-random unitary folding#2956
Conversation
|
Thank you for the PR @jk20342 🎉 Before reviewing code, my main concern was figuring out what the feature is even supposed to do.
It sounds like in your PR each gate is wrapped in a loop that iterates The issue is pretty sparse about the desired behaviour, and mostly refers to the UF documentation. Reading through it I'm getting the following relevant info:
This is satisfied.
Looking at the odd integer scale factors section, this is not 100% clear to me, but it sounds like odd scaling factors might lead to a predictably uniformly scaled circuit? The example in that section, which also uses local-random folding, does not show any randomness either (admittedly it is very small). Unfortunately, the API docs for the random folding function don't go into details on how the sampling is performed exactly, except for:
So gate indices (from the circuit) are sampled randomly (probability distribution not specified, although there is an optional fidelity mechanism that might affect this) without replacement. I think the "index sampling without replacement" part could support the hypothesis that random folding with a scale factor of 3 would indeed lead to a uniformly scaled circuit.
What is clearer I think is that the proposed implementation doesn't meet this scaling factor target, since it generates One interpretation is that the random folding for odd integer scale factors does not behave any differently than the "local-all" folding, and that the randomness is only meaningful for fractional scale_factors (currently not supported in the Catalyst implementation), or perhaps when the fidelity dict is used. What are your thoughts on this? Perhaps the best thing to do would be to reach out to mitiq maintainers, dig into their source code, or play around with their tools to figure out the intended behaviour. |
|
Hey @dime10 took a look at the mitiq docs https://mitiq.readthedocs.io/en/stable/guide/zne-3-options.html and https://mitiq.readthedocs.io/en/stable/_modules/mitiq/zne/scaling/folding.html from my understanding the rule is if the scale factor is an odd integer going to make some changes to allow real that looks to be correct behavior to me if you could verify on your end :) |
|
ie per gate: |
|
I would leave the fidelity-weighted variant out though since catalyst doesnt expose per-gate fidelities yet |
|
Great, sounds like we have the same interpretation then :) Your proposal sounds reasonable! |
…/catalyst into zne-random-local-folding # Conflicts: # doc/releases/changelog-dev.md
…/catalyst into zne-random-local-folding
|
@dime10 made the changes :) |
Context:
The
local-randomfolding option formitigate_with_znewas wired through the enum and op but the MLIRrandomLocalFoldingwas a stubDescription of the Change:
Implemented
randomLocalFoldingin the--lower-mitigationpass: each gate is wrapped in a fold loop where every iteration flips a runtime coin (__catalyst__rt__random_double() < 0.5) deciding whether to insert aG G^\daggerpair. Added the__catalyst__rt__random_doubleruntime CAPI (backed by the ExecutionContext PRNG) and unblockedfolding="local-random"in the frontend.Benefits:
local-randomfolding now works end-to-end, with per-gate fold counts randomized at runtime and reproducible underqjit(seed=...).Possible Drawbacks:
Folding shares the single qjit
seed, so it can't be seeded independently of measurement readout yet.Related GitHub Issues:
#755