Cirq adapter for Clifft circuits and sampling
Project description
clifft-cirq
clifft-cirq converts parameter-resolved qubit cirq.Circuit instances into
Clifft circuit text and provides a small Cirq-style sampler facade on top of
Clifft. Parameter-resolved means the circuit has no symbolic parameters left,
for example after cirq.resolve_parameters.
import cirq
import clifft_cirq
q0, q1 = cirq.LineQubit.range(2)
circuit = cirq.Circuit(
cirq.H(q0),
cirq.CNOT(q0, q1),
cirq.measure(q0, q1, key="m"),
)
converted = clifft_cirq.to_clifft_text(circuit)
print(converted.clifft_text)
sampler = clifft_cirq.ClifftSampler(seed=123)
result = sampler.run(circuit, repetitions=1000)
The converter returns:
clifft_text: text accepted by Clifft's parser.qubit_map: the deterministic mapping from Cirq qubits to Clifft integer qubits.measurement_map: measurement-key metadata used to rebuild acirq.Result.
Supported
- Qubit circuits with parameter-resolved operations.
- Sampling behavior and measurement distributions up to unconditional global phase.
- Mid-circuit measurements and resets.
- Measurement keys that appear once each.
- Common one-, two-, and three-qubit gates, including
H, Pauli gates, special-angle axis powers,CX,CZ,SWAP,ISWAP,CH,CCX,CCZ, and Clifft half-turn rotations such asR_XandR_ZZ. - Operations that Cirq can decompose into supported operations.
The converter uses rotations instead of same-named Clifft sqrt gates when
Clifft and Cirq conventions differ. Unsupported operations raise
UnsupportedCirqOperationError with the failing operation.
Unsupported
- Qudits.
- Unresolved symbolic parameters at the
to_clifft_textboundary. - Repeated measurement keys, such as
cirq.measure(q0, key="m")followed bycirq.measure(q1, key="m"). - Arbitrary classical control.
- Measurement confusion maps.
- Cirq noise channels.
- Device, timing, calibration, duration, and tag semantics.
- Stochastic noise, leakage, loss, and other noncomputational models.
Development
uv sync --group dev
uv run pytest
uv run ruff check .
The package depends on clifft>=0.5 because that release supports the gateset
used by this adapter, including controlled-gate rewrites for CH, CCX, and
CCZ. CI should keep testing both the Cirq floor and the latest allowed
cirq-core<2 range.
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 clifft_cirq-0.1.1.tar.gz.
File metadata
- Download URL: clifft_cirq-0.1.1.tar.gz
- Upload date:
- Size: 88.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee556afe3626389b824f9546f4c3054f8f8066632910b54566403f34c7a3b9c2
|
|
| MD5 |
eafa650ca2238ff4f20bfc3720ee67ee
|
|
| BLAKE2b-256 |
38512cd751ec9439ab042c09224f3d8dbc2a632592c99aaccf7ba4178a4013f8
|
Provenance
The following attestation bundles were made for clifft_cirq-0.1.1.tar.gz:
Publisher:
release.yml on unitaryfoundation/clifft-cirq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clifft_cirq-0.1.1.tar.gz -
Subject digest:
ee556afe3626389b824f9546f4c3054f8f8066632910b54566403f34c7a3b9c2 - Sigstore transparency entry: 2084924903
- Sigstore integration time:
-
Permalink:
unitaryfoundation/clifft-cirq@02d4b362e95815ece6ae7fd22b1b3d6750734ff9 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/unitaryfoundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@02d4b362e95815ece6ae7fd22b1b3d6750734ff9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clifft_cirq-0.1.1-py3-none-any.whl.
File metadata
- Download URL: clifft_cirq-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32d983e7932a6a2127b93ad75f4249a9d55ab84332b3ae5e25f4745cd89245e5
|
|
| MD5 |
ad6a487d8e7cd802db4aa9033ec4294d
|
|
| BLAKE2b-256 |
b8aa92c23b057285a453bc191f0cd008383347242d48e363a264bc071f99b3c1
|
Provenance
The following attestation bundles were made for clifft_cirq-0.1.1-py3-none-any.whl:
Publisher:
release.yml on unitaryfoundation/clifft-cirq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clifft_cirq-0.1.1-py3-none-any.whl -
Subject digest:
32d983e7932a6a2127b93ad75f4249a9d55ab84332b3ae5e25f4745cd89245e5 - Sigstore transparency entry: 2084924928
- Sigstore integration time:
-
Permalink:
unitaryfoundation/clifft-cirq@02d4b362e95815ece6ae7fd22b1b3d6750734ff9 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/unitaryfoundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@02d4b362e95815ece6ae7fd22b1b3d6750734ff9 -
Trigger Event:
push
-
Statement type: