Skip to main content

QuoNic — Quantum programming, as simple as writing Python

License Python 3.9+ Qiskit Cirq

QuoNic is a tool that makes quantum programming as simple as writing Python.

No QuantumCircuit to learn, no backend to understand, no manual measure. If you can write Python, you can write quantum programs.

中文文档


🚀 30-second quick start

from quonic import qgate, qshow
from quonic.gates import H, CX

qgate(H, 0)
qgate(CX, 0, 1)
qshow()

This is the Bell state — the most classic result in quantum computing. The same thing takes 10+ lines in raw Qiskit. QuoNic does it in 3. The result appears directly in your terminal or Jupyter.

More copy-and-run examples (GHZ, qif, QInt, Grover, VQE, QAOA, noise) live in examples/.


📦 Installation

pip install quonic

Backends are optional dependencies — install only what you need. To install all three backends (plus numpy/scipy for the algorithm templates) in one shot:

pip install 'quonic[qiskit,cirq,pennylane,algorithms]'

To install a single backend, e.g. only Cirq: pip install 'quonic[cirq]'. Calling an uninstalled backend raises a clear message (English by default; set QUONIC_LANG=zh for Chinese).

Visualization is a separate optional dependency: pip install 'quonic[viz]' (matplotlib only — no Graphviz / Seaborn / NetworkX).


✨ Core features

1. Minimal syntax: a Bell state in 3 lines

You don't need to understand "quantum circuit objects", pick a "backend simulator", or write measure by hand. QuoNic handles all of it.

2. Switch every backend with one argument

# Use the Qiskit simulator (default)
qshow(backend='qiskit')

# Switch to Cirq
qshow(backend='cirq')

# Switch to PennyLane
qshow(backend='pennylane')

# Real hardware (Quantum Inspire) — requires login
qshow(backend='qi')                    # QX cloud simulator (default; verify before submitting)
qshow(backend='qi', device='tuna9')    # Tuna-9 real device
qshow(backend='qi', device='tuna17')   # Tuna-17 real device
qshow(backend='qi', device='qx')       # QX cloud simulator

The same code, unchanged, runs on any backend. Minimal syntax + backend independence is QuoNic's combined differentiator.

3. Conditional gates and "if = superposition"

QuoNic implements quantum superposition control with qif and draws a strict line between two concepts:

  • Quantum superposition control (qif, implemented): when the control qubit is in a superposition, the branches are not measured — they interfere coherently and produce real entanglement. This is "both branches happen at once", not "measure then pick one".
    from quonic import qgate, qif, qshow
    from quonic.gates import H, X, I
    
    qgate(H, 0)                       # control qubit enters superposition
    qif(0).then(X, 1).else_(I, 1)     # q0==1 flips q1, else nothing (= controlled X)
    qshow()
    
    The I in else_(I, ...) is the identity gate, so "controlled gate = qif special case" reads naturally.
  • Conditional gates (classical control, planned): measure first, then branch on the result — a "classical branch after collapse".
    # Planned: condition on the measurement result
    # qgate(H, 0)
    # if qgate(MEASURE, 0) == 0:
    #     qgate(X, 1)
    # else:
    #     qgate(Z, 1)
    

We don't dress up "classical branching after measurement" as "superposition" — teaching wrong physics is worse than not teaching at all.

4. Genuinely beginner-friendly

  • Clear error messages (English by default, Chinese via QUONIC_LANG=zh): they tell you what went wrong, why, and how to fix it
  • Autocomplete: gate names and parameters are hinted in VS Code / Jupyter
  • Automatic measurement: forgot to write measure? qshow() fills it in

5. Smart scheduler: automatically picks the fastest method

Quantum simulation has four methods whose speeds differ by orders of magnitude — picking wrong hits a wall:

Method Complexity Best for
statevector 2^n general default
stabilizer polynomial pure Clifford circuits (e.g. error-correcting codes)
matrix_product_state grows with treewidth low-treewidth circuits (e.g. QAOA)
density_matrix 4^n noise simulation

QuoNic's scheduler picks automatically based on circuit features (gate types, treewidth, whether it contains noise) — you never specify the method by hand. Measured evidence: GHZ(24) is 36× faster, QAOA(24) 19× faster; Grover's mcz only runs on statevector, and the scheduler routes around methods that would crash.

from quonic.scheduler import schedule
rec = schedule(circuit)   # -> Recommendation(backend='qiskit', method='stabilizer')

See scheduler benchmarks and measurements.

6. Full visualization suite: 23 chart types with only Matplotlib

from quonic.viz import plot_circuit, plot_counts, plot_decision_tree

plot_circuit(circuit)        # gate-sequence circuit diagram
plot_counts(result)          # measurement histogram
plot_decision_tree()         # scheduler decision tree

The 23 chart types span four layers: core needs (circuit / histogram / topology), scheduler evidence (method comparison / decision tree / heatmap / fallback chain / feature radar), algorithm teaching (energy convergence / Grover amplitude / statevector / Bloch sphere), and quantum states (density matrix / entanglement / gate matrix / routing / per-gate state evolution / noise cost). All with matplotlib as the single dependency, lazy-loaded, zero overhead on import quonic. See visualization suite.


📊 QuoNic vs Qiskit

Scenario Qiskit QuoNic
First quantum program 5–8 new concepts to learn just 2: qgate and qshow
Lines of code (Bell state) 8–12 lines 3 lines
Install to first result 30–60 minutes 2–3 minutes
Switching backends rewrite everything change one argument

🧠 Why the name QuoNic?

QuoNic is an acronym for Quantum Unified Operation Native Interface Core:

Letter Word Meaning
Q Quantum quantum
U Unified unified — one argument switches every backend
O Operation operations — qgate / qshow
N Native native — as natural as writing Python
I Interface interface — the backend adapter layer
C Core core — IR / scheduler / compiler

Pronounced /ˈkwɑnɪk/ ("kwah-nik").


🛠️ Currently supported backends

Backend Status Notes
Qiskit ✅ stable IBM ecosystem · local simulator
Cirq ✅ stable Google ecosystem · local simulator
PennyLane ✅ stable quantum machine learning · local simulator
Quantum Inspire ✅ connected real hardware Tuna-9 / Tuna-17 + QX simulator
More backends 📅 planned IBM / AWS Braket / domestic (Chinese) hardware...

Note: the Qiskit / Cirq / PennyLane backends run on local simulators; Quantum Inspire real hardware is reached via qshow(backend="qi", device="tuna9") (bare backend="qi" defaults to the QX cloud simulator and requires login). More cloud hardware (IBM / AWS Braket) is on the roadmap.

To pave the way for hardware, QuoNic already ships CouplingMap (coupling graph), the compile() compilation seam, and decompose() gate decomposition — which expands higher-order gates (cp / ccx / mcz) into the basic gate set. The latter is QuoNic's own "portable core": users aren't locked to one backend's circuit shape, and Grover's mcz decomposes into cx / h / p so it runs on every backend method. A greedy SWAP router route_swaps() is built in (with plot_routing visualization), so wiring up IBM / domestic engines later only touches the compilation layer — no changes to the IR or scheduler.


📖 Docs and tutorials


🤝 Contributing

QuoNic is open source (Apache 2.0) and welcomes all kinds of contribution:

  • Report bugs
  • Propose new features
  • Submit code (new backend adapters, gates, features)
  • Improve docs and tutorials

See CONTRIBUTING.md for the development setup, code style, and conventions.


📄 License

QuoNic is licensed under the Apache License 2.0 — friendly to commercial and closed-source use, with patent protection.


🌟 Star the project

If QuoNic helps you, please give us a ⭐️ on GitHub. Your support keeps us going.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quonic-0.3.0.tar.gz (138.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quonic-0.3.0-py3-none-any.whl (139.2 kB view details)

Uploaded Python 3

File details

Details for the file quonic-0.3.0.tar.gz.

File metadata

  • Download URL: quonic-0.3.0.tar.gz
  • Upload date:
  • Size: 138.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quonic-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cc5304780732c5ad11eeee69abb671bca281120ffa227c75d67b9e3c4a8c9f9c
MD5 cfcd39ceb72d36cd81c3d265a67be941
BLAKE2b-256 788bd219bc2e0663dba2a20800417574f62be28f354d641cd67c2a79ef3c35d2

See more details on using hashes here.

File details

Details for the file quonic-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: quonic-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 139.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quonic-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c8353b0773555cc4a82deb27d1ef418f5127a6728339d1ec774857d9b07ff9e
MD5 7d421433f78bc5573a5469ae51209964
BLAKE2b-256 b96b0945a3515185830dd4bebd48ef6ad5d9461b0d04320061b0473daf91209a

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.0

2 files

0.14.1

2 files

0.12.1

2 files

0.12.0

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.2

2 files

0.4.0

2 files

This release

0.3.0 This release

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page