A programming language for hybrid AI and quantum computing
Quick Start • What It Does • Golden Snippets • Installation • Docs • Contributing
Synaphe (from the Greek synaphe, meaning "connection" or "junction") is a programming language that bridges classical AI and quantum computing. It transpiles to Python, giving you the entire PyTorch and Qiskit/PennyLane ecosystem — while adding three things Python lacks:
- Tensor shape checking at compile time — catches the #1 PyTorch runtime error before your code runs
- Linear quantum types — enforces the No-Cloning Theorem through the type system, preventing qubit reuse bugs
- Native automatic differentiation across quantum circuits —
grad()uses the Parameter Shift Rule for quantum gates and backpropagation for classical tensors, seamlessly
Today, building a hybrid quantum-classical ML workflow requires juggling Python, PyTorch, Qiskit, PennyLane, YAML configs, and dozens of MLOps tools. Tensor shape mismatches crash at runtime. Qubit reuse bugs produce garbage data silently. And computing gradients through quantum circuits requires manual Parameter Shift Rule implementations.
Synaphe reduces a 65-line VQE implementation to 18 lines — and catches shape errors, qubit bugs, and hardware constraint violations before your code ever touches a QPU.
# Clone the repository
git clone https://github.com/martus-spinther/synaphe-project.git
cd synaphe
# Run the interactive demo
python examples/demo.py
# Run the test suite (86 tests)
python tests/test_parser.py
python tests/test_typechecker.py
python tests/test_v030.py- Python 3.9+
- NumPy (for quantum simulation)
- Optional: PyTorch, PennyLane, Qiskit (for hardware execution)
These side-by-side comparisons show why Synaphe exists:
| Python / PennyLane (65 lines) | Synaphe (18 lines) |
|---|---|
import pennylane as qml
from pennylane import numpy as np
from pennylane import qchem
symbols = ["H", "H"]
coordinates = np.array([0.0, 0.0, -0.6614,
0.0, 0.0, 0.6614])
H, qubits = qchem.molecular_hamiltonian(
symbols, coordinates)
dev = qml.device("default.qubit", wires=qubits)
hf_state = qchem.hf_state(2, qubits)
@qml.qnode(dev)
def circuit(param):
qml.BasisState(hf_state, wires=range(qubits))
qml.DoubleExcitation(param, wires=[0, 1, 2, 3])
return qml.expval(H)
opt = qml.GradientDescentOptimizer(stepsize=0.4)
theta = np.array(0.0, requires_grad=True)
for n in range(100):
theta, energy = opt.step_and_cost(circuit, theta)
# + device setup, HF encoding, QNode decoration... |
|
See examples/golden_snippets.synaphe for 5 complete comparisons (VQE, hybrid ML, QAOA, differentiable chemistry, anomaly detection).
synaphe/
├── src/ # Language implementation
│ ├── lexer.py # Tokenizer (40+ token types)
│ ├── ast_nodes.py # Abstract syntax tree
│ ├── parser.py # Recursive descent parser
│ ├── types.py # Type system (tensor, quantum, differentiable)
│ ├── typechecker.py # Three-pillar type checker
│ ├── transpiler.py # Python code generator
│ └── hardware.py # Hardware-aware constraint checking
├── stdlib/ # Standard library
│ ├── runtime.py # Quantum simulation, autodiff, optimization
│ └── data.py # Data loading, validation, transforms
├── examples/ # Example programs
│ ├── demo.py # Executable demo of all features
│ ├── golden_snippets.synaphe
│ ├── mnist.flux
│ └── quantum_hybrid.flux
├── tests/ # Test suite (86 tests)
│ ├── test_parser.py # 47 lexer/parser tests
│ ├── test_typechecker.py # 19 type checker tests
│ └── test_v030.py # 20 hardware/data tests
└── docs/ # Documentation
├── DESIGN.md # Language specification
├── DESIGN_v2.md # Revised design principles
└── USER_GUIDE.md # Getting started guide
let x: Tensor<Float32, [32, 784]> = randn(32, 784)
let w: Tensor<Float32, [10, 128]> = randn(10, 128)
let y = x @ w
// ✗ ShapeMismatchError: inner dimensions 784 vs 10 do not match
let q = qregister(4)
let result = measure(q) // OK — consumes q
let oops = hadamard(q) // ✗ LinearityError: quantum state already measured
@differentiable
fn circuit(theta: Float) -> Float {
qubit() |> ry(theta) |> measure |> expectation(PauliZ)
}
let gradient = grad(circuit) // Uses Parameter Shift Rule automatically
// check_fidelity warns before you waste QPU time:
// ✗ [coherence] Circuit duration (17.6 μs) exceeds T2 (10 μs)
// ⚠ [fidelity] Estimated fidelity 12.3% — results dominated by noise
// ⚠ [connectivity] CNOT(0, 15) — qubits not directly connected
Includes real profiles for IBM Brisbane, IBM Sherbrooke, Google Sycamore, and IonQ Forte.
- v0.1 — Lexer, parser, Python transpiler, REPL
- v0.2 — Type system, linear quantum types, autodiff bridge
- v0.3 — Hardware constraint checking, data pipelines
- v0.4 — End-to-end
.synaphefile compilation and execution - v0.5 — Language server (LSP) for IDE support
- v0.6 — MLIR backend for optimized classical execution
- v0.7 — QIR backend for direct quantum hardware compilation
- v1.0 — Production release with complete standard library
We welcome contributions! See CONTRIBUTING.md for guidelines.
Good first issues are labeled good first issue — these are scoped, approachable tasks for newcomers. Areas where help is especially welcome:
- Standard library functions — implementing quantum algorithms (Grover, Shor, VQE variants)
- Hardware profiles — adding new QPU specifications
- Type checker improvements — better error messages, more inference
- Documentation — tutorials, examples, translations
- Testing — edge cases, property-based tests
- Website: synaphe.io
- Discussions: GitHub Discussions
- Issues: GitHub Issues
Apache 2.0 — see LICENSE for details.
If you use Synaphe in research, please cite:
@software{synaphe2026,
title={Synaphe: A Programming Language for Hybrid AI and Quantum Computing},
year={2026},
url={https://github.com/martus-spinther/synaphe}
}