Skip to content
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

Implement a good way of tracking measurements #45

Closed
nelimee opened this issue Jan 16, 2024 · 2 comments
Closed

Implement a good way of tracking measurements #45

nelimee opened this issue Jan 16, 2024 · 2 comments
Labels
backend Issue pertaining to the Python backend (tqec package) enhancement New feature or request, may not be in the task flow help wanted Extra attention is needed

Comments

@nelimee
Copy link
Contributor

nelimee commented Jan 16, 2024

Measurements need to be translated to record offsets in order to be readable and usable by Stim. This is currently handled by CircuitMeasurementMap that takes a cirq.Circuit instance as input and provides a way to compute the record offset for any measurement in this cirq.Circuit instance.

The current implementation of CircuitMeasurementMap is not adapted to the movement of a logical qubit due to one "limitation" (that was originally a feature): it counts measurements in a repeated cirq.CircuitOperation only once.

This means that if we perform the following QEC experiment:

  1. Initialize a logical qubit,
  2. Extend the logical qubit horozontally (let's say to the right),
  3. Wait a few (let's say $n_1$) QEC cycles,
  4. Measure out the data qubits on the left, where the logical qubit originally was,
  5. Wait a few (let's say $n_2$) QEC cycles,
  6. Measure the final observable,

the CircuitMeasurementMap would not be able to accurately compute the measurement records of the measurements included in the final observable, because it would count each measurement in the $n_2$ QEC cycles only once (instead of $n_2$ times).

A quick fix would be to change the behaviour of CircuitMeasurementMap on cirq.CircuitOperation instances when they are repeated.

@nelimee nelimee added enhancement New feature or request, may not be in the task flow help wanted Extra attention is needed backend Issue pertaining to the Python backend (tqec package) labels Jan 16, 2024
@nelimee
Copy link
Contributor Author

nelimee commented Jan 17, 2024

Thinking about it a little bit more, the CircuitMeasurementMap and all the code that is based on the assumption that a cirq.CircuitOperation only accounts for 1 cirq.Moment should probably be changed.

One instance of cirq.CircuitOperation can (and very likely will) take more than one cirq.Moment, and scheduling the measurements correctly in all cases with that fact is a little bit harder than what was expected.

For the moment, I think that the best would be to (potentially recursively) flatten the cirq.Circuit instance provided to the CircuitMeasurementMap constructor, construct the measurement map from that flattened circuit, and adapt the measurement indices provided to CircuitMeasurementMap.get_measurement_relative_offset.

nelimee added a commit that referenced this issue Jan 17, 2024
@nelimee
Copy link
Contributor Author

nelimee commented Jan 18, 2024

Fixed by #55

@nelimee nelimee closed this as completed Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Issue pertaining to the Python backend (tqec package) enhancement New feature or request, may not be in the task flow help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant