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

Adding stabilizer PY #220

Conversation

AbdullahKazi500
Copy link

This PR introduces support for mid-circuit measurements and entanglement entropy computation in the tensorcircuit library. Mid-circuit measurements are a crucial feature in quantum circuit simulation, allowing for measurements to be performed at intermediate stages of circuit execution. Additionally, entanglement entropy computation provides valuable insights into the entanglement properties of quantum states, aiding in quantum error correction and algorithm development.

Key Changes:

Mid-Circuit Measurement Support:

Implemented functionality to support mid-circuit measurements in the tensorcircuit library.
Introduced a new method M to perform mid-circuit measurements on qubits.
Entanglement Entropy Computation:

Added a function compute_entanglement_entropy to compute the entanglement entropy from the stabilizer tableau extracted after circuit execution.
The function constructs a binary matrix representing the stabilizer tableau and computes its rank to determine the entanglement entropy.
FIXES #211



# Append mid-circuit measurement
for measurement in tc_circuit._extra_qir:
Copy link
Contributor

Choose a reason for hiding this comment

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

mid-circuit measurement can be interleaved with other gates, should first call tc.translation._merge_extra_qir to get an ordered set of gates and measurements

Copy link
Author

@AbdullahKazi500 AbdullahKazi500 Jun 6, 2024

Choose a reason for hiding this comment

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

@refraction-ray added this functionality and code works thanks

Merge extra QIR with the main QIR to get an ordered set of gates and measurements

```merged_qir = tc.translation._merge_extra_qir(tc_circuit._qir, tc_circuit._extra_qir)```


# Compute and print the entanglement entropy
try:
entropy = compute_entanglement_entropy(stabilizer_tableau)
Copy link
Contributor

Choose a reason for hiding this comment

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

please also compare the results with baseline results by tc.quantum.entanglement_entropy, also one needs one extra argument for entanglement calculation -- the sites to be traced

Copy link
Author

Choose a reason for hiding this comment

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

baselineentropy
@refraction-ray compared it with baseline entropy here is the result

Copy link
Contributor

@refraction-ray refraction-ray left a comment

Choose a reason for hiding this comment

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

Please first refactor the code, with the reference style from other scripts in /examples, now the code is heavily duplicated

@AbdullahKazi500
Copy link
Author

@refraction-ray Hi Github is not allowing me to make changes in the same PR
made a new PR To address this issue here #221
I have tried to refactor the code with the docstrings and added the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stabilizer simulation example utilizing stim backend
2 participants