-
Notifications
You must be signed in to change notification settings - Fork 49
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
Simulate circuits containing PauliMeasurements using PauliFrames #412
base: master
Are you sure you want to change the base?
Conversation
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.
This is awesome, thank you!
I think we just need to add some tests (potentially including a test that uses @allocated
to verify that memory is not churned).
src/pauli_frames.jl
Outdated
end | ||
end | ||
op.pauli.phase[] == 0 || apply!(frame, sX(n + 1)) | ||
apply!(frame, sMRX(n + 1, op.bit)) |
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.
I think this should be sMRZ
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.
Of course...
@@ -26,7 +26,8 @@ $(TYPEDSIGNATURES) | |||
Prepare an empty set of Pauli frames with the given number of `frames` and `qubits`. Preallocates spaces for `measurement` number of measurements. | |||
""" | |||
function PauliFrame(frames, qubits, measurements) | |||
stab = fastcolumn(zero(Stabilizer, frames, qubits)) # TODO this should really be a Tableau | |||
# one extra qubit for ancilla measurements | |||
stab = fastcolumn(zero(Stabilizer, frames, qubits + 1)) # TODO this should really be a Tableau |
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.
I agree with this change. I think now we need to update show
and nqubits
and maybe others. Thankfully, for show
it can be as simple as using @view frame[:,1:end-1]
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.
actually, we do not even have a show method implemented, so this probably only needs a correct nqubits
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.
I subtracted the ancillary qubit in the nqubits(f::PauliFrame)
function. I think that should be fine.
src/pauli_frames.jl
Outdated
@@ -120,6 +121,24 @@ function apply!(frame::PauliFrame, op::sMRZ) # TODO sMRY, and faster sMRX | |||
return frame | |||
end | |||
|
|||
function apply!(frame::PauliFrame, op::PauliMeasurement) | |||
# this is inspired by ECC.naive_ancillary_paulimeasurement. Not sure if it's better to import and call that. |
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.
# this is inspired by ECC.naive_ancillary_paulimeasurement. Not sure if it's better to import and call that. | |
# this is inspired by ECC.naive_syndrome_circuit |
Better to keep it the way you did it here, as this is non-allocating while naive_syndrome_circuit
would create a temporary array
…ct nqubits(f::PauliFrame)
The test failures happen due to this: QuantumClifford.jl/test/test_ecc_syndromes.jl Lines 33 to 36 in f69e49c
The cleanest way to fix this is probably to do with a newly defined
|
Somehow this is more complicated because the |
darn, you are right. Thankfully, here we are adding a qubit at the very end, so there is still an easy workaround
If I am not getting this wrong, the internal indexing utilities of |
Sadly, this doesn't seem to work. I guess the internal indexing doesn't skip over the last qubit. And removing it from the I don't think there are many other options... Probably, silently adding one extra qubits is not such a good idea. |
I still like the way you have set this up and I suspect there is something pretty minor left to fix. I should be able to look into it around the end of the week. |
This PR adds a layer of abstraction that uses option 2 of #411 to make it easier to simulate circuits containing PauliMeasurements using PauliFrames.
apply!
function has a method for PauliMeasurements that basically reusesECC.naive_ancillary_paulimeasurement
to convert a PauliMeasurement to a list of gates (which already haveapply!
methods) that perform the measurement using the ancillary qubit.concrete_typeparams
method for PauliMeasurements to makeCompactifiedGate
possible. (I'm not sure if the one possible type parameter I specify here is exhaustive... probably not.)