Skip to content

Added interactive quantum circuit playground with tutorials#9

Open
CodeMaverick2 wants to merge 3 commits intoOpenQuantumDesign:mainfrom
CodeMaverick2:feat/quantum-circuit-playground
Open

Added interactive quantum circuit playground with tutorials#9
CodeMaverick2 wants to merge 3 commits intoOpenQuantumDesign:mainfrom
CodeMaverick2:feat/quantum-circuit-playground

Conversation

@CodeMaverick2
Copy link
Copy Markdown

@CodeMaverick2 CodeMaverick2 commented Feb 24, 2026

Summary

Interactive digital quantum circuit builder that lets users visually build circuits, simulate quantum states, and execute on hardware. Complements the analog program builder (#5) to complete the teaching demo for Issue #3.

What's New

3 new modules:

  • digital_simulator.py - quantum state simulation (kronecker product math, measurement sampling)
  • digital_compiler.py - compiles Circuit → laser intensity patterns + trap commands
  • gui/circuit_builder.py - interactive NiceGUI UI with circuit grid, gate palette, and results panel

Modified:

  • digital.py - fixed pydantic v2 compatibility (root_validatormodel_validator), relaxed qubit count to match 4-laser hardware
  • gui/programs.py - added preset circuits (Bell state, GHZ, superposition, X gate)
  • gui/main.py - wired "Quantum Playground" button to circuit builder

Features:

  • 4×6 clickable circuit grid (qubits × time steps) with I/X/Z/H/CNOT gates
  • Real-time quantum simulation with state vector display and probability bar charts
  • Measurement sampling (100/1000 shots) with histogram visualization
  • Hardware execution — lasers fire per gate, trap shakes during CNOT
  • 4 guided tutorials: Superposition, Bit Flip, Entanglement (Bell State), GHZ State
  • Export: "Show Circuit JSON" (OQD digital IR) and "Show Laser Program" (compiled hardware commands)
  • No new dependencies (uses NiceGUI's built-in ECharts)

Demo -

Screen.Recording.2026-02-24.110521.1.mp4

Test Plan

  • python src/oqd_teaching_demo/gui/main.py starts without errors (MOCK=True)
  • All 4 tutorials load correct presets and step text
  • Free Build: place/clear/reset gates, add/remove columns
  • Simulate shows correct state vectors and probabilities
  • Sample 100/1000 shots produces histogram
  • Run on Hardware fires mock lasers + trap shake for CNOT
  • Show Circuit JSON and Show Laser Program display correct output
  • No new dependencies added

Closes - #3

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants