-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create and diagonalize mid-circuit measurements in conditionals #7037
base: move_validation_to_cond
Are you sure you want to change the base?
Conversation
…ne into validate_mcm_in_cond
) | ||
assert diagonalizing_gates[0].meas_val.processing_fn == measurement.meas_val.processing_fn | ||
|
||
def test_diagonalize_mcm_cond_two_outcomes(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's currently only support for conditional having two measurement outcomes, so this test and the previous test became the same test
Hello. You may have forgotten to update the changelog!
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## move_validation_to_cond #7037 +/- ##
==========================================================
Coverage ? 99.60%
==========================================================
Files ? 489
Lines ? 47005
Branches ? 0
==========================================================
Hits ? 46820
Misses ? 185
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Context:
Conditional
s, so we need to get rid of those before we get to execution.qml.cond
doesn't return anything (so its not suitable for conditionally applying functions that return aMeasurementValue
), and would need different handling for measurement functions than for anOperator
orqfunc
. We've decided to continue limiting itOperator
andqfunc
, and make a separate function just for measurements. It will be restricted in its inputs and outputs to make sure that what it returns is up-to-date with our current ability to process conditional MCMs, and it will be part of theftqc
module.Description of the Change:
We add
cond_meas
, with a call signaturecondition, true_fn, false_fn,
to matchqml.cond
. Limitation on inputs will be informed by our limitations on what we can process for execution, and will currently be:true_fn
andfalse_fn
are required, and should create aMidMeasureMP
(likely a parametrized one from theftqc
module) and return aMeasurementValue
reset
andpostselect
attributes. Effectively this means only the measurement basis is conditional.We update the
diagonalize_mcms
transform to assume anyConditional
containing a mid-circuit measurement is accompanied by its correspondingfalse_fn
Conditional
on the tape, and to diagonalize pairs ofConditional
s together. The transform "factors out" the measurement as a Z-basis measurement, so it's no longer conditional, and applies conditional diagonalizing gates.Benefits:
We can add a measurement to a circuit whose measurement basis is conditional on a previous measurement outcome, and retrieve the measurement value.
Possible Drawbacks:
It's restrictive, and it's limited to devices where we want to diagonalize the MCMs - but for now, it does what we need it to do.
[sc-84499]