Implementation of the gate-by-gate sampling algorithm.
Project description
BGLS
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
pip install bgls
Example
import cirq
import bgls
# 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"))
Sample output:
Counter({0: 6, 3: 4})
Documentation
See more details and examples in the Documentation for BGLS.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bgls-0.2.0.tar.gz.
File metadata
- Download URL: bgls-0.2.0.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
488235be47e9b733c52d57207b18ad6cae5c3ec1ce797da96eb87ea589b4d859
|
|
| MD5 |
2eb1a9baa6274b7ba66d7bb3489686a5
|
|
| BLAKE2b-256 |
09ce686abb156b6712b97787ccf1406017444785b60f641d8de5328ee5ba01af
|
File details
Details for the file bgls-0.2.0-py3-none-any.whl.
File metadata
- Download URL: bgls-0.2.0-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
535087493af4fd6c95fd5b89aea6c3e98b8c68d2262be50fb08e0976c16e4fb1
|
|
| MD5 |
fbbe6fdf5e2e86e23e99b5921b18c8ad
|
|
| BLAKE2b-256 |
bcd7f2f19c5d33fd742ab0703a2eaf72e97af28aea23acb40a660ebfb3f84f13
|