BGLS is a Python package that implements the Bravyi, Gosset, and Liu Sampling algorithm presented in How to simulate quantum measurement without computing marginals (Phys. Rev. Lett.) (arXiv) for Cirq circuits.
Quickstart
Installation
pipinstallbgls
Example
importcirqimportbgls# Example circuit to run.qubits=cirq.LineQubit.range(2)circuit=cirq.Circuit(cirq.H.on(qubits[0]),cirq.CNOT.on(*qubits),cirq.measure(*qubits,key="z"))# Run the circuit with BGLS.simulator=bgls.Simulator(initial_state=cirq.StateVectorSimulationState(qubits=qubits,initial_state=0),apply_op=cirq.protocols.act_on,compute_probability=bgls.born.compute_probability_state_vector,)results=simulator.run(circuit,repetitions=10)print(results.histogram(key="z"))