This release is a pre-release and may not be stable for production use.
Qciscirq
Current version: v0.1-beta
Adaptors for translating quantum circuits between QCIS and cirq.Circuit.
What is qciscirq
QCIS is a quantum circuit instruction set used in
Xiaobo Zhu group at USTC. QCIS is designed deliberately to work on
hardware. They are low-level instructions and can be hard to write from
scratch, which requires heavy string manipulation.
cirq is an open-source quantum computing framework proposed by Google. It provides
a high-level quantum circuit API and a simulator for simulating quantum circuits. Writing
quantum circuits in cirq is much easier than QCIS.
This package(qciscirq) provides an adaptor for translating quantum circuits between QCIS and
cirq.Circuit. The supported translation units are limited by the relatively small number of
QCIS instructions. Additionally, qciscirq defines some cirq extension gates for some operation
abstractions such as dynamical decoupling sequence.
Installation
qciscirq can be installed with pip:
pip install qciscirq
API Reference
qciscirq.cirq_to_qcis
Convert cirq circuit to QCIS circuit.
Args:
circuit: The cirq circuit to be converted.
map_func: A function that maps cirq.GridQubit to a string.
all_blockable_qagents: All qagents that can be blocked, used in 'B' operation.
couplers: A dictionary mapping coupler names to qubit pairs, used in CZ operation conversion.
Defaults to None. When the circuit contains CZ gates, this argument must be provided.
ignored_gates_or_ops: Specify the gates or operations to ignore when converting from cirq to qcis.
Defaults to None. When None, the default set of gates or operations to ignore will be used, including
stimcirq extension operations and cirq noise channel gates. When not None, the ignored set used will be
the union of the default set and the set specified by this argument.
Returns:
The QCIS circuit.
Examples:
>>> import cirq
>>> import qciscirq
>>> q1, q2 = cirq.GridQubit.rect(1, 2)
>>> print(qciscirq.cirq_to_qcis(
... cirq.Circuit(
... cirq.Moment((cirq.Y ** 0.5)(q1), (cirq.Y ** -0.5)(q2)),
... cirq.Moment(cirq.CZ(q1, q2)),
... cirq.Moment((cirq.Y ** 0.5)(q2)),
... cirq.Moment(cirq.measure(q1, q2)),
... ),
... map_func={q1: 'Q01', q2: 'Q02'}.get,
... all_blockable_qagents = ['Q01', 'Q02', 'R01'],
... couplers = {'G0201': ('Q01', 'Q02')}))
Y2P Q01
Y2M Q02
B Q01 Q02 R01
CZ G0201
B Q01 Q02 R01
Y2P Q02
B Q01 Q02 R01
M Q01 Q02
B Q01 Q02 R01
qciscirq.qcis_to_cirq
Convert QCIS circuit to cirq circuit.
Args:
qcis: The QCIS circuit to be converted.
map_func: A function that maps a string to cirq.GridQubit.
couplers: A dictionary mapping coupler names to qubit pairs, used in CZ operation conversion.
Defaults to None. When qcis contains CZ operations, couplers must be provided.
ignored_instructions: Instructions to be ignored. Defaults to None. When not None, the instructions
start with the strings in this set will be ignored.
Returns:
The cirq circuit.
Examples:
>>> import cirq
>>> import qciscirq
>>> q1, q2 = cirq.GridQubit(0, 1), cirq.GridQubit(0, 2)
>>> qcis_circuit = '''X2P Q01
... X2M Q02
... B Q01 Q02 R01
... CZ G0201
... B Q01 Q02 R01
... M Q01 Q02
... B Q01 Q02 R01
... '''
>>> print(qciscirq.qcis_to_cirq(
... qcis_circuit,
... map_func={'Q01': q1, 'Q02': q2}.get,
... couplers={'G0201': ('Q01', 'Q02')}))
(0, 1): ───X^0.5────@───M('Q01,Q02')───
│ │
(0, 2): ───X^-0.5───@───M──────────────
Metadata
Release files for Qciscirq 0.1b0
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 |
|---|---|---|---|---|
| Qciscirq-0.1b0.tar.gz | 9.4 kB | Without provenance | Details for Qciscirq-0.1b0.tar.gz |
Release files / Qciscirq-0.1b0.tar.gz
| Download URL | Qciscirq-0.1b0.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9cb31d65af75623512f4705a2227f0ba860a85d42fa5f27f11369a01dc8f011f
|
|
BLAKE2b-256 checksum How to use checksums |
718bf1130205ee33f039639162b42a3004f623fc28315a595d4130ecee17a24b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for Qciscirq 0.1b0
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.