blqs_cirq: Taking the pain out of writing Cirq programs
Blqs_cirq is a library that uses blqs to make it easier to write Cirq programs.
Here is the creation of a simple circuit in Cirq
import cirq
circuit = cirq.Circuit()
q0, q1 = cirq.LineQubit.range(2)
circuit.append(cirq.H(q0))
circuit.append(cirq.CX(q0, q1))
circuit.append(measure(q0, key='a'))
Blqs_cirq makes it so that you can write this more like a normal imperative program
import blqs_cirq as bc
from blqs_cirq import CX, H, measure
# Write the function imperatively.
@bc.build
def my_circuit():
H(0)
CX(0, 1)
measure(q0, key='a')
# To create the circuit we simply call the function.
circuit = my_circuit()
Blqs provides supports for all the gates in Cirq, along with all the various ways to use these gates to create operations.
But wait, there is more. Blqs_cirq supports
-
Simplification of qubit specification. Instead of creating
LineQubitorNamedQubit, etc., one can simply use integers (converted toLineQubits), 2-tuples or 2-lists (converted toGridQubits) or strings (converted toNamedQubits). Custom conversions are also possible. -
Simplification of control flow primitives. For example Cirq currently supports a subcircuit which can be repeated. For example here we repeat a small circuit within our circuit:
@bc.build
def my_circuit():
H(1)
with Repeat(repetitions=10):
H(0)
CX(0, 1)
As more control operations are added to Cirq these will be added to blqs_cirq.
- Simple building of Moments. For example, the code below builds two moments:
@bc.build
def my_circuit():
with Moment():
bc.H(0)
with Moment():
bc.H(1)
- Support for Cirq's insertion strategies:
@bc.build
def my_circuit():
with bc.InsertStrategy(cirq.InsertStrategy.NEW):
H(0)
H(1)
Installation
To install blqs_cirq one can simply pip install the appropriate package
pip install blqs_cirq
Note that installing blqs_cirq will also install blqs and cirq.
Documentation
A good place to start is with the introduction, followed by a look at the important features. For a quick intro via a jupyter notebook, see hello blqs_cirq.
Metadata
Release files for blqs-cirq 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blqs_cirq-0.1.0.tar.gz | 19.7 kB | Without provenance | Details for blqs_cirq-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blqs_cirq-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for blqs_cirq-0.1.0-py3-none-any.whl |
Total release size: 54.1 kB
Release files / blqs_cirq-0.1.0.tar.gz
| Download URL | blqs_cirq-0.1.0.tar.gz |
|---|---|
| Size | 19.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c93b37135a0dc03d426fdb11692f574a1dcdc847dc389d2cbd8a81372a6bfa2
|
|
BLAKE2b-256 checksum How to use checksums |
7c00b45b7b951abfe06cb61f21383d058a520a02b5e2db00153aa6b72710f80d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / blqs_cirq-0.1.0-py3-none-any.whl
| Download URL | blqs_cirq-0.1.0-py3-none-any.whl |
|---|---|
| Size | 34.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7648531971586682d32a097430935db45dd5df3b4abb377942f753860e8b2ef3
|
|
BLAKE2b-256 checksum How to use checksums |
6d7637dadb56a75c4520ce95dbb1cd3324014b41a97aaf721301a10e70fa26aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for blqs-cirq 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.