DEV Community

Cover image for I Built a Quantum Circuit Simulator Without Understanding Quantum Physics
Ola Prøis
Ola Prøis

Posted on

I Built a Quantum Circuit Simulator Without Understanding Quantum Physics

A few days ago I set myself a weird challenge. I'm not a quantum physicist. I'm not a Rust developer. But I wanted to know: can you build something genuinely useful in a technical domain you don't personally understand, by directing AI carefully and being honest about what you don't know?

The answer, I think, is yes. But it's more complicated than that.


The Gap I Saw

I was looking at quantum computing tools and noticed something odd. Every visual quantum circuit editor is either a web app, a Python library that generates static plots, or a cloud-based service. Nothing just runs as a native binary on your desktop. No install process. No Python environment to manage. No browser required.

For someone learning quantum computing, that friction matters. You want to drag a gate onto a wire, see the Bloch sphere update in real time, step through the circuit gate by gate, and understand what's happening. You shouldn't need to pip install anything or log into IBM's cloud.

So I decided to build that. Even though I don't really understand quantum mechanics.

Tool Visual Editor Native Desktop Open Source Real-time Sim
KetGrid
Qiskit Composer ❌ (web) Partial Cloud
Quirk ❌ (web) ✅ (JS)
QPanda

How It Was Built

KetGrid is written entirely in Rust using egui for the GUI. The entire codebase was generated through AI-assisted development. I provided the direction, the architecture decisions, the requirements, and the review. The AI wrote the code.

I want to be completely transparent about this. It's in the README. It's not something I'm trying to hide, and I think it's actually part of what makes this interesting as an experiment.

The architecture ended up as a clean Cargo workspace with three crates:

KetGrid Architecture: three-crate Cargo workspace

  • ketgrid-core handles the circuit data model, gate definitions, and serialization formats
  • ketgrid-sim runs the state vector simulation engine with Rayon parallelism and gate fusion
  • ketgrid-gui is the egui application: the editor, visualizations, and everything you interact with

The sim crate uses rayon for parallelization on larger circuits and nalgebra for complex matrix operations.


What It Does Right Now

As of v0.1.0, released today:

KetGrid Demo

Circuit Editor: Drag gates from a palette onto qubit wires and see the state vector update in real time at 60fps. Right-click context menus, undo/redo (100 operations deep), and keyboard shortcuts.

Bloch Spheres: Per-qubit Bloch sphere for each qubit that updates as you build, computed from the reduced density matrix.

Step-Through Mode: Advance one gate column at a time with playback controls to watch the quantum state evolve. This is where the learning happens.

Probability Visualization: Phase-aware histogram coloring with toggleable amplitude tables. Entanglement between qubits is shown directly on the wires themselves.

21 Built-In Examples: Bell states, quantum teleportation, Grover's algorithm, QFT, Deutsch-Jozsa, Bernstein-Vazirani, Simon's, superdense coding, and the three-qubit Shor error correction code. All searchable from a built-in browser.

Export: OpenQASM 2.0, Qiskit Python code, SVG circuit diagrams, and a native JSON format.

The current ceiling is around 14 qubits in real time. GPU acceleration is planned for v0.3 to push that to 25+.


What I'm Genuinely Unsure About

Here's where I need to be honest. I don't know if this is useful.

I think the teaching and learning use case is real. Step-through mode with live Bloch spheres is something I haven't seen anywhere else in a native offline app. The 14-qubit ceiling is fine for Bell states, teleportation, Grover, and QFT.

But I don't know if the people who would benefit from this will find it, or whether the qubit ceiling is a dealbreaker for them, or whether I'm missing obvious things that would make it more useful.


Where I Want to Take It

The roadmap has three major workstreams after v0.1.0:

KetGrid Roadmap - three parallel workstreams

GPU Acceleration (Workstream A)

Push from ~14 to 25+ qubits using wgpu compute shaders. Cross-platform by default: Vulkan on Linux, DX12 on Windows, Metal on macOS. The crossover point where GPU beats CPU is around 13-15 qubits.

Quantum Phenomena Visualization (Workstream B)

Make quantum mechanics visceral. Animated amplitude flow showing how gate operations redistribute probability across basis states. Measurement collapse as a dramatic visual event. Entanglement propagation, "spooky action at a distance" made visible. A combined "Quantum Playground" mode for circuits ≤6 qubits.

Interactive Bell Inequality Experiment (Workstream C)

This is the one I'm most excited about. The idea is a mode where you run a CHSH test: the most important experiment in quantum physics. You collect measurement outcomes across multiple shots, watch the S-value rise, and see it cross the classical limit of 2.

That crossing is the empirical proof that quantum mechanics cannot be explained by classical hidden variables.

"Classical physics says S cannot exceed 2. You just measured S = 2.7. Welcome to quantum mechanics."

No existing tool lets you run this interactively and watch it happen. I don't know enough about this domain to know if I'm overestimating how compelling that would be. That's partly why I'm writing this.


The AI Development Angle

I want to say something about the process because I think it's worth discussing.

Building software in a domain you don't understand forces you to think very carefully about what you're asking for. You can't rely on instinct. You have to:

  • Describe behavior precisely: no hand-waving
  • Review output for correctness: even when you can't fully evaluate the implementation
  • Be honest about what you're missing4: and design around that honesty

There were things the AI got wrong that I didn't catch until much later. There are probably things in the current codebase that experienced Rust developers would consider bad patterns. That's part of the journey and I'm open about it.

What surprised me is how far you can get with this approach. The circuit editor works. The simulation is real. The export formats are correct. The thing I built actually does what I intended.


If You Want to Try It

KetGrid is MIT licensed, fully open source, and there are pre-built binaries for Windows, macOS, and Linux on the releases page. No install process, just download and run.

# Or build from source
git clone https://github.com/OlaProeis/KetGrid.git
cd KetGrid
cargo run --release -p ketgrid-gui
Enter fullscreen mode Exit fullscreen mode

If you're a quantum computing researcher, a physics educator, or a Rust developer, and you try it and have opinions, I'd really like to hear them. I'm specifically looking for feedback on whether the tool is actually useful in its current state, or whether specific roadmap items need to happen first before it's worth your time.

GitHub | Releases | Roadmap

Top comments (0)