Using quantum in a real applicationLesson 6 of 6

What to build

Start from the shape of the output your application needs.

Choose a quantum project by the output your application needs. A circuit gives your program exactly one thing, a distribution over bitstrings, and every application built on one consumes that distribution in one of five ways. An idea that fits none of the five does not need a circuit. Picking a famous algorithm first and then looking for a place to use it often turns up nothing that fits.

A decision tree. It starts by asking what the application must consume. One answer quickly means the baseline wins and there is no circuit. Amplitudes or phases means a simulator-only path with a two-to-the-n ceiling. Samples or a distribution reaches the five shapes. Survivors then pass four gates: latency budget, reproducibility, input size, and whether a mature classical answer exists. Failing any gate returns the idea to the baseline.
Fig. 1The output shape gives a circuit a possible role; whether that role is worth building depends on the four gates and the classical baseline.

Five things you can do with a distribution

Sample from it. You want draws, and you use the spread of outcomes directly. The picker you built takes this shape, and so does most generative work, where any given draw is as valid as another.

Quantum Garden maps five qubits' thirty-two outcomes to a plant's traits. Superposition Sequencer, by Francisco Estivallet, turns every note in a music sequencer into a draw from a circuit you designed. Quantum Patterns, by Peter Thomas and Paulo Itaboraí, uses partitioned quantum cellular automata to make musical material you can live-code against.

Compare two of them. You have a live state and a reference state, and you want a similarity score between them. Regime Radar prepares a fingerprint of current market conditions, runs a stored regime backwards over it, and reads the fraction of shots landing on all zeros as the overlap: when the two states match, the shots concentrate there.

Read structure inside it. You care less about which outcomes appear than about how the bits relate: which qubits agree, which are correlated, how that changes layer by layer. Butterfly Field turns pairwise entanglement into the threads between its butterflies. QCFlows renders the same structure as a live graph. Entangled Body, by Chanhyuk Park and Luke Shim, builds a point-cloud figure whose parts, per its write-up, respond to each other across distance.

Classical simulations of many entangled qubits get expensive quickly, so this shape has the least obvious classical shortcut.

Reduce it to one number. You want a score, and the distribution is only an intermediate. The Quantum Systemic Oracle reduces an optimization result to a single risk index. qOrbital, by Aryan Bawa and Arnav Singh, runs a chemistry calculation and reads out a molecule's energy. Quantum Market Game, by Aadarsh Venkat Ramanan, models two traders as two entangled qubits and reads their payoffs out of the tally.

Watch it change. This shape reads the statevector rather than a tally, so per lesson 2 it only exists on a simulator, which is enough for a tool that shows someone what a circuit is doing. QAVE, by Inho Choi, makes an algorithm visible gate by gate. Quantum Advantage Lab, by Hossein Sadeghi, streams four algorithms' intermediate state beside their classical counterparts. Quantum Canvas, by Shivani Mayekar, lets you drag operations into a circuit and watch the result move.

Watching it change is also the easiest of the five shapes to ship, because nothing queues.

Ideas that do not map

Most ideas do not map, for one of four reasons.

It needs one correct answer, quickly. A distribution is not an answer, and lesson 5 measured what the round trip costs. If your feature can be written with a lookup or a solver that returns in milliseconds, it should be.

It needs to process a lot of data. Getting classical data into a quantum state costs roughly one operation per number, so loading a large dataset takes longer than reading it. Your laptop already solves the problems small enough to fit on today's machines, and solves them exactly.

It needs the state itself, at scale. The fifth shape, watch it change, is fine for a teaching tool on a handful of qubits, but simulating n qubits takes 2ⁿ numbers, so an application built on statevectors hits a qubit limit quickly.

It needs to be reproducible. Two presses of an unchanged circuit disagree, as lesson 2's two Garden runs did. If your feature must produce the same output twice, the circuit has to sit behind a cache, which is the precomputed-pool shape from lesson 4.

These four reasons do not stop you learning, prototyping or building something because it interests you; they apply to shipping a feature.

The shape of a good first idea

The projects in this course share three things: a small circuit, a decode step doing most of the visible work, and a stated reason for the quantum part to be there.

Garden needed a supply of unpredictable, structured variation, and a pool of measurement outcomes gave it one. Butterfly Field set out to make entanglement visible. Regime Radar needed a similarity measure and chose a kernel that a circuit computes directly.

None of the three needed to beat a classical computer, which lesson 5 showed is rare today.

From one probability to two inputs and four named outcomes

A probability is the smallest thing you can put through a circuit. An application has several, and it needs its results named before anything can branch on them.

The next step up has two independent inputs, one qubit for each, and four named outcomes.

slice.py Python · PlaygroundOpen in Playground ↗
# 'backend' already exists when this runs: it is whatever you pick in the Run Experiment dialog.
from math import asin, sqrt
from qiskit import QuantumCircuit
from qiskit.providers.jobstatus import JobStatus
import time
​
shots = 1000
1p_left = 0.2
2p_right = 0.8
​
3NAMES = {
    "00": "neither",
    "01": "left_only",               #   key is c1 c0, so the RIGHT character is qubit 0
    "10": "right_only",
    "11": "both",
}
​
​
4def build_circuit(pl, pr):
    qc = QuantumCircuit(2, 2)
    qc.ry(2 * asin(sqrt(pl)), 0)
    qc.ry(2 * asin(sqrt(pr)), 1)
    qc.measure([0, 1], [0, 1])
    return qc
​
​
5def decode(counts, n):
    return {NAMES[k]: v / n for k, v in sorted(counts.items())}
​
​
job = backend.run(build_circuit(p_left, p_right), shots=shots)
while job.status() not in (JobStatus.DONE, JobStatus.ERROR, JobStatus.CANCELLED):
    time.sleep(5)
​
counts = job.result().get_counts()
print(counts)
​
for name, share in sorted(decode(counts, shots).items()):
    print(f"{name:11s} {share:.3f}   {'#' * int(40 * share)}")
print(f"expected both = {p_left * p_right:.3f}, neither = {(1 - p_left) * (1 - p_right):.3f}")
  1. 1one input per qubit: how often the left step fires
  2. 2and the right one
  3. 3the result schema the rest of the app codes against
  4. 4two app values in, one two-qubit circuit out
  5. 5counts in, named results out

Three things changed from the picker, and all three are the parts you would write for any application.

Two inputs, two qubits. p_left and p_right each get their own ry. Nothing entangles the two qubits, so the four outcomes are the two probabilities multiplied out, and calling random.choices twice would do the same job.

A result schema. NAMES turns bitstrings into neither, left_only, right_only and both. The rest of the program branches on those words and never sees a bitstring. Adding a third input later means changing this table.

The bit order, stated once. A counts key reads c1 c0, so the rightmost character is qubit 0, and 01 means the left step fired and the right one did not. Get this backwards and your application does the opposite of what you meant, silently, because both keys are valid.

Our run on 22 September 2026, with p_left = 0.2 and p_right = 0.8:

{'00': 172, '01': 56, '10': 621, '11': 151}
both        0.151   ######
left_only   0.056   ##
neither     0.172   ######
right_only  0.621   ########################
expected both = 0.160, neither = 0.160

The ideal shares are 0.160, 0.040, 0.640 and 0.160. Every measured share sits near its ideal.

Assignment: name the results your own idea needs

  1. Open /u/qollab/learn-app-slice, press Fork, then Fork Project in the dialog.
  2. In your fork, rename the four entries in NAMES to the four outcomes your own idea would branch on.
  3. Set p_left and p_right to the two probabilities your idea needs.
  4. Work out the ideal share of each of your four outcomes, by multiplying the two probabilities out.
  5. Predict which of your four will be the noisiest, and say why.
  6. Press Run on Qollab, choose IonQ Aria 1 (25q) under Remotely Run Simulators, and press Run.
  7. Compare the four printed shares against the four you worked out.
Solution

The four ideal shares are (1-pl)(1-pr), pl(1-pr), (1-pl)pr and pl·pr, in the order neither, left_only, right_only, both.

The noisiest in relative terms is the smallest, because the uncertainty on a share is roughly the square root of its count divided by the shots. Ours was left_only: 56 shots, an ideal 40, and a measured 0.056 against 0.040. The same absolute error on right_only, which had 621 shots, is small by comparison.

If your four names do not cover every outcome, the listing raises a KeyError on the first key you left out, so the mistake shows up in development instead of in production.

Assignment: encode one probability from your own idea

Put one probability from your own idea through the boundary you built in lesson 3.

  1. Write down an idea in one sentence, and say which of the five shapes it needs.
  2. Find the single probability in it: a drop rate, a chance a note plays, how often a branch is taken, or how likely one of two states is.
  3. Open your fork of /u/qollab/learn-app-boundary from lesson 3. If the percent edit is still there, leave it.
  4. Set p_rare to your probability, and predict the tally you expect from 1,000 shots.
  5. Press Run on Qollab, choose IonQ Aria 1 (25q) under Remotely Run Simulators, and press Run.
  6. Write down three lines: the idea, its output shape, and the circuit that would sit inside it. If step 1 showed the idea fits none of the five shapes, write down which of the four reasons it hit instead.
Solution

A worked example: "A rhythm generator where each step has a chance of firing." The rhythm generator needs shape one, sample from it. The probability is the chance a step fires, say 0.35. Setting p_rare = 0.35 should give about 350 ones in 1,000 shots, inside a 95% window of roughly 320 to 380. The circuit inside the generator is one ry per step, or one circuit sampled repeatedly.

A worked rejection: "A scheduler that picks the cheapest delivery route." The scheduler is shape four, reduce to one number, and it hits the first reason. Classical routing heuristics are decades mature, and Quantum Courier's published stage 3 result is one measurement of that: classical annealing beat four QAOA variants at 25 customers.

Your tally will not equal your prediction exactly, for the reason lesson 2 gave.

Takeaway

Start from what your application consumes and choose the algorithm last. Match the output to one of the five things a distribution can do, then check the idea against the four reasons ideas fail to map.

You can put a circuit inside a program, decide whether it belongs there, and work out what to build next.

Stay in the loop.

Get the latest tutorials, demos, and project showcases straight to your inbox. No noise, just the good stuff.