5eea6bcc5b
Extracted from micro-kiki for open-source release. Pure-torch VQC matching
PennyLane default.qubit at 1e-5 numerical precision, with autograd training
and batched inference.
Contents:
src/torch_vqc/
circuit.py — torch_vqc_forward (6-qubit StronglyEntanglingLayers)
router.py — TorchVQCRouter nn.Module + optional learned projection
__init__.py — public API exports
tests/ (10 tests, all passing)
test_circuit.py — forward match vs PennyLane, single + batched
test_training.py — loss decrease, accuracy, gradient flow, 20x speedup
test_projection.py — learned projection rescues hard tasks, shape checks
conftest.py — sys.path shim for tests without pip install -e
pyproject.toml — Apache-2.0, Python 3.10+, deps: torch+numpy, test: pennylane
README.md — quick start, benchmarks, conventions, citation
LICENSE — Apache 2.0 full text
docs/findings.md — scientific background (from micro-kiki Plan 6)
Measured speedup on 6-qubit 6-layer circuit with 120 training samples × 3 epochs:
PennyLane parameter-shift: ~99 s
torch-vqc autograd: ~30 ms
= ~3000x speedup.
52 lines
1.5 KiB
TOML
52 lines
1.5 KiB
TOML
[build-system]
|
||
requires = ["hatchling"]
|
||
build-backend = "hatchling.build"
|
||
|
||
[project]
|
||
name = "torch-vqc"
|
||
version = "0.1.0"
|
||
description = "Pure-torch variational quantum circuit (VQC) with autograd training — ~3000× faster than PennyLane parameter-shift on 6-qubit StronglyEntanglingLayers."
|
||
readme = "README.md"
|
||
requires-python = ">=3.10"
|
||
license = { text = "Apache-2.0" }
|
||
authors = [{ name = "L'électron rare" }]
|
||
keywords = ["quantum-machine-learning", "vqc", "pytorch", "autograd", "pennylane", "variational-quantum-circuit"]
|
||
classifiers = [
|
||
"Development Status :: 3 - Alpha",
|
||
"Intended Audience :: Science/Research",
|
||
"License :: OSI Approved :: Apache Software License",
|
||
"Programming Language :: Python :: 3",
|
||
"Programming Language :: Python :: 3.10",
|
||
"Programming Language :: Python :: 3.11",
|
||
"Programming Language :: Python :: 3.12",
|
||
"Programming Language :: Python :: 3.13",
|
||
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
||
"Topic :: Scientific/Engineering :: Physics",
|
||
]
|
||
dependencies = [
|
||
"torch>=2.0",
|
||
"numpy>=1.24",
|
||
]
|
||
|
||
[project.optional-dependencies]
|
||
test = [
|
||
"pytest>=7.0",
|
||
"pennylane>=0.40",
|
||
]
|
||
dev = [
|
||
"pytest>=7.0",
|
||
"pennylane>=0.40",
|
||
"ruff>=0.4",
|
||
]
|
||
|
||
[project.urls]
|
||
Repository = "https://github.com/electron-rare/torch-vqc"
|
||
Issues = "https://github.com/electron-rare/torch-vqc/issues"
|
||
|
||
[tool.hatch.build.targets.wheel]
|
||
packages = ["src/torch_vqc"]
|
||
|
||
[tool.pytest.ini_options]
|
||
testpaths = ["tests"]
|
||
addopts = "-v"
|