Edukaizen

Menu
  • Nieuws
  • Hubbard 1D
    • Part 1: 1D Hubbard model
    • Part 2: Snake layout and fSWAP
    • Part 3: Qiskit and Fire Opal
    • Part 4: 120-qubit run
    • Part 5: Time-to-answer
    • Part 6: Tensor networks
    • Part 7: Majorana propagation
    • Part 8: Heatmaps
    • Part 9: 2D Hubbard outlook
    • Part 10: Quantum computer as a lab
    • Part 11: Official Monoprop benchmark
  • Hubbard 2D
    • Part 1: 1D to 2D
    • Part 2: Cuprates
    • Part 3: 3×3
    • Part 4: Time
    • Part 5: 4×4
    • Part 6: 6×6 Fez
  • Hadron
    • Deel 1: Hadron op quantumprocessor
    • Deel 2: Quarks en confinement
    • Deel 3: SU(2) en LSH
    • Deel 4: Hamiltoniaan en circuit
    • Deel 5: Fire Opal
    • Deel 6: Klassieke simulaties
    • Deel 7: Quantumvoordeel
  • Black Hole OLE
    • Part 1: What we ran
    • Part 2: How OLE works
    • Part 3: Fire Opal and Kingston
    • Part 4: The tensor-network challenge
    • Part 5: Hawking and scrambling
    • Part 6: What the result proves
    • Part 7: Local toy model
    • Part 8: QGSS26 compatibility
  • Random Graph
    • Start here
    • Part 1: Theory
    • Part 2: Circuit
    • Part 3: Qiskit
    • Part 4: Complexity
    • Part 5: Verification
    • Part 6: Workflow
    • Part 7: Conclusion
  • QOS QML
    • Tutorial: UMI counts to a four-qubit circuit
    • Part 1: The QML task
    • Part 2: QOS theory
    • Part 3: Gene expression to 40 qubits
    • Part 4: JAX to hardware
    • Part 5: Readout and classifier
    • Part 6: 40-qubit result
    • Part 7: Route to quantum advantage
    • Part 8: 60-qubit result
  • Floquet-Ising
    • Part 1: Floquet physics
    • Part 2: Ising cycle
    • Part 3: Two-qubit toy model
    • Part 4: Oscillation and entanglement
    • Part 5: Noise and error mitigation
    • Part 6: Toward 51 qubits
  • Quantumgoud
    • Deel 1: Waarom goud een relativistisch quantumprobleem is
    • Deel 2: Waarom het goud-VQE-onderzoek uit 2025 vastliep
    • Deel 3: Van QE en spin-baan-koppeling naar Qiskit
    • Deel 4: Twaalf goud-spinormodi op vier qubits
    • Deel 5: De 24-qubit route: een actief venster voor transport
    • Deel 6: 24 qubits op IBM en met Fire Opal
    • Deel 7: De route naar quantumvoordeel voor goud
  • Advantage List
Menu

Beginner’s guide to QML: from UMI counts to a four-qubit circuit

English | Nederlands | Series hub | Next part | QOS paper | Official code | Hardware code

How does a row of gene-expression data become an executable quantum circuit? In this guide, we follow one real PBMC68k cell from raw UMI counts to four rotation angles, a small Qiskit circuit, eight quantum features, and a classical classifier.

This is deliberately a beginner model. It runs on a four-qubit simulator, uses only 16 training and 16 test cells, and makes no quantum-advantage claim. Its purpose is to make the complete translation chain visible and reproducible.

1. The task: distinguish two immune-cell types

In our loader, the PBMC68k dataset contains 68,579 cells and 32,738 genes. A row is one cell, a column is one gene, and every matrix value is a molecule count. We select two cell types:

  • CD4+/CD25 T Reg;
  • CD4+/CD45RO+ Memory.

The selected binary subset contains 9,248 cells. For the educational experiment, fixed seed 11 selects eight training and eight test cells per class. Training and test sets do not overlap.

The task is therefore not to look up a gene. It is:

gene-expression profile of one cell -> quantum feature map -> predicted cell type

2. What is a UMI count?

UMI means Unique Molecular Identifier. Before amplification in the laboratory, every captured RNA molecule receives a short barcode. Reads with the same cell barcode, gene, and UMI are probably copies of the same original molecule, so they count together as one molecule.

From sequencing reads to two unique UMI counts
From sequencing reads to two unique UMI counts

A cell with five reads carrying UMI ACGT and four reads carrying UMI TGCA therefore has nine reads for that gene, but only two distinct UMIs. The resulting count matrix is sparse and contains non-negative integers. A zero means that no molecule was detected; it does not prove that the gene was biologically absent.

3. Split first, then learn every choice

All data-dependent choices are made from the sixteen training cells only:

  1. select four genes without using labels;
  2. learn normalization and scaling parameters;
  3. calculate quantum features for the training set;
  4. train the classical classifier;
  5. only then evaluate the sixteen held-out test cells.

Among genes with a useful detection frequency, the script selects the four largest training variances. For seed 11 these are:

Qubit Gene Detection in training Training mean Training standard deviation
0 IER2 0.6250 1.724827 1.482075
1 ACTG1 0.7500 2.261162 1.377323
2 LIMD2 0.5625 1.427313 1.354013
3 GLTSCR2 0.7500 2.266142 1.349629

The order matters: selecting genes with knowledge of test labels, or fitting the scale on test values, would introduce data leakage.

4. From a raw UMI count to a rotation angle

Cells do not all contain the same total amount of measured RNA. We therefore divide the count for gene g by all UMIs in cell i, scale to 10,000, and apply log1p:

\[n_{ig}=10{,}000\frac{x_{ig}}{\sum_h x_{ih}}, \qquad \ell_{ig}=\log(1+n_{ig}).\]

We then use only the training mean and training standard deviation:

\[z_{ig}=\frac{\ell_{ig}-\mu_g^{\mathrm{train}}}{\sigma_g^{\mathrm{train}}}.\]

The z-score is clipped to [-3,3] and converted into an angle:

\[\theta_{ig}=\pi\frac{\operatorname{clip}(z_{ig},-3,3)}{3}.\]

Every angle therefore lies between -pi and pi.

The first real training cell has label CD4+/CD45RO+ Memory, contains 2,010 UMIs in total, and produces:

Gene Raw UMI log1p z-score Angle in radians
IER2 0 0.000000 -1.163792 -1.218720
ACTG1 3 2.767914 0.367925 0.385290
LIMD2 1 1.787605 0.266092 0.278651
GLTSCR2 2 2.393362 0.094263 0.098712
The complete route from UMI data to a hybrid prediction
The complete route from UMI data to a hybrid prediction

5. The four-qubit circuit

We start in basis state |0000>. Each angle controls one RY gate. Four CNOT gates then connect the qubits in a ring: 0->1, 1->2, 2->3, and 3->0.

The four-qubit circuit for the example cell
The four-qubit circuit for the example cell

The Y rotation has matrix:

\[R_Y(\theta)=\begin{pmatrix}\cos(\theta/2)&-\sin(\theta/2)\\ \sin(\theta/2)&\cos(\theta/2)\end{pmatrix}.\]

For four qubits, the rotation layer is the tensor product:

\[R=R_Y(\theta_3)\otimes R_Y(\theta_2)\otimes R_Y(\theta_1)\otimes R_Y(\theta_0).\]

The complete cell-dependent operation is:

\[U(\theta)=\operatorname{CNOT}_{3\rightarrow0}\operatorname{CNOT}_{2\rightarrow3}\operatorname{CNOT}_{1\rightarrow2}\operatorname{CNOT}_{0\rightarrow1}R.\]

Four qubits have 2^4 = 16 basis states, so U is a 16 x 16 matrix. The numerical check gives ||U^dagger U-I||_F = 1.11 x 10^-15: within rounding error, the matrix is unitary.

Absolute values of the 16 x 16 unitary matrix
Absolute values of the 16 x 16 unitary matrix

6. From state to measurement probabilities

The circuit creates the state:

\[|\psi(\theta)\rangle=U(\theta)|0000\rangle=\sum_{b=0}^{15}a_b|b\rangle.\]

According to the Born rule, the probability of bit string b is:

\[p_b=|a_b|^2, \qquad \sum_b p_b=1.\]

For the example cell, the largest ideal probabilities are:

Basis state q3q2q1q0 Probability
0000 0.633736
1110 0.308730
1111 0.024114
1101 0.012463

Qiskit displays bit strings as q3 q2 q1 q0; qubit 0 is therefore on the right.

7. Eight quantum features from bit strings

For a measured bit b_q, we use the Z eigenvalue (-1)^{b_q}. The single- and two-qubit expectation values are:

\[\langle Z_q\rangle=\sum_b p_b(-1)^{b_q},\]
\[\langle Z_qZ_r\rangle=\sum_b p_b(-1)^{b_q+b_r}.\]

Each cell produces four single-qubit Z features and four neighbouring ZZ features:

\[f(x)=(\langle Z_0\rangle,\langle Z_1\rangle,\langle Z_2\rangle,\langle Z_3\rangle,\langle Z_0Z_1\rangle,\langle Z_1Z_2\rangle,\langle Z_2Z_3\rangle,\langle Z_3Z_0\rangle).\]
Ideal quantum features and estimates from 512 shots
Ideal quantum features and estimates from 512 shots
Feature Ideal 512 shots
Z0 0.886607 0.914063
Z1 0.319566 0.300781
Z2 0.307240 0.281250
Z3 0.305744 0.281250
Z0Z1 0.329931 0.308594
Z1Z2 0.961427 0.964844
Z2Z3 0.995132 1.000000
Z3Z0 0.344847 0.328125

The difference between ideal values and 512-shot estimates is ordinary sampling noise. More shots reduce the average error, but require more circuit executions.

8. Why a classical classifier is still required

The quantum circuit produces features; it does not choose the final label by itself. Using the sixteen training labels, a classical logistic-regression model learns:

\[P(y=+1\mid f)=\sigma(w^Tf+b), \qquad \sigma(a)=\frac{1}{1+e^{-a}}.\]

On the sixteen held-out test cells, the result is:

Model Correct Balanced accuracy
Four-qubit quantum features 7/16 0.4375
Classical, using the same four genes 9/16 0.5625

This is a successful reproducibility and teaching demonstration, but not a performance advantage. A good QML tutorial should report an unfavourable classical comparison honestly.

9. Run it yourself

The simulator route uses no IBM or Fire Opal quantum time:

/home/bram/.venvs/qiskit/bin/python \
  qiskit_qos_pbmc68k_q4_educational.py \
  --shots 512 \
  --json-out output/pbmc68k_q4_educational.json

Regenerate the tables, circuit drawing, and matrices with:

/home/bram/.venvs/qiskit/bin/python \
  qiskit_qos_pbmc68k_q4_explain.py \
  --shots 512 \
  --output-dir docs/beginner/assets

The complete source code and all fixed artifacts are available on GitHub. A downloadable DOCX guide is available there as well.

10. Relationship to Quantum Oracle Sketching

This PBMC68k beginner model is not a literal QOS implementation. It uses four classically prepared rotation angles, a fixed CNOT ring, and Z/ZZ readout. It is a conventional small quantum feature map.

The repository also contains a separate four-qubit hardware pilot that does port the official q_state_sketch_flat sampling kernel to Qiskit. That pilot implements only one QOS building block, not the complete QOS/QSVT classification chain.

Route Purpose Literal QOS kernel? Claim boundary
Four-qubit PBMC68k beginner model Learn the translation from UMI data to circuit and classifier No No advantage claim
Four-qubit flat-QOS hardware pilot Test the official sampling sketch on hardware Yes, one primitive No complete QOS classifier
60-qubit PBMC68k pilot Test a wide real-data hardware feature map No, QOS-inspired Only a bounded local timing claim

Sources

  • Kivioja et al., Counting absolute numbers of molecules using unique molecular identifiers, Nature Methods 9, 72-74 (2012).
  • Zheng et al., Massively parallel digital transcriptional profiling of single cells, Nature Communications 8, 14049 (2017).
  • IBM Quantum documentation for the RY gate.
  • IBM Quantum documentation for bit ordering.
  • Havlicek et al., Supervised learning with quantum-enhanced feature spaces, Nature 567, 209-212 (2019).
  • Zhao et al., Exponential quantum advantage in processing massive classical data, arXiv preprint (2026).
  • 10x Genomics PBMC68k count matrix.
English | Nederlands | Series hub | Next part | QOS paper | Official code | Hardware code

Recent Posts

  • Quantum computing-nieuws — 9 augustus 2026
  • Quantum computing-nieuws — 8 augustus 2026
  • Quantum computing-nieuws — 7 augustus 2026
  • Quantum computing-nieuws — 6 augustus 2026
  • Quantum computing-nieuws — 5 augustus 2026

Recent Comments

No comments to show.

Archives

  • August 2026
  • July 2026
  • May 2026
  • March 2026
  • February 2026
  • September 2024

Categories

  • 10
  • Quantum Computing
  • Uncategorized
©2026 Edukaizen | Theme by SuperbThemes