quantum-learn
quantum-learn is a quantum machine learning library with backend-specific APIs for Pennylane and Qiskit, plus higher-level estimators and VQC wrappers for common workflows.
Features
- Backend-specific entry points such as
qlearn.pennylane.QuantumFeatureMapandqlearn.qiskit.QuantumFeatureMap - A generic
VariationalQuantumCircuitwith configurable measurement and loss settings - Task-oriented
VariationalQuantumClassifierandVariationalQuantumRegressorwrappers with sensible defaults - Hybrid estimators for classification, regression, and clustering on top of quantum feature maps
- Optional backend dependencies so importing
qlearndoes not require every quantum framework - A default top-level backend for users who want a simple
qlearn.QuantumFeatureMap()orqlearn.VariationalQuantumCircuit()entry point
Installation
Base install:
pip install quantum-learn
The base install is enough to import the package and use backend-independent utilities, but any quantum execution requires at least one backend extra.
Install with a specific backend:
pip install "quantum-learn[pennylane]"
pip install "quantum-learn[qiskit]"
Install both backends:
pip install "quantum-learn[all]"
Install Hugging Face Hub support:
pip install "quantum-learn[hf]"
Install from source:
git clone https://github.com/OsamaMIT/quantum-learn.git
cd quantum-learn
pip install -e ".[pennylane]"
Backend Model
qlearn.pennylaneexposes the implemented Pennylane backend.qlearn.qiskitcurrently exposes the QiskitQuantumFeatureMap.- The top-level
qlearn.QuantumFeatureMapandqlearn.VariationalQuantumCircuitresolve to the default backend, which is currently Pennylane. qlearn.qiskit.VariationalQuantumCircuitis intentionally not exported yet because it is not implemented.
Usage
Use a backend directly:
from qlearn.pennylane import QuantumFeatureMap
qfm = QuantumFeatureMap()
transformed = qfm.transform(data)
Use a hybrid estimator with an explicit backend:
from qlearn import HybridClassification
model = HybridClassification(backend="pennylane")
model.fit(features, labels)
predictions = model.predict(features)
Use clustering with a sklearn-style workflow:
from qlearn import HybridClustering
clusterer = HybridClustering(backend="pennylane")
labels = clusterer.fit_predict(features, n_clusters=3)
Use a task wrapper on top of the shared VQC:
from qlearn import VariationalQuantumClassifier, VariationalQuantumRegressor
classifier = VariationalQuantumClassifier()
classifier.fit(features, labels)
predictions = classifier.predict(features)
probabilities = classifier.predict_proba(features)
regressor = VariationalQuantumRegressor()
regressor.fit(features, targets)
values = regressor.predict(features)
Or use the generic VQC directly with explicit output and loss choices:
from qlearn import VariationalQuantumCircuit
vqc = VariationalQuantumCircuit()
vqc.fit(
features,
labels,
measurement="probabilities",
loss="cross_entropy",
)
raw_outputs = vqc.predict(features)
You can also override the task defaults by supplying custom target encoders, prediction decoders, probability decoders, ansatz functions, or fit-time VQC options.
Save a trained classifier locally and push it to the Hugging Face Hub:
from qlearn import VariationalQuantumClassifier
model = VariationalQuantumClassifier()
model.fit(X_train, y_train)
model.save_pretrained("./iris-vqc")
model.push_to_hub("KUQCI/iris-vqc-pennylane")
loaded = VariationalQuantumClassifier.from_pretrained("KUQCI/iris-vqc-pennylane")
print(loaded.predict(X_test))
save_pretrained() writes a transparent artifact directory with config.json,
weights.npz, metadata.json, and a Hugging Face-compatible README.md model
card. Hub support is optional. Install it with
pip install "quantum-learn[hf]".
The current safe serialization path supports the default
VariationalQuantumClassifier workflow with a qlearn backend VQC. Custom
encoders, decoders, ansatz callables, callable measurements, and callable losses
are rejected because they cannot be reconstructed safely without arbitrary code
execution.
API Notes
fit()is the primary training method.train()remains available as an alias for compatibility.HybridClustering.predict()now requires a fitted model. Usefit_predict()when you want clustering in a single call.VariationalQuantumClassifierdefaults to probability outputs and cross-entropy training, with automatic label encoding andpredict_proba().VariationalQuantumClassifiersupports Hugging Face-compatiblesave_pretrained(),from_pretrained(), andpush_to_hub()for default safe-serializable VQC classifiers.VariationalQuantumRegressordefaults to expectation-value outputs and MSE training, with automatic target scaling and inverse-scaling at prediction time.VariationalQuantumCircuitnow supports configurablemeasurement,measurement_wires, andlossvalues infit().- Both wrappers still accept custom target encoders and decoders when you want full control.
Documentation
For tutorials, examples, and details on the classes, check out the quantum-learn documentation.
Dependencies
If you're working with the source, the required dependencies can be installed by
pip install -r requirements.txt
Planned Features
- Implement quantum kernel methods
- Implement categorical feature maps
Contributing
Contributions are welcome! To contribute:
- Fork the repository
- Create a new branch (feature-branch)
- Commit your changes and open a pull request
License
This project is licensed under the MIT License. See LICENSE for details.
Metadata
Release files for quantum-learn 2.1.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 |
|---|---|---|---|---|
| quantum_learn-2.1.0.tar.gz | 24.3 kB | With provenance | Details for quantum_learn-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quantum_learn-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for quantum_learn-2.1.0-py3-none-any.whl |
Total release size: 48.0 kB
Release files / quantum_learn-2.1.0.tar.gz
| Download URL | quantum_learn-2.1.0.tar.gz |
|---|---|
| Size | 24.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7aa801144232ce0127daab358d95b85c320f30017937036f34df6b16f952cdd
|
|
BLAKE2b-256 checksum How to use checksums |
f52d7e6f2b4f8059543bb2b56ea01087edb853561d012aa68fa893803eff7665
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.
Transparency logRelease files / quantum_learn-2.1.0-py3-none-any.whl
| Download URL | quantum_learn-2.1.0-py3-none-any.whl |
|---|---|
| Size | 23.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
69012fffcabf736e91cee46b4b781d6f82d8560407523f2244c261205bc2d267
|
|
BLAKE2b-256 checksum How to use checksums |
50e411d28b62fc075932983223f43f21813cae3f3c967ffb31cbd7b9434a9ed8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.
Transparency logSecurity for quantum-learn 2.1.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for quantum_learn-2.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.
Transparency logA 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.