Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

How To Use This Book

This book works best when you treat it like a lab manual, not a novel.

That means: reading is only half the battle. The other half is typing code, running it, breaking it, and fixing it.

The Chapter Pattern

Every chapter follows this rhythm:

1. Learn one mental model
   ↓
2. Type a short Qiskit example
   ↓
3. Predict the result before running
   ↓
4. Run and compare
   ↓
5. Solve checkpoint exercises
   ↓
6. Try a QCoder problem

Skip the steps, and you’ll finish the book without the skills to use it.

Four Layers Per Chapter

Most chapters have four layers:

1. The Mental Model

This is the conceptual understanding. Examples:

  • “A Hadamard gate is a basis change, not just a gate symbol”
  • “cx(control, target) means ‘flip the target if the control is 1’”
  • “A phase can be invisible in immediate counts but still matter later”

If you skip this layer, Qiskit becomes memorization instead of understanding.

2. The Qiskit Move

This is the code pattern you’ll use repeatedly:

  • QuantumCircuit to define circuits
  • Statevector to inspect exact states
  • StatevectorSampler to sample measurement outcomes
  • compose, inverse, control to assemble larger circuits

These tools are reused until they feel routine.

3. The Worked Pattern

This is the circuit design skill:

  • preparing a basis state
  • creating superposition
  • building an oracle
  • implementing a reflection

Once you can name a pattern, many QCoder problems stop feeling unique.

4. The Exercises

Exercises are where learning becomes skill. Each chapter includes:

  • Checkpoint exercises — targeted practice with the chapter’s concept
  • QCoder problems — linked challenges from QCoder contests

The Reading Rhythm

For each chapter, use this rhythm:

  1. Read once without writing code (get the big picture)
  2. Type every code block yourself (muscle memory)
  3. Predict the result before running (this is critical)
  4. Run and compare (did you get what you expected?)
  5. Change one thing and predict again (explore)
  6. Solve at least one QCoder problem before moving on

That last step matters. If you only read, the material will feel clearer than it really is. QCoder problems expose gaps in understanding that passive reading hides.

The Statevector-First Workflow

Here is the workflow that will save you hours of frustration:

  1. Write the circuit
  2. Inspect Statevector()
  3. Predict what you expect
  4. Compare actual vs expected
  5. If wrong: debug using the checklist below
  6. Only then: measure and sample

This order matters because:

  • The statevector tells you exactly what the circuit does
  • Sampling only shows statistical outcomes
  • Many bugs are invisible in counts but obvious in amplitudes

The Debugging Checklist

When a circuit doesn’t behave as expected, check these in order:

#CheckWhat to look for
1Qubit orderingIs |10> interpreted as you expect?
2Amplitudes vs countsAre you looking at the right thing?
3Measurement timingDid you measure too early?
4Inverse/uncomputeDid you forget to undo temporary operations?
5Global vs relative phase-1 on one branch vs -1 on all branches
6Control vs targetIs your CNOT control-target correct?

This checklist resolves a surprising number of “quantum mysteries.”

QCoder: Your Practice Partner

QCoder problems are structured challenges that test your circuit-building skills. Each problem:

  • Provides a clear specification
  • Tests your circuit against known inputs
  • Gives immediate feedback on correctness

How to use them:

  1. Finish a chapter’s exercises
  2. Pick a linked QCoder problem (see the QCoder Problem Catalog)
  3. Read the problem description carefully
  4. Design your circuit on paper first
  5. Implement in Qiskit
  6. Submit and iterate

QCoder is unforgiving in the best way: either your circuit works, or it doesn’t.

Current QCoder Problems: 79 problems across 6 contests, organized by topic in the QCoder Problem Catalog.

When You Get Stuck

Getting stuck is part of the process. Here’s what to do:

On conceptual confusion:

  • Reread the mental model section
  • Draw the circuit by hand
  • Google with the phrase “qiskit [concept] example”

On code errors:

  • Copy the exact error message
  • Check Qiskit version (pip show qiskit)
  • Try the book’s exact code first

On circuit behavior:

  • Add print(Statevector(qc)) to see what’s happening
  • Test on the simplest possible input
  • Check the debugging checklist

On QCoder problems:

  • Read the problem statement again (twice)
  • Verify you understand the input/output format
  • Check if there’s a hint in the problem comments
  • Try the problem with fewer qubits first

How This Book Is Organized

The book has six parts:

PartTopicApprox. Difficulty
IHello, Quantum WorldGetting started
IISingle-Qubit ToolkitFoundational
IIITwo-Qubit TerritoryFoundational
IVCircuit PatternsIntermediate
VAlgorithmsIntermediate/Advanced
VIPutting It TogetherApplied

Don’t skip parts. Each one builds on the previous.

A Note on Pacing

This book is designed to be worked through over several weeks, not read in a weekend.

If you’re doing one chapter per day:

  • Days 1-5: Part I (Foundations)
  • Days 6-12: Part II (Single-Qubit)
  • Days 13-18: Part III (Two-Qubit)
  • Days 19-25: Part IV (Patterns)
  • Days 26-32: Part V (Algorithms)
  • Days 33-35: Part VI (Application)

Take breaks. Quantum intuition takes time to build.


Next: Setup