tencent-quantum-lab / tensorcircuit

Tensor network based quantum software framework for the NISQ era
https://tensorcircuit.readthedocs.io
Apache License 2.0
252 stars 75 forks source link

Stabilizer simulation example utilizing stim backend #211

Closed refraction-ray closed 3 weeks ago

refraction-ray commented 1 month ago

Task description

Add an example python script stabilizer_stim_sim.py in /examples which showcases stabilizer circuit simulation using tc interface with stim backend.

Implementation

The script includes:

  1. Clifford circuit with mid-circuit measurement defined in tc
  2. Transform the circuit object into Stim circuit object with the helper function defined in the same script (input: tc circuit, output: stim circuit)(can utilize c._qir and c._extra_qir, using c.measure_instruction to get the mid circuit measurement recorded in extra_qir and using c.mid_measurement for the real functionality)
  3. Simulate the circuit in stim and extract the stabilizer tableau
  4. Compute the entanglement entropy of the output state with the helper function defined in the same script (input: stabilizer tableau representation, output: entanglement entropy value) (see Ref 3, it would be better to try hard to accelerate this function)
  5. Validate the correctness by directly computing entanglement from tc (mid-circuit measurement results might require to be averaged)

References:

  1. https://github.com/tencent-quantum-lab/tensorcircuit/issues/159
  2. https://github.com/quantumlib/Stim
  3. https://quantumcomputing.stackexchange.com/questions/16718/measuring-entanglement-entropy-using-a-stabilizer-circuit-simulator
  4. https://arxiv.org/abs/quant-ph/0406196
anonymousr007 commented 1 month ago

Hi @refraction-ray, Nice to meet you.

I am Rishabh Singh, and I have been learning about quantum computing since 2020.

Best Regards Rishabh Singh LinkedIn | GitHub

refraction-ray commented 1 month ago

@anonymousr007 , great, feel free to open a PR for this issue. Should you encounter any further questions or need assistance while working on it, please don't hesitate to reach out. We're here to help and look forward to your contributions.

AbdullahKazi500 commented 1 month ago

Hi @refraction-ray I got the stabilizer example to work now I will be covering the points in the PR Issue

AbdullahKazi500 commented 1 month ago

@refraction-ray I got the stabilizer example to work with mid circuit measurements

AbdullahKazi500 commented 1 month ago

@refraction-ray is their a way to plot in stim

refraction-ray commented 1 month ago

is their a way to plot in stim

https://quantumcomputing.stackexchange.com/questions/25734/how-can-i-visualize-a-stim-circuit

AbdullahKazi500 commented 1 month ago

@refraction-ray I am getting stuck here --------------- AttributeError: 'stim._stim_sse2.TableauSimulator' object has no attribute 'simulate' probably checking

AbdullahKazi500 commented 1 month ago

@refraction-ray this issue is done now just stuck at the 4 point it is really hard to get that function to work

AbdullahKazi500 commented 1 month ago

@refraction-ray finally the code works after modification I will make a PR

AbdullahKazi500 commented 1 month ago

stim

AbdullahKazi500 commented 1 month ago

@refraction-ray can I get some feedback

refraction-ray commented 1 month ago

@AbdullahKazi500 , you can open an PR so that I can review the script if you have already got the example work and the result entanglement is checked to be correct

AbdullahKazi500 commented 4 weeks ago

@refraction-ray Added

king-p3nguin commented 3 weeks ago

Hi, I would also like to work on this issue.