flaq
Compile a quantum research spec into a priced, refusable plan — before anything runs.
Flaq does not generate code and hope. It takes a solve spec, decides whether the stated accuracy is reachable inside the stated budget, and says so:
synthesize(spec) -> SolvePlan # what it will cost and achieve
-> Refusal # or exactly how much it is short
There is no third output. A plan without a prediction is not a plan.
Why
An LLM asked to "solve this with VQE" will always produce something. It has no cost model, so it cannot tell you the run will need 40,000 shots when you budgeted 10,000. Flaq turns that into a compile-time decision:
>>> from flaq import synthesize
>>> synthesize(spec)
Refusal(reason='ACCURACY_UNREACHABLE',
violated=('budget.max_shots_total',),
minimal_relaxation={'budget.max_shots_total': 40000})
A refusal is a return value, not an exception: "not within this budget" is an answer, and it is more useful than a plausible-looking circuit.
Install
pip install flaq
Usage
from flaq import (
AccuracyBudget, BackendProfile, PauliTerm, ResourceBudget, SolveSpec, synthesize,
)
spec = SolveSpec(
observable=(PauliTerm(coefficient=1.0, pauli="ZZ"),),
n_qubits=2,
accuracy=AccuracyBudget(
epsilon=0.01,
allocations={"statistical": 0.005}, # error priced before execution
safety_factor=1.0,
),
budget=ResourceBudget(max_shots_total=100_000),
backend=BackendProfile(name="simulator", max_qubits=20),
)
result = synthesize(spec)
# SolvePlan(spec_id='3f2a…', required_shots=40000,
# predicted_statistical_error=0.003162…)
What the numbers mean
The only error source priced analytically in 0.2.0 is the statistical one, using a bound that holds for any state:
eps_stat <= sqrt( sum_i |h_i|^2 / shots )
required_shots is therefore a sufficient ceiling, not a tight estimate. It
ignores 1 - <P_i>^2 (which can only reduce the cost) and ignores iteration
count entirely. Tightness arrives with the cost model in a later version; until
then a refusal means "provably impossible", and a plan means "provably
sufficient".
minimal_relaxation is exact for the same reason: it is the value that makes
synthesize succeed.
Guarantees
- Deterministic.
spec_idis a content hash, stable across term order and float noise. The same spec always compiles to the same plan. - Refusal before execution. Budget and backend checks happen at compile time; nothing is discovered halfway through a run.
- Spec errors are errors. An inconsistent spec (negative allocation,
overspent error budget, Pauli length mismatch, particle sector out of range)
raises
SpecErrorrather than being compiled around. - Zero runtime dependencies, standard library only.
Scope
0.2.0 is the specification and refusal core. Not yet included: method catalogues, iterative cost models, ansatz/optimisation error handling, backend error rates, execution and acceptance reporting.
License
Apache-2.0
Metadata
Release files for flaq 0.2.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 |
|---|---|---|---|---|
| flaq-0.2.0.tar.gz | 10.0 kB | Without provenance | Details for flaq-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flaq-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for flaq-0.2.0-py3-none-any.whl |
Total release size: 20.1 kB
Release files / flaq-0.2.0.tar.gz
| Download URL | flaq-0.2.0.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aad4c65c7b0541ca3698d41c115dd759d364bc16d59aeb2ac951f5c8d37befb9
|
|
BLAKE2b-256 checksum How to use checksums |
de91d53b8abbe062570f1472da69e65fc9936d5e5bc9b6d58adb94a0041ee03b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / flaq-0.2.0-py3-none-any.whl
| Download URL | flaq-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e85d2e66b2af2c8aeab797f38b71476bdf53b77f8555a0c4fe065d35bd77575c
|
|
BLAKE2b-256 checksum How to use checksums |
f66c545d9b54a1118fe194cc2fece066c31d8d0c1881629bbb78ae7989e9be4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for flaq 0.2.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.