MCPcopy Index your code
hub / github.com/Fraunhofer-AISEC/qml-playground

github.com/Fraunhofer-AISEC/qml-playground @v1.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.0 ↗ · + Follow
138 symbols 365 edges 25 files 83 documented · 60%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

DOI arXiv

QML Playground Illustration

Quantum Machine Learning Playground

The Quantum Machine Learning (QML) Playground is an interactive web application designed to visualize and explore the inner workings of quantum machine learning models in an intuitive and educational way. Inspired by classical tools like TensorFlow Playground, it focuses on parameterized quantum circuits (PQCs) — particularly the data re-uploading universal quantum classifier — and introduces visual metaphors such as Bloch spheres and the Q-simplex to interpret quantum state evolution.

Now extended beyond classification, the playground also supports regression tasks, uncertainty quantification, and regularization techniques, enabling deeper exploration of quantum model performance and generalization.

This playground is ideal for learners, educators, and researchers who want to explore QML models without requiring deep expertise in quantum hardware or simulators.


🌐 Live Demo

Screenshot of the QML Playground

Explore the QML Playground directly in your browser:

👉 Try the Live Demo

No installation required — perfect for quick experimentation, education, and outreach.


🧠 How the Quantum Model Works

The playground demonstrates the data re-uploading variational quantum model, a flexible architecture introduced by Pérez-Salinas et al. (Quantum, 2020). This architecture repeatedly embeds classical features into quantum states using trainable gates, mimicking the depth and expressivity of classical neural networks.

Originally designed for classification, it now also supports quantum regression, expanding its educational and research potential.

This model was chosen because it is:

  • Structurally similar to common variational quantum circuit (VQC) architectures
  • Simple enough to visualize intuitively
  • Powerful enough to be universal, capable of approximating any function in principle
  • Flexible enough to illustrate training dynamics, regularization effects, and uncertainty estimates for regression tasks

✨ Features

🧩 Core Functionality

  • 🧠 Real-time QML model training and visualization
  • 🌐 Visual Metaphors for Data and Quantum State Evolution
  • Bloch Sphere for single-qubit state dynamics
  • Q-Simplex for multi-qubit and entanglement visualization
  • 🔍 Layer-by-Layer Quantum Circuit Analysis
  • 📊 Interactive Performance Metrics and Learning Curves
  • 🎯 Decision Boundary Visualizations (for classification)
  • 🧪 Flexible Dataset Generation and Hyperparameter Controls

📈 New in the Latest Version

  • 🔢 Regression Task Support – Go beyond classification to predict continuous target values using quantum circuits
  • ⚖️ Regularization Options – Add L1/L2 penalties to study overfitting and model smoothness
  • 🌫️ Uncertainty Quantification (for Regression) – Visualize predictive uncertainty through sampling-based variance estimation, highlighting how model confidence varies across the input space

🐳 Deployment & Accessibility

  • 💻 Browser-Based Interface – Explore directly in your browser, no installation needed
  • 🐳 Docker Support for Easy Deployment
  • 📦 Lightweight and Educational by Design

🔧 Requirements

  • Python 3.11+
  • Virtual environment (virtualenv)
  • Required Python packages listed in requirements.txt
  • Docker and Docker Compose (optional)

🚀 Installation

# 1. Clone this repository
git clone https://github.com/fraunhofer-aisec/qml-playground
cd qml-playground

# 2. Set up virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# 3. Install dependencies
pip install -r requirements.txt

🖥️ Running the Application

Local Development

python app_dev.py

Then visit: http://127.0.0.1:8050/

Docker Deployment

Pull the latest Docker image from the GitHub Container Registry:

docker pull ghcr.io/fraunhofer-aisec/qml-playground:latest
docker-compose up -d  # Start container
docker-compose down   # Stop container

🛠 Troubleshooting

  • Ensure all required packages are installed
  • Verify port 8050 (local) or 80 (Docker) is free
  • Make sure Docker Desktop is running (for Docker users)

📚 Citation

If you use this tool in your research or presentations, please cite:

P. Debus, S. Issel, and K. Tscharke, "Quantum Machine Learning Playground," IEEE Computer Graphics and Applications, vol. 44, no. 05, pp. 40–53, Sept.–Oct. 2024. DOI: 10.1109/MCG.2024.3456288

The arXiv version of this paper is available here: 2507.17931


🙋 Maintainer

Developed and maintained by Pascal Debus, Quantum Security Technologies (QST), Fraunhofer AISEC.

If you find this work useful, feel free to connect or reach out for collaboration opportunities!

Core symbols most depended-on inside this repo

apply_unitary
called by 11
app/backends/torch_state_vector_simulator.py
unserialize_model_dict
called by 4
app/utils/serialization.py
create_target
called by 4
app/data/datasets_torch.py
get_single_qubits_unitary
called by 4
app/backends/torch_state_vector_simulator.py
get_Pauli_system_unitary
called by 4
app/backends/torch_state_vector_simulator.py
evaluate
called by 4
app/models/reuploading_regressor.py
load_model
called by 4
app/models/reuploading_model_base.py
convert_state_vector_to_bloch_vector
called by 3
app/utils/qstate_representations.py

Shape

Function 65
Method 53
Route 14
Class 6

Languages

Python100%

Modules by API surface

app/logic.py28 symbols
app/backends/torch_state_vector_simulator.py26 symbols
app/plotting.py13 symbols
app/data/datasets_torch.py13 symbols
app/models/reuploading_model_base.py10 symbols
app/models/reuploading_classifier.py9 symbols
app/utils/serialization.py8 symbols
app/models/reuploading_regressor.py8 symbols
app/visualization/two_qubits.py5 symbols
app/visualization/single_qubit.py4 symbols
app/backends/torch_single_qubit_reuploading.py4 symbols
app/utils/qstate_representations.py3 symbols

For agents

$ claude mcp add qml-playground \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page