Final - Instructor Hints

Updated 27 Nov 2026

Final — Instructor Hints (CSS482)

Final exam guideline (P' Arm)


3 hours · 7 questions · open book, open calculator, open dictionary. In person he said it's easier than the midterm: mostly "why" questions and only 2 computations (Q1 expectation, Q6 Hamiltonian).

QTopicSlidesNotes
1State expectation (compute)Ch4 32–34Lecture 4 - Computation, Measurement, and Dynamic Circuits
2Phase kickbackCh5 3–12, 15–20Lecture 5 - Leveraging Superposition, Entanglement, and Error Correction
3Quantum noisy channelCh5 41, 45–46same
4Teleportation (bartender vs bandit)Ch5 23–26same
5Shor's algorithmCh6 28–33, 40–41, 44, 47–50, 53–56Lecture 6 - Searching and Cryptography
6Hamiltonian matrix (compute)Ch7 19–23Lecture 7 - System Dynamics, Simulation, and Polynomial Functions
7Quantum machine learningCh8 4–5, 7–9, 14–15, 21–24, 37–41Lecture 8 - Quantum Artificial Intelligence

Slide errors that matter in the exam

  • Ch4 slide 33 (Q1): the shortcuts drop a factor ½ for X and Y, and the Y sign is flipped. Correct: ⟨X⟩=∣a+b∣2−∣a−b∣22\langle X\rangle = \tfrac{|a+b|^2-|a-b|^2}{2}, ⟨Y⟩=∣a−ib∣2−∣a+ib∣22\langle Y\rangle = \tfrac{|a-ib|^2-|a+ib|^2}{2}, ⟨Z⟩=∣a∣2−∣b∣2\langle Z\rangle = |a|^2-|b|^2. Safest: compute ⟨ψ∣P∣ψ⟩\langle\psi|P|\psi\rangle directly.
  • Ch7 slide 22 (Q6): for A=[12+i3−i4]A=\begin{bmatrix}1&2+i\\3-i&4\end{bmatrix} the slide says cY=0c_Y=0; it is −2-2 → H=5I+5X−2Y−3ZH = 5I+5X-2Y-3Z (checked numerically). The slide formula ck=tr⁡(U′Pk)c_k=\operatorname{tr}(U'P_k) has no ½ — use the slide's convention in the exam, but you can mention it.
  • Ch5 slide 40: ∣+⟩⟨+∣=12[1111]|+\rangle\langle+| = \tfrac12\begin{bmatrix}1&1\\1&1\end{bmatrix}, not 12I\tfrac12 I.

Timestamps are (date, part, mm:ss) in the class recordings. The text has been cleaned up from Google's auto-captions.

Chapter 4

There is no Ch4 transcript (taught before the midterm). The hints below come from later lectures that reuse Ch4's expectation/projector/density-matrix ideas, and from the slide annotations.

Q1 — State Expectation (Ch4 slides 32–34)

  • Exam guideline: "manually compute state expectation on a projector matrix". He said in person it is one of only 2 computation questions (the other is Hamiltonian, Q6).
  • (Nov 17 02, 10:44–11:27) "B means basis… projection basis. B can be anything like X, Y or Z. That means projection axis… In most cases the projection basis is Z because you just want to measure the expectation of being zero or one."
  • (Nov 17 02, 11:06–11:13) Z axis picture: "Zero is up here, north pole. One is down here, south pole."
  • (Nov 17 02, 13:14–14:07) "The expectation means you've got the value of minus one and one, and this is zero in the middle… if it's positive it's ket 0, but if it's pointing down it means ket 1."
  • (Nov 17 02, 15:31–15:45) "The expectation will be either positive one or negative one or in between… expectation means average. Average of the measurement."
  • (Nov 17 02, 28:10–28:55) How to compute: "You multiply your quantum state to the projection axis… but it doesn't stop there. To achieve an expectation, you need to multiply with the bra of that state." → ⟨ψ|B|ψ⟩.
  • (Nov 17 02, 29:29–30:54) For a circuit U on |0⟩: substitute |ψ⟩ = U|0⟩, the bra becomes ⟨0|U* ("adjoint… you reverse the order on the left-hand side: U star and then bra zero"). "Although the math looks bizarre, believe me, the result is very simple."
  • (Nov 10 01, 48:10–49:22) "First of all we must have a projection matrix. It could be X, Y or Z. Projector matrix is for measuring the expectation… In most cases we choose the projector matrix to be Z."
  • (Oct 20 02, 0:07–1:36) Density-matrix route: "If you want to project the density matrix onto a quantum operator U — we say it's a projector U — just multiply density matrix with U and then compute the trace. You've got the expectation right away… I gave you a hint about the mathematical question. You know what to do now." → ⟨U⟩ = tr(ρU).
  • (Oct 20 02, 0:19–0:36) Meaning of each projector: X → positive/negative (real), Z → zero/one, Y → +i/−i. "U means just a quantum operator representing each axis of the Bloch sphere."
  • Slide 33 annotation: "Projection on each axis" (each Pauli expectation = shadow of the Bloch arrow on that axis).
  • Slide 34 annotation: red highlight "projection onto a single axis is irreversible"; green highlight "joint projection on multiple axes is reversible". Likely "why" material.
  • ⚠️ Slide 33 has formula typos (missing squares; the X/Y shortcuts drop the factor ½; Y has its sign flipped). The note gives the corrected forms. On the exam, compute ⟨ψ|U|ψ⟩ directly to be safe.

Density matrix / purity (Ch4 slides 42–43, reused in Ch5 Q3)

  • (Oct 20 01, 56:50–58:53) Purity: "compute the square of that matrix and then take the trace… you will end up with one, that means it's pure, no noise. If the purity is less than one, now you've got a noisy state."
  • (Oct 20 01, 57:06) "The trace means the sum of all diagonal elements."
  • (Oct 20 02, 1:43–2:05) He skipped purification: "I deliberately skip this part because it's more like a computational part. You need a computer to actually compute that." (not on the exam)
  • Slide 42 annotation: "(noisy state)" written under "Density Matrix".

Skipped / low priority in Ch4

  • Slides 18–24 (Uniform State Preparation, Shukla & Vedula 2024): stamped "SKIPPED" in red on the annotated slides.
  • Dynamic circuits (slides 45–58) and the PennyLane code are not in the final guideline.

Other annotations worth knowing ("why" ammunition)

  • Slide 7: "All classical programs can be run on quantum computers!" (Toffoli universality).
  • Slide 8: "Hermitian matrix" crossed out → "Hamiltonian matrix" (U = cis(H_U)); ties to Q6.
  • Slide 12: "In most cases, M ∈ {X, Y, Z}."
  • Slide 13: "RX, RY, RZ are used in quantum ML." (ties to Q7)
  • Slide 29: "binary output is used as a control" (mid-circuit measurement → conditional gates).
  • Slide 31: Z-bases = "computational base", X-bases = "superposition bases", Y-bases = "circular bases".

Admin / exam format

  • (Nov 17 02, 5:26–5:30) "I'm finalizing the final exam before Wednesday."
  • (Nov 17 02, 41:52–42:07) "Do we really have to remember that? No. The final exam is all about why questions. Why? Give me reasons why you choose this, why you choose that."

Funny lines / catchphrases (for video)

  • (Nov 17 02, 4:06–4:21) How to dodge a hard question at your presentation: "Just say due to the time limitation, we didn't do this… this is how you dodge away from difficult questions."
  • (Nov 17 02, 16:01–16:13) "Normally I don't use my iPad for teaching, but for theory of computation and quantum computing I need my iPad."
  • (Nov 17 02, 29:17) On expanding the expectation formula: "Oh my god. I know. Look at that." / "Believe me, the result is very simple. Like really, really simple."
  • (Oct 20 02, 1:43) "No, I spill the beans all the time."

Chapter 5

Note: Oct 20 part 3 is still Ch5 (Shor code, surface code); no Ch6 content in these files.

Exam format / general (admin)

  • "You don't have to be serious about the math proof. It's not going to show up in the final … The majority of the final exam will be why, why, why and apply, apply, apply. Some mathematical questions, but no proof." (Oct 6 p2 6:03–6:35)
  • "In the final paper I'm asking more reason questions: give me some application and give me reasons why you do this, why you do that. Some math question may show up, maybe one question. But no more state preparation." (Oct 20 p1 37:11–37:50)
  • "I'm drafting the final paper." (Oct 20 p1 37:05)
  • Midterm results: full marks got free coffee (200 baht credit); runner-ups 39/40, two got 38/40. (Oct 6 p1 9:14–15:27, 41:44)
  • Midterm last question: he intended Toffoli gates for AND; a runner-up "missed one qubit at the end" (−1 mark). (Oct 6 p1 33:29–34:13)

Q2 Phase kickback (BV slides 3–12, DJ slides 15–20)

  • Likely questions: "Why do we have to do the phase kickback? What does it mean by the phase is kicked back from the second part to the first part? Things like that … The main challenge is that you may have to design your U_f." (Oct 6 p3 3:40–4:18)
  • "In the exam it's going to look like this. No math proof. We do care about this input and output … we don't care about the middle of the way." (Oct 6 p2 39:30–39:56)
  • What to remember: "the input is always fixed to |+>^N ⊗ |->" and the output is "H of each qubit of the oracle ⊗ H|1>". (Oct 6 p2 27:28–27:52, 40:28–40:48)
  • The long derivation "takes about one page of A4 … you don't really have to remember that." (Oct 6 p2 26:04–27:06)
  • Phase kickback definition: "if you change the phase of one qubit, it's going to ripple to the other qubits" — linked to the midterm's interference question. (Oct 6 p2 1:51–3:46)
  • Why it works: cis θ is "a constant complex number, you can move it" from the last qubit to the front = "relocation of the global phase … this phenomenon is called phase kickback." (Oct 6 p2 11:22–12:54)
  • Why fix θ = π and ancilla = |->: cis π = −1; physicists "fixed y with ket minus" → the k-th qubit becomes |+> if s_k=0, |-> if s_k=1; Hadamard turns those into |0>/|1> = s_k. (Oct 6 p2 24:59–33:56)
  • "Two things for phase kickback: the input |+>^N|-> (fixed) and the operator in this form (flip the last qubit)." (Oct 6 p2 57:18–58:05)
  • U_f intuition: first N qubits = your guess (identity), last qubit = flag that flips if the guess is correct (XOR truth table walk-through). (Oct 6 p1 35:12–41:29)
  • Ancilla works as a "carry flag". (Oct 6 p1 50:58–51:14)
  • Oracle implementation: "just remember this scheme — Toffoli for each bit"; the secret is fixed inside the box, nobody sees it. (Oct 6 p1 42:58–44:52; p2 34:41–36:57)
  • Read-out: H then measure Z expectation per qubit (north pole 0, south pole 1). (Oct 6 p2 37:08–39:09)
  • BQP = Bounded-error Quantum Polynomial: QP = solvable by a quantum algorithm in polynomial time; B = output is a probability distribution (may be wrong with low probability). (Oct 6 p1 55:07–59:49; p2 0:10–0:21)
  • One-hot probe example s=110: f(100)=1, f(010)=1, f(001)=0 → 110. (Oct 6 p1 29:57–33:09)
  • Complexity: 3 decimal digits → 10^3; classical cracking is "intractable", quantum O(1) "one single execution". (Oct 6 p1 19:39–21:41)
  • DJ motivation: hash function must be balanced; classical check = try all contents = "intractable … exactly the same idea as cracking the ATM". (Oct 6 p2 45:26–48:38)
  • DJ balance score: (−1)^f gives ±1; sum/average → 0 = balanced, else imbalanced. (Oct 6 p2 52:17–56:52)
  • BV vs DJ difference: "Look at the output. The measurement is measured only on the quantum state |00…0>." (Oct 6 p3 0:36–1:28)
  • His DJ code measures the ancilla probability instead (saves simulator memory) — "In the exam, focus on this: focus on the theoretical part. Measure on the all-zero." (Oct 6 p3 2:45–5:57)
  • DJ as taught only works for a binary (0/1) hash function. (Oct 6 p3 1:43–2:03)
  • Ex 5.2 oracles: "This is an example of your U_f. Read the definition." Q8 (RX(θ) etc.) is taken from quantum machine learning — θ are model parameters. (Oct 6 p3 6:24–8:11)
  • He admitted omitting 1/√2^N on slide 8 "for the ease of math". (Oct 6 p2 19:39–20:10)

Q4 Quantum teleportation (slides 23–26) — bartender vs bandit

  • NOT faster than light: "This communication protocol is not faster than light. It's just as fast as light. But it's very secure." (Oct 6 p1 16:28–16:45)
  • "You need to send P and Q through a classical channel … Therefore it's not faster than light … It's just secure. It's not fast." (Oct 6 p3 49:28–50:17)
  • Not sci-fi / not mass transfer: "a fancy term for a secure communication protocol." (Oct 6 p3 8:22–9:14; Oct 20 p1 7:54–8:31)
  • No-cloning: to copy you must read → collapse → "the original one is collapsed already. It's died." Even non-destructive (weak) measurement is only guessing (~90%) → "no perfect clone". (Oct 6 p3 11:02–14:20)
  • Eavesdropping: on a carried qubit it collapses immediately and "you'll be alerted right away". (Oct 20 p1 9:01–9:31)
  • Setup = 3 things: qubit x, entangled pair Φ_A/Φ_B (Bell state made by H + CNOT), classical channel. Φ_A/Φ_B are the "secure keys". (Oct 6 p3 18:45–20:44, 25:40–26:04)
  • Sender: CNOT (x control, Φ_A target), H on x, measure p (from x) and q (from Φ_A); "because you measure Φ_A … Φ_B also collapses at the same time." (Oct 6 p3 21:26–23:26)
  • Exact mapping (he corrected himself): "It should be QP… Oh, PQ. Sorry, I forgot my own notation is PQ." (Oct 6 p3 40:02–40:18) and "P means the first qubit. Q means the second qubit." (Oct 20 p1 19:38–19:44)
  • Rule: "If the second qubit is one, I should do X. And the first qubit if is one, I should do Z … do X first … Z afterwards." (Oct 6 p3 39:05–39:34)
  • Grouping: 00 → don't touch; 01 → bit flip; 10 → sign flip; 11 → flip the bit and flip the sign. (Oct 20 p1 18:16–19:15)
  • Receiver order: "You start from Q … Q is produced by applying the CNOT, so you apply the CNOT first … then flip the sign with P." (Oct 20 p1 14:48–15:14)
  • Eavesdropper on p, q "still cannot decode the message because he does not have Φ_B. That's the key." (Oct 6 p3 50:58–51:25)
  • Pairs are consumed: create many pairs and "use them one by one … sequentially." (Oct 6 p3 51:43–52:12)
  • Bob's qubit collapses but "you can't just read the message just yet. Bob must wait for P and Q to be delivered." (Oct 6 p3 54:17–54:45)
  • Common mistake: forgetting to distribute the tensor product when expanding |x>⊗|Φ+> ("that's why you got the wrong CNOT"). (Oct 6 p3 27:44–28:26)
  • Slide coefficient 1/√2 (and 1/2) deliberately omitted on slides 24–25. (Oct 20 p1 16:21–16:32)
  • "Honestly, I didn't know how he came up with this idea. Maybe trial and error." (Oct 20 p1 19:53–20:10)
  • Teleportation takes "about 15 minutes to understand". (Oct 6 p2 44:22)
  • SKIPPED: quantum gate teleportation (slides 29–32) — "It's skip from the exam." (Oct 6 p3 55:35–56:25; Oct 20 p1 23:46–24:15)
  • Big hint (superdense + teleportation): "I would ask you further question like how could you actually apply superdense coding and quantum teleportation in one go … It will show up for sure. I'm drafting the final paper." (Oct 20 p1 36:31–37:05)

Superdense coding (slides 34–39)

  • "This is WinZip … 2:1 ratio." (Oct 6 p3 56:42–57:06)
  • b1 → sign flipping (CZ), b2 → bit flipping (CNOT); controls are classical (double lines). (Oct 20 p1 28:02–29:32)
  • Receiver: CNOT (A→B) then H → b1 b2; "Dense means double the compression rate." (Oct 20 p1 30:06–36:16)
  • "Do you think I'm going to ask you a question in this? No, that's not me." → expects application/combination questions instead. (Oct 20 p1 36:31–36:50)

Q3 Quantum noisy channel (slides 41, 45–46)

  • Density matrix = representation of a noisy state; compute as ket × bra and add; noise = "energy leakage" → off-diagonals non-zero. (Oct 20 p1 39:37–48:00)
  • Bit-flip: "1−q probability of retaining the good old density matrix and q probability of flipping"; seen on IBM systems. (Oct 20 p1 48:43–50:44)
  • All noise is "unexpected interaction with the environment which affects the rotation of a particle". (Oct 20 p1 52:08–52:20)
  • Pauli channel: q_x bit, q_z sign, q_y "phase". (Oct 20 p1 52:34–53:04)
  • "All of these four types can be managed … But the last ones on the right-hand side are worst-case scenario … depolarization … make a prayer to your god." (Oct 20 p1 53:14–54:28)
  • Amplitude damping "dampen means lower": |0> preserved, |1> becomes a superposition with prob q; he said common in trapped-ion computers (slide says superconducting & optical — quote the slide). (Oct 20 p1 54:55–55:56)
  • Phase damping acts on the off-diagonal elements, "also very common"; "seven types of noise … show up in all modern quantum computers … very, very small but it shows up." (Oct 20 p1 55:56–56:26)
  • Purity = tr(ρ²); 1 = pure, <1 = noisy "still usable". (Oct 20 p1 56:34–59:39)
  • Expectation of a density matrix = tr(ρU): "I gave you a hint about the mathematical question. You know what to do now." (→ Q1 skill) (Oct 20 p2 1:04–1:36)
  • SKIPPED: partial trace & purification ("you need a computer") — slides marked (Skip). (Oct 20 p2 1:43–2:14)
  • Fidelity = similarity (not just "quality"). Pure case: bra-ket, absolute value, square. "If I want to ask you this question, it's going to be like this. Easy, right?" (Oct 20 p2 2:20–5:46)
  • Noisy case (diagonalize, √ρ, M, …): "We are not going to do the case two … I'm not going to do this to you." (Oct 20 p2 6:52–8:48)
  • WHY fidelity: "how we measure the quality of a quantum computer" — store |+> in register R, read it out, compare want vs get; ~99.5% today, but reliable computing needs ~10^-10 error. (Oct 20 p2 8:59–12:12)

Error correction (slides 50–63)

  • Logical vs physical qubits; RSA needs ≥1,400 logical ≈ 280,000 physical ≈ 200 physical per logical (2026); "in the future we may need just 10". (Oct 20 p2 15:31–20:25)
  • Why 200 per logical: codes only fix bit/sign flip; "five more types of noise", decoherence "ruins everything". Vendors' "1,000 qubits" = logical; millions physical behind the scene. (Oct 20 p3 22:01–24:25)
  • Hamming recap: parity = even number; mnemonic b1b2b4→p1, b1b3b4→p2, b2b3b4→p3. (Oct 20 p2 22:04–27:52)
  • "This is binary matrix multiplication" (1+1=0, XOR). (Oct 20 p2 34:26–35:08)
  • Syndrome locating: intersect the 1-circles, exclude the 0-circles ("1 = inclusion, 0 = exclusion"). (Oct 20 p2 35:32–36:32)
  • Limitation: Hamming detects only one erroneous bit; two errors → fails. (Oct 20 p2 40:12–41:33)
  • Noise modelled as CNOT/CZ with an uncertain control (√(1−p)|0>+√p|1>) — "not a real qubit … uncontrollable variable … in the channel". (Oct 20 p2 42:56–45:14)
  • Repetition code = majority vote; "I was about to ask this question in the final, but then you spilled the bean … I'm going to add some more details into the questions." (Oct 20 p2 55:21–57:37)
  • "Do you think I'm going to ask you to write down this diagram? Nah. You know me." (Oct 20 p2 54:26–54:33)
  • Student caught a b1/b2 mix-up in his handwritten version → trust the printed table / "just draw the picture". (Oct 20 p2 52:16–53:12)
  • Sign-flip slides have mistakes (Fig 20 caption says bit-flipping): "The slides were finished … one year before the book." (Oct 20 p3 0:29–1:12)
  • Only one erroneous qubit at a time; after decoding we read only the first qubit. (Oct 20 p3 1:14–4:06)
  • Shor code: 3×3 = 9 qubits; inner grouping = bit flip, outer = sign flip; ratio 1:9 "really bad". (Oct 20 p3 4:16–6:23, 8:40–9:14)
  • Surface code (2002) = real hardware implementation; data qubits in QPU, measurement flags in classical system; needs a classical computer to compare timesteps. (Oct 20 p3 9:14–14:34, 18:29–18:39)
  • Possible exam task (not in the official guideline list): "I'll give you two time steps. Highlight the errors and flip it … you may spend like five minutes on this question." Draw the box from the corners; boxes may overlap. (Oct 20 p3 19:45–21:01)
  • CAUTION: in class he said "X flag misaligned → flip the bit"; the slide (60) says bit-flip → Z-measure mismatch, sign-flip → X-measure mismatch. Use the slide. (Oct 20 p3 17:06–18:08)

Funny lines / catchphrases (for video)

  • "Every time you learn quantum computing, it's a love–hate relationship. Conceptually it's a lovely idea, but mathematically it's disgusting." (Oct 6 p1 18:29–18:46)
  • BV = "ATM cracking algorithm"; in the UK an ATM is "a hole in the wall". (Oct 6 p1 17:12–18:19)
  • "Ancilla" = Latin for maid/slave woman: "it just exists there, no importance, but you need it." (Oct 6 p1 45:44–47:18)
  • Phase kickback: "Kickback is from a horse." (Oct 6 p2 3:30)
  • "Calm down. Okay, don't calm down. Okay, just calm down." (Oct 6 p2 5:53)
  • "Easy peasy lemon squeezy." (Oct 6 p2 16:07)
  • "It takes me half an hour to tell a story for three slides." (Oct 6 p2 0:27)
  • "Nobody thought of that. It's so obvious in plain sight." (Oct 6 p2 34:27)
  • Crypto professor joke: "That explains why his exam paper looks like that." (Oct 6 p1 49:39)
  • "Everyone has an X … Do not send a message to your ex." (Oct 6 p3 20:55–21:13, 50:37) / "When you recover your ex from your memory, it hurts." (Oct 20 p1 22:22–22:35)
  • "Someone wrote on the exam paper 'I dropped dead'. But then he got 30." (Oct 6 p3 11:56)
  • Crypt = encrypted message = graveyard: "you dig the original body from the crypt." (Oct 6 p3 48:18–48:42)
  • NASA cartoon: "Nerdy joke — where can I laugh? No laugh." (Oct 6 p3 54:52–55:07)
  • Sender/receiver "dirty mind" apology, three times. (Oct 20 p1 18:36–18:58, 27:01–27:20)
  • Electrocuted by his own iPad mid-lecture. (Oct 20 p1 41:36–42:22)
  • Depolarization: "Make a prayer to your god. Whatever god you have." (Oct 20 p1 54:18–54:28)
  • "There's a foot stuck in my throat." (Oct 20 p2 16:46–17:14)
  • Students at home: "You can make good grades although you stay home, but I can make fun of you when you're in the room." (Oct 20 p2 35:08–35:26)
  • Shor code circuit looks like him in high school: "a bad boy … one side tucked in, one side left out … juvenile delinquent … it's just me flipping." (Oct 20 p3 6:49–8:09)
  • "We are playing Minesweeper on the quantum computers." (Oct 20 p3 14:59–15:08)
  • "Sounds too real, too good." (Oct 20 p3 16:57)

Chapter 6

Sources: c_Oct_27_01/02/03 (Grover, QFT, QPE), c_Nov_3_01/02/03 (QPE recap, crypto, RSA, Shor, Simon). Oct 20 is still Ch5 (surface code), so Ch6 starts on Oct 27. Also checked: c_Nov_10_02_new (QPE + Trotter link) and c_Nov_17_02 (exam style).

Admin / exam format

  • The final is all "why" questions: "Why? Give me reasons." (Nov 17, 41:58)
  • Grover in the final: "I would need some justification. No math derivation... for the peace of your mind, no math derivation at all. But I'm going to ask, e.g., how could we come up with the number of iterations?" (Oct 27, 37:28–37:55)
  • "The final will not be involved with math. I'm not asking you to do the math anymore. I'm asking you reasons and design." (Nov 3, 26:21)
  • "We are quantum engineers, not quantum physicists. But we still need to know some math." (Nov 3, 26:59)
  • Open book: you don't need to memorise the QFT matrix. "Do you think I'm going to remember it? No." (Oct 27, 18:49)
  • The annotated slide PDF was uploaded to Google Classroom, so re-download it. (Oct 27, 14:09)
  • Post-quantum cryptography is NOT in this course. It is in his book. (Oct 27, 9:08)
  • He said he would spend the most time on QPE "because it's the thing we use to crack RSA: Shor's algorithm." (Oct 27, 8:35)

Q5 — Shor's algorithm (slides 28–33, 40–41, 44, 47–50, 53–56)

QPE (slides 28–33)

  • QPE = "how could we estimate the rotation period of one quantum program". You don't know what is inside the gate, you only see that it rotates the input. (Oct 27, 52:23)
  • Global vs relative phase: factor out cis θ1. θ2−θ1 is the relative phase (fixed by the gate, "we can't touch it"). θ1 is the global phase, which QPE extracts. (Oct 27, 53:24–55:26)
  • If |ψ⟩ is an eigenvector of U, then applying U leaves the vector pointing the same way and only the global phase changes. That is why we need the eigenvector. (Nov 3, 17:08–18:23)
  • Electric-fan analogy: rotate U many times and you start to see the blades. That pattern is the hidden global phase. (Oct 27, 56:32–58:48; Nov 3, 19:40)
  • Airplane-propeller / camera-shutter analogy: when the shutter speed matches the propeller speed, the propeller looks still, so you have found the right frequency. (Oct 27-03, 4:46)
  • Why the |+⟩ controls: each control qubit means "rotate or not rotate" U^(2^k). Every rotation count is a sum of powers of 2, so N control qubits try all 2^N frequencies at once. (Oct 27-03, 1:14–4:24; Nov 3, 21:10–24:35)
  • "Granularity degree" N = how much detail you want. More control qubits means more frequencies tried. (Oct 27-03, 5:48; Nov 3, 24:50)
  • Phase kickback inside QPE: cis(...) is a constant, so "kick the phase to the other side" (from the target onto the control qubits). (Oct 27-03, 8:13–8:42)
  • InvQFT then "extracts a time domain from the frequency domain". Pick the bar with the highest probability, k*. Then θ = k*/2^N. (Oct 27-03, 6:13; 10:39–11:27; Nov 3, 25:31–27:35)
  • Worked example he drew: 8 bars (N=3), the tallest is index k*=2, so θ = 2/8. (Oct 27-03, 12:05–13:48)
  • Annotation slide 29: "hint: almost equivalent to extracting a time domain from a frequency domain → InvQFT".
  • Weakness: QPE is "not that efficient". U^(2^9) = U^512 repetitions. If U is a long algorithm (loops), this takes ages. Whether RSA really falls "depends on this U". (Oct 27-03, 21:56–24:47; Nov 3, 28:22–29:28)
  • Fix = Hamiltonian / energy form: U = exp(−iH), so U^n = exp(−inH). Multiply n inside instead of multiplying matrices. This links to Ch7 (Oct 27-03, 24:53; Nov 3, 29:41–32:15). "When QPE becomes practical you can crack the RSA cryptosystem" (Nov 10-02, 52:53).

Number theory (slides 40–41, 44, 47)

  • Classical factorization = guessing a prime a in (1, √n) and testing it with gcd. "It's called guessing." Why √n: a factor larger than √n would be paired with one smaller than √n, so you only need to search up to √n. (Nov 3-02, 2:49–5:07)
  • He said classical factorization is about O(n²) and "impossible" for large n. "But in quantum computing, no more." (Nov 3-02, 5:20–5:53)
  • GCD and LCM "are very important in prime factorization. This is how we crack RSA." (Nov 3-02, 11:54)
  • Coprime = GCD 1 = "they have nothing in common, just like you and your crush". 8 = 2·2·2 and 9 = 3·3. (Nov 3-02, 13:07–13:48)
  • Bézout / extended Euclid: "you don't need to memorize it... I'm showing you the origin of RSA." (Nov 3-02, 15:19; 15:47)
  • "Totient" comes from the Latin totiens ("so many times"), so a totient function counts something. φ(n) counts the coprimes from 1 to n. He walked through φ(15) = 8. (Nov 3-02, 17:24–20:34)
  • Carmichael λ: "you don't have to remember that." (Nov 3-02, 24:28)
  • KEY MESSAGE: "If you can guess that number [the totient/order], you can crack n right away." a^r − 1 ≡ 0 (mod n) factors as (a^(r/2)+1)(a^(r/2)−1), so these share factors with n. (Nov 3-02, 28:03–30:25)
  • "The order that Pom (cyber lecturer) talks about = the global phase of rotation." (Nov 3-02, 30:37; Oct 27-03, 19:07: "the totient function is the order of modulo")
  • "Mark my word: every time you see modulo, it means rotation, and in every rotation there must be a frequency." So QPE can extract it. (Nov 3, 38:04–38:54)

RSA (slides 48–50)

  • Symmetric vs asymmetric: "which is harder to crack? They're equally very hard." The Caesar cipher is easy to crack, but that does not make all symmetric ciphers easy. (Nov 3, 36:39–37:06)
  • φ(pq) = (p−1)(q−1) is just Euler's formula with exponent 1 on each prime. He derived it on the board. (Nov 3-02, 32:01–33:08)
  • The modulus n must be large. With a small n, you just for-loop and crack it. (Nov 3-02, 34:30–34:58)
  • Key generation: "You don't really have to remember that. What you really have to remember is to guess r by quantum algorithms." (Nov 3-02, 37:27–37:40)
  • Proof of correctness (slide 51): "you don't have to focus on that." (Nov 3-02, 41:32)
  • Where k comes from in λk + ed = 1: the extended Euclid method on slide 42. (Nov 3-02, 43:19)

Shor (slides 53–56)

  • Shor = classical factorization plus ONE extra step: when the guess is wrong, don't just loop. Turn modulo into a quantum operator and use QPE to guess the order r. (Nov 3-02, 48:09–49:21)
  • Failure branches: if r is odd, go back and guess again. If gcd(n, a^(r/2)+1) = 1, it is still a wrong guess, so go back. Otherwise you have found a factor; recurse on g and n/g. (Nov 3-02, 50:56–51:58)
  • "This is a guessing game... we speed up the guessing process by QPE. That's it." (Nov 3-02, 52:41; Nov 3-03, 3:53–4:04)
  • Modulo operator example: U_{%7}|10⟩ = |3⟩. (Nov 3-02, 53:52–54:29)
  • θ = k*/2^L must be approximated as a fraction m/r with m, r coprime, using the continued fraction method (Python Fraction). (Nov 3-02, 55:11–56:15)
  • Continued fraction walk-through for 1.23456: floor, take the reciprocal of the fractional part, repeat "until you're satisfied". More "tail" gives more precision. (Nov 3-02, 57:09–59:58)
  • "We can guarantee that each pair [numerator/denominator] is coprime." (Nov 3-03, 0:06)
  • "You don't care about the numerators, you care about the denominators. Compute the LCM of the denominators and you've got r." (Nov 3-03, 1:15–2:15)
  • His own PennyLane code (slides 57–60): "it's a long code, we don't really have to focus on that." (Nov 3-03, 2:27)
  • Complexity: classical is about O(N²) in n; Shor is O(L² log L), where L = number of bits/qubits. "That is a different scale." (Nov 3-03, 4:50–5:16)
  • Hardware: RSA-256 needs about 1,400 LOGICAL qubits. 1 logical ≈ 1,000 physical, so about 1 million physical qubits. Today there are about 400 qubits in one system. "The future is near." (Nov 3-03, 5:28–8:47; compare Oct 20-03, 23:32: "280,000 physical qubits for solving RSA")

Grover (not in the exam list, but he named a possible "why" question)

  • Information retrieval = the oracle function f(x)=1 if the key matches the query. Classical search is O(n), which "takes ages" for billions of documents. (Oct 27, 10:49–12:27)
  • The oracle is a black box: "you never know the solution inside, but you know its behaviour: it flips the sign." (Oct 27, 21:49–22:28)
  • The mean vector is perpendicular to the distribution. Flipping the solution's sign shifts the mean towards it. Then readjust around the new mean and repeat. (Oct 27, 16:50–19:35)
  • "Slingshot": two Householder reflections (pull, then release). Each iteration rotates the mean vector by θ. (Oct 27, 24:24–29:03)
  • Why the floor in k*: going beyond the solution is overshooting, so stay within the limit. (Oct 27, 31:42–32:48)
  • Why π/4·√n: for millions of documents √(1/n) is tiny, so sin θ ≈ θ. "All physicists got stuck at this point" until they used this. (Oct 27, 33:45–37:15)
  • Grover's search is O(√n). With multiple solutions, k* ≈ π/4·√(n/m). (Oct 27, 38:22; 46:22)
  • D is hard to implement, so the physicists replaced it with the Grover operator. Mnemonic: "Hadamard and Z, Hadamard and Z, and then Toffoli in the middle." (Oct 27, 40:36–41:27; 47:12)
  • Lov Grover: "although his name sounds European, he's actually Indian." (Oct 27, 42:33)

QFT (not in the exam list; QPE depends on it)

  • Fourier: every signal is a mix of component waves. The frequency domain is a bar chart of energies (squared amplitudes). (Nov 3, 9:22–10:35)
  • Manual FT = increase the sampling frequency and average the squared bars. AI students know it as "mean square error". He reused the slide from Machine Learning. (Oct 27, 55:38–57:05)
  • Speech-recognition spectrogram: "I deliberately put that in the final exam of machine learning." (Oct 27-02, 1:59)
  • Manual FT is O(n²), from the sum 1+2+…+n. FFT (he said 1969; in fact Cooley–Tukey 1965) is O(n log n) by recursion. (Oct 27-02, 3:13–5:14; 6:40–11:05)
  • r_N = cis(2π/N) = the N-th root of unity, "the N-th slice of a pie". Multiplying by it = rotating. (Oct 27-02, 11:51–12:58)
  • Input = a superposition of the data points. n elements need only log₂ n qubits; 1,000 elements need 10 qubits. (Oct 27-02, 24:09–26:27)
  • The gate count is O(N²) in qubits = O((log n)²) in items, "much much smaller than n log n. That's why I love QFT." (Oct 27-02, 27:01–28:11; 33:18)
  • "Do we have to implement it ourselves? No. Don't do that, I did it myself and it took ages." Use qml.QFT. (Oct 27-02, 28:19–29:02)
  • InvQFT = rotate backwards (clockwise). "To crack RSA we need the inverse QFT." (Oct 27-02, 30:16–33:41)
  • The Caesar cipher is circular (Z wraps back to A), just like the root of unity, "so we can crack it by rotation". (Oct 27-02, 35:24–36:02)

Simon (not in the official list, but he hinted at a design question)

  • Simon's algorithm checks whether a hash function covers the whole output space. Classically you must loop over all inputs. Quantumly, Hadamard all inputs at once and measure the output distribution. "Same idea as Deutsch." (Nov 3-03, 9:13–12:58)
  • Uniform distribution = a good (balanced) hash. Biased = hash collisions; "the taller the bias, the more collisions." (Nov 3-03, 24:51–25:22; 33:35)
  • Possible question: "I have my mysterious hash function... which distribution is good, which is bad?" (Nov 3-03, 26:36)
  • "Please design a quantum algorithm for this logical expression [AND/OR/NOT/XOR with Toffoli]... that will show up again. I spilled the beans." (Nov 3-03, 29:55–30:27). This may be superseded by the later official guideline, which has QML as Q7.
  • Skipped: the math proof of the Simon probability distribution (slide 64). "Beyond our scope." (Nov 3-03, 30:52)

Funny lines / catchphrases

  • "Mathematically it's [bleep] difficult" (Grover, Oct 27, 18:24). "Slingshot sounds serious. Country boy." (Oct 27, 24:29)
  • "This is my D. Show me your D." (diagonalization joke, Oct 27, 40:18)
  • "Don't feel stupid, because we are all stupid. I am stupid as well." (Oct 27-02, 57:46)
  • "Nobody does 67 anymore... nobody dares do the 67 in front of me again." (Oct 27-03, 12:28)
  • "Today's lecture is going to be the most cryptic of all, because it's all about cryptography." (Nov 3, 8:04)
  • "Make the blockchain unsafe. Wow." (Nov 3, 15:11)
  • Coprime = "nothing in common, just like you and your crush." (Nov 3-02, 13:19)
  • French mathematicians "were quarantined at home during the revolution, so they invented a lot of formulas." (Nov 3-02, 23:13)
  • "ED is also an acronym for erectile dysfunction... the evaluation has passed, so I can say that now." (Nov 3-02, 42:14)
  • "It almost ripped off my shirt. It's not sexy time." (mic cable, Nov 3-03, 21:52)
  • "Oh my [bleep] god. I know. I know." (signature sign-off, Nov 3-03, 34:24)

Chapter 7

Sources: Nov 3 (pt 1, pt 3: Hamiltonian spoilers), Oct 27 pt 3, Nov 10 pt 1 (c_Nov_10_01.txt timestamps), Nov 10 pt 2 (c_Nov_10_02_new.txt timestamps; the plain file is ~2 min earlier). Duplicate "_new" captions deduped.

Q6 Hamiltonian Matrix (slides 19–23): exam hints

  • Confirmed exam question: "Why do I mention that? Because I'm going to make you do it in the exam. You'll be given a matrix like this and then convert it into its Hamiltonian. You've got to do it. I'm telling you what's going to show up in the final." (Nov 10, 23:12)
  • Single qubit only: "It's exponential, 4^n… My heart isn't made of wood. I'm not doing that to you. You would have one qubit. Not 20." (Nov 10, 42:35)
  • "Once you have extracted the Hamiltonian, that's all for the final." Everything after slide 23/24 (BCH proof, qubitization) is beyond that. (Nov 10, 44:17)
  • Early spoilers: "We can convert any quantum operator into its Hamiltonian. It's not that difficult, believe me… We can do that by hand as well, which means I'm going to make you do it." (Nov 3, 30:09–30:30)
  • "Believe it or not, we can compute it by hand and it's quite easy too." (Nov 10, 12:35)
  • Annotated slides are on Google Classroom: "I have annotated everything for you." (Nov 10, 12:46)
  • Recipe exactly as he taught it (Nov 10, 22:46–34:00):
    1. Check Hermitian: "the diagonal line is real, across the diagonal is conjugate" (22:46–23:12). For slide example A: diagonal 1, 4 real; 2+i vs 3−i not conjugate, so not Hermitian (24:04)
    2. If not Hermitian: "just add U and U-star (adjoint) and then average. We can guarantee the output will be Hermitian." (24:29)
    3. Single qubit: multiply U′ by each Pauli axis I, X, Y, Z, take the trace (sum of diagonal) → c_I, c_X, c_Y, c_Z (25:19–27:00)
    4. Ĥ = c_I·I + c_X·X + c_Y·Y + c_Z·Z. "That's it. This is your Hamiltonian. Super easy." (27:15–27:33)
  • His trick: don't do the full matrix multiplication. Only the diagonal matters: dot row 1 of U′ with column 1 of P, plus row 2 with column 2 (colour highlights on slide 22). (29:40–31:14)
  • Size tells the qubit count: 2×2 = 1 qubit, 4×4 = 2, 8×8 = 3 (2^n × 2^n). (28:58)
  • "Each element [of Ĥ] may be larger than one, and it's okay, because it's the argument of cis. These are phases." (43:43)
  • Hermitian = exact, non-Hermitian = approximation: "If you want an actual Hamiltonian, U must be Hermitian. If U is not Hermitian, you would have only an approximation of the Hamiltonian, not the real one. This is the main limitation." (32:39; also 17:08–17:56) (A likely "why" question.)
  • "If you take a look at the source code of PennyLane, you're going to see the same method." (32:02)
  • Slide typos he pointed out: "Hermition" and "appproximate" on slide 21. (33:12)
  • Slide error to warn about (found while checking with numpy, not mentioned in class): slide 22 computes c_Y = 0. The correct value is −2, because (5/2−i)(−i) = −1 − 5i/2. So Ĥ = 5I + 5X − 2Y − 3Z = [[2, 5+2i],[5−2i, 8]], not [[2,5],[5,8]]. Also, the slide formula has no 1/2^n factor, so it gives 2·U′. PennyLane's pauli_decompose gives U′.
  • Multi-qubit (taught, but not examined): Pauli axes are tensor products, 4^n of them (16 for 2 qubits, 64 for 3). He re-taught the tensor product [[a,b],[c,d]]⊗B = [[aB, bB],[cB, dB]]. (34:58–41:33)

Why the Hamiltonian exists (likely "why" material)

  • Motivation: QPE needs U, U², U⁴, …, U^(2^n). "U to 256, what's going to happen? If U is a very complex quantum algorithm, it takes ages to finish." (Nov 3, 28:34–29:12; also Oct 27, 23:52–24:16)
  • "We can transform any quantum algorithm into its energy form. H is called the Hamiltonian of U." Then U^N = cis(−N·H): "Instead of multiplication, you multiply N directly into the Hamiltonian." (Nov 3, 29:41–31:35)
  • "What if you want to apply this quantum operator 10,000 times? In the simulator you'd do matrix multiplication 10,000 times… Can we convert it to some form, multiply by 10,000 and convert it back? Yes. This step is called the Hamiltonian matrix." (Nov 10, 9:37–12:23)
  • "Hamiltonian is one of the key ingredients for quantum algorithms… especially for speeding up the process." (Oct 27, 25:34)
  • Non-commutativity warning: "You're so tempted to add them, but can we? Matrix multiplication is non-commutative… If H1 to HN are not the same, you can't just add them." (Nov 10, 18:25–19:38) "Matrix multiplication is non-commutative but addition is commutative. That's the main difference." (46:12–46:24)
  • Can convert only some operators exactly; the condition is that U must be Hermitian, otherwise approximation. (17:08–17:56)

Trotterization (slides 28–30, explained, not computed)

  • "Trotter–Suzuki decomposition. That's a big word. In the textbook we usually call it trotterization. Not terrorization." (Nov 10, 15:12–15:41)
  • Jumped straight to slide 29: "This is the point of the Hamiltonian. If you've got U^N with N very large, multiply N into the Hamiltonian, divide by small n, take the power n." (20:48–22:19)
  • Small n = degree of granularity (same idea as in QPE). "Supposed to be small, like 2 or 4, because inside cis is a matrix and you have to multiply it n times." Trade-off: too large → takes ages; too small → inaccurate. (21:43, 51:01–53:48)
  • Error O(1/n): "the error is in big O of the reciprocal of n." (49:05)
  • Trotterization is what makes QPE "almost practical… and when QPE becomes practical you can crack the RSA crypto system." (52:40–53:20)
  • BCH expansion (slide 26): "Let's forget this math… that's a deep math. We're not looking at that." (44:28)
  • Qubitization: "an extension of trotterization… better accuracy, but a little more complicated. I'm not going to include it in the final. If you're interested, read the book (PDF on Google Classroom)." (54:47–55:34)
  • Polynomial functions / QSP / QSVT / HHL: flipped through with "passed… passed". Not covered. (55:53) He said at the start: "We will study only the first two topics. That's more than enough. The rest is for non-linear simulation. We don't care about it." (Nov 10, 12:10)

QFA / Szegedy (slides 3–18): why-questions only, no computation

  • No computation: "Are you going to make me compute that by hand? No. I'm asking why questions instead, like: why do we need a reflection? What does it mean by state transition by reflection? You just have to understand the concept." (Nov 10 pt 2, 5:48–6:29)
  • "Let me give you a hint for the final exam. I'm not going to make you compute U_a… I'm asking questions like why do we do this, why do we do that, what is this. No actual computation at this point." (Nov 10 pt 2, 8:26–8:42)
  • (Earlier at Nov 10 pt 1, 58:55, he said "in the final exam you would have to do that… oh, I spilled a bean". The two later statements override this: concept only.)
  • Determinism = "you've got all cases of the if-clause covered… you consume one symbol, you know exactly where to go, no hesitation." δ is a function, so exactly one output. (Nov 10, 16:54–17:55, 21:23)
  • Function vs relation: a function is one-to-one or many-to-one; a relation also allows one-to-many and many-to-many. (22:02)
  • Time evolution = derivation one symbol at a time; "why do we say time evolution? Because now we are running a simulation." (25:46–26:19)
  • Deterministic → one input string gives exactly one path. Nature (e.g. weather cycles) isn't deterministic, so we extend to PFA. The only change is that the transition function becomes a conditional probability. (27:06–29:20)
  • Read P(B|A) as "P of B if A". A = premise, B = consequence. P(B|A) = P(A,B)/P(A). (30:32–32:25)
  • PFA → quantum: each input symbol gets its own quantum operator U_a. "Then you can run the simulation on quantum computers and simulate all possible paths in one go." (42:00–43:00)
  • P(next|curr,a) = |U_a|curr⟩|² is an amplitude; "if you measure that amplitude you get the probability." (43:23–44:18)
  • Initial state = start state ⊗ |+⟩: "just average all possible next states." (46:43–47:56)
  • Acceptance uses a projector (X, Y or Z). "In most cases we choose Z." (48:10–49:22)
  • Szegedy: needs √ of the conditional probability ("you need the square root"). R_a is a mirror: "use R_a, the current input symbol, as a mirror and compute the reflection. This is the next state. More input symbols → do the mirror over and over again." Reflection = Householder matrix from Chapter 3. Then swap bra and ket. (55:15–58:35)
  • "The idea is very easy, but the math is difficult. I understand." (57:43)
  • Worked example tip: "For each column they sum to one." "You're at q1, so the first half of the ket is fixed to 0… take the probability and square-root it, put it right there." Keep Π_a in bra-ket form: "You don't have to expand the term." (Nov 10 pt 2, 0:49–5:16)
  • QFA circuit: after each U_a, copy with CNOT and measure each step → most probable state sequence = quantum Viterbi algorithm; classical HMM Viterbi O(N²) vs quantum O(N). (Nov 10 pt 2, 6:48–8:15)
  • Moore machine = FSA where each state performs an action on the environment (vending machine example). (Nov 10, 14:39–15:28)

Admin / exam format

  • Final: "the final will not be involved with math… I'm asking you reasons and design. We are quantum engineers, not quantum physicists. But still we need to know some math." (Nov 3 pt 3, 26:14–27:12) Q6 Hamiltonian is the exception (computation).
  • Next week (Nov 17) = VQA, "the final week… configurable sausage machine." (Nov 10 pt 2, 56:49)

Funny lines / catchphrases (for the video)

  • "Episode two of theory of computation." / "You're going to love it or you're going to hate it." (Nov 10, 10:27–10:50)
  • "Does Professor Hung's face flash up in your memory?" (TOC nostalgia) (20:45)
  • "I'm going slow, because I understand TOC is a nightmare. So I've got to reteach it." (41:13–41:24)
  • "Easy peasy lemon squeezy." (25:00, 39:30) · "Oh yeah… lovely." (everywhere) · "It's not that difficult, believe me. Believe me." (Nov 3, 30:16–30:22)
  • On Szegedy: "It's Hungarian. I thought it was Polish until I Googled it… I tried Polish for two months and gave up." (Nov 10, 51:01–51:35)
  • "Here we call it c_k. Not C.K. Chung." (Nov 10 pt 2, 26:39)
  • "Not terrorization. Trotterization." (15:34)
  • "Reciprocal… the verb is reciprocate. You take good care of your girlfriend, but she never reciprocates. That hurts, right? I learned this word the hard way, based on my true experience." (49:14–50:08)
  • "My heart isn't made of wood. You would have one qubit." / "4 to 20, you don't have enough time, even for your lifetime." (42:35–43:06)
  • "Oh, I spilled a bean." (Nov 10, 59:03; also Nov 3 pt 3, 30:09 about the hash-function design question)
  • "Let me show you the real deal… the real deal is really easy." (Nov 10 pt 2, 28:00)

Chapter 8

Sources: Nov 17 is the last class (files c_Nov_17_01/02/03 are labelled 17-1, 17-2, 17-3 below), plus the end of Nov 10 part 2. Ch8 did NOT start on Nov 10; that class only previewed it.

Admin / exam format

  • (Nov 17-1 12:46) "This is going to be the final class." The final covers VQA and quantum neural networks, "it's going to cover all that."
  • (Nov 17-1 13:05) ⚠️ "You can cancel out the support vector machine right here. I'm not going to take it to the final exam." Section 3 (Quantum Kernel Methods / QSVM, slides 29–36) is out. This matches the guideline, which skips slides 29–36.
  • (Nov 17-1 13:22) This week he will post the slides needed for the final. "Same way as the midterm, just print out the necessary slides" (open book).
  • (Nov 17-1 46:27) ⭐ "The final exam won't focus on calculation… it focuses more on why questions. Give me your rationale. Why do you choose this? Why do you choose that?"
  • (Nov 17-2 41:52–42:07) On the NLL gradient: "Do we really have to remember that? No. The final exam is all about why questions. Give me reasons why you choose this, why you choose that."
  • (Nov 17-3 16:08) ⭐ QNN "is included in the final but it's not going to be involved with math… it's going to be just why questions."
  • (Nov 17-2 05:26) He was finalising the final exam paper that night (before Wednesday).
  • (Nov 17-3 45:52) "That sums up everything that is needed for the final… see you next week in the final exam room."
  • Slide 28 has his handwritten green line labelled "Final". It marks where final material ends before the SVM section.
  • (Nov 10-2 52:05 & 53:23) The Ch7 part on the final ends at Hamiltonian extraction. Qubitization is NOT in the final. Next week = VQA, "the final week".

Q7 — VQA loop and quantum embedding (slides 4–5)

  • (17-1 19:39) Main purpose: (1) the model can be quantum; (2) then you can adjust many parameters at the same time in the quantum way.
  • (17-1 20:17) The VQA loop is almost the same as classical ML. "The only difference is the quantum part": the input becomes a quantum state (can be complex), not a real vector.
  • (17-1 21:34) ⭐ Spoiler: "You will use the quantum algorithm as non-linear activation function", especially in neural networks. He also wrote this on slide 4.
  • (17-1 22:44–24:04) Loop: parameters → prediction (measurement) → compare with the gold standard → loss → readjust with SGD → repeat.
  • (17-2 06:07–06:36) WHY the training is classical (student asked why not purely quantum): "the qubit number is very small… and the noise. Quantum computers are noisy, not reliable for training parameters, so we separate the training task outside of the quantum algorithm."
  • (17-1 24:23–25:36) Embedding means "assign a vector to an item". Quantum embedding = assign a quantum state to an item.
  • (17-1 25:50) Basis embedding is the simplest: binary features go straight into a superposition. He skipped the encoding-circuit details: "just learn that it exists."
  • (17-1 28:46) Angular: "It's in the gate, not a quantum state." The input state is |0⟩ and each feature becomes the rotation angle of its own qubit.
  • (17-1 29:55) Angular is less accurate / less precise. Features are real numbers, no longer binary.
  • (17-1 30:43) ⭐ "Choose your embedding according to your data." Binary features → basis ("very accurate"). Real values → angular or amplitude.
  • (17-1 32:04–33:56) Amplitude embedding must be normalized. "You don't really have to mention [the PennyLane commands] in the final. What you really have to do is choose the embedding method according to the data."

Q7 — Ansatz, basic and strong entanglers (slides 7–9, plus 10–11 for the why)

  • (17-1 34:24) Ansatz = German for guess = a trial wave function. In QC: try or guess all possible sets of parameters θ.
  • (17-1 36:47–37:20) The result is a wave function. Each coefficient is controlled by θ1 and θ2.
  • (17-1 38:02–39:32) A problem-inspired ansatz needs background knowledge. In ML we want a generalized one = problem-agnostic ("you don't take sides", like a religious agnostic).
  • (17-1 40:48–41:47) ⭐ WHY entangle: "In QML we want to learn how to create an arbitrary quantum state, and in most cases they are entanglement. So we need to accommodate entanglement." Every entangler = parameterized rotation + entanglement.
  • (17-1 41:54) A basic entangler "is generalized enough to learn to create any quantum state… just like a neural network."
  • (17-1 43:19) Student summary: "rotate, entangle, rotate, entangle." "How lovely." MultiBEL = stacked BEL layers.
  • (17-1 45:43–46:21) Strong entangler: R has four parameters. α and β control |0⟩; β and γ control |1⟩. "You don't really have to remember them." What matters is that they give more control over the coefficients of |0⟩ and |1⟩.
  • (17-1 47:12–47:42) φ is the global phase and rotates both |0⟩ and |1⟩. That is why the strong entangler is more flexible: you can rotate in "every possible direction".
  • (17-1 47:48) The cost: more parameters "take ages to train" (LLM analogy: 7B, 14B parameters).
  • (17-1 50:08) The CNOT order can be flipped or arranged any way, "as long as it is entanglement".
  • (17-1 54:58) In ML, flexibility is called expressivity: "you can express more quantum states, like freedom of expression = freedom of creation."
  • (17-1 56:21–57:31) ⭐ "We prefer trainability to expressivity… because we cannot wait. We all have ADHD." So in most cases use the basic entangler. Strong is fine for small models, but it takes ages at 100–1,000 qubits.
  • (17-1 59:05) Students' senior project: the strong entangler was about 4× slower to train. The data was small, but on large data strong is significantly slower.
  • (17-2 00:37–03:32) Architectures: HEA = one layer covers all qubits; every hardware platform provides it. TEN = split the state into modules; you must know the shape of the problem. ALT = brick wall, an approximation of HEA, "less expressive but good enough in most cases."

Q7 — Prediction loss and SGD (slides 14–15)

  • (17-2 07:12–09:38) Loss = difference between the model output and the gold standard. Comparing two vectors works like dot product or cosine similarity.
  • (17-2 09:55–12:05) Compare qubit k with bit k of the training data, bit by bit. The basis B is usually Z, because we want the expectation of 0 or 1 (north/south pole), which compares directly with binary labels.
  • (17-2 13:14–15:45) ⟨Z⟩ ∈ [−1, 1]: positive = |0⟩, negative = |1⟩. "Expectation means average of the measurement." MSE example: (Z1−0)², (Z2−0)², (Z3−1)², (Z4−0)², then average.
  • (17-2 17:51) SGD = his "hill descending algorithm".
  • (17-2 22:45–23:21) ⭐ The slope tells you two things: direction and step size.
  • (17-2 23:30–24:52) WHY the minus sign: the slope is negative but you move right, so flip the sign. WHY η: the slope can be enormous, so scale it down ("ETA, not estimated time of arrival"), e.g. 10⁻⁴.
  • (17-2 25:40–26:20) WHY it stops: at the minimum the slope is 0, so θ(k+1) = θ(k).
  • (17-2 26:39–27:16) The problem: "what if I have an ansatz? How could I compute that gradient? The gradient of a quantum gate is difficult already. How about a whole circuit?" This motivates the PSR.
  • Slide 15 annotation: "Main challenge: how can we find the gradient ∂L/∂Θ?" Exercise hint for "why only a local optimum": think of a mountain range.

Q7 — Loss functions and hybrid models (slides 17–21; 21 is on the exam)

  • (17-2 33:28) Of the loss criteria, "in most cases we care about meaningfulness: we need to interpret the meaning of the difference."
  • (17-2 35:47) MSE: "neutralize the sign of the difference by squaring it", then average.
  • (17-2 39:08–40:27) ⭐ WHY NLL instead of MSE: MSE is good for large differences (outputs in [−1, 1], max difference 2). If outputs are only in [0, 1], differences are below 1, so use NLL. NLL cares only about the probability of the correct class. The slide 19 annotation says the same.
  • (17-2 42:31–44:42) Hinge = count of mispredictions. The line works like a door hinge: rotate the door and count the things on the wrong side. Its gradient uses only the mispredicted points. Slide 20 annotation: "emphasize only the number of mispredictions."
  • (17-2 46:30–47:58) Which loss goes with which model: linear regression (trend) = MSE, logistic regression (binary classification) = NLL, SVM (boundary, can be non-linear) = hinge.

Q7 — Parameter shift rule (slides 22–24)

  • (17-2 48:07) "The most important part is to compute the gradient of the expected measurement, which looks like an Einstein equation but it's not. If you understand this, you can understand quantum neural networks."
  • (17-2 49:43–51:12) ⭐ The recipe: add 90° (π/2) → run → measure the expectation; subtract 90° → rerun → measure; take the difference and halve it = the gradient.
  • (17-2 51:12–52:21) ⭐ WHY it is great: "Instead of actually computing the gradient, you just shift the phase by 90°… you don't have to differentiate any matrix at all."
  • (17-2 53:04–53:25) ⭐ Contrast: "In classical ML you have to differentiate all kinds of layers in your neural network. In quantum computing you don't have to at all."
  • (17-2 55:06) "Training a model is not that difficult. You just run your algorithm twice."
  • (17-2 55:31–56:19) The proof is about 2 A4 pages in his book. The name comes from the parameters being phases: phase shift = parameter shift rule.
  • (17-2 52:29) A student's senior project modified the PSR (his pride in his students).
  • (17-2 56:44) Gradients of MSE, NLL and hinge = substitute the PSR for ∂b/∂θ. "You can implement it yourself, but I don't recommend that."
  • Slide 23 annotation: "PSR is irreversible due to projection-based measurement", with b_k = ⟨B^(ψ)⟩ written in red. Exercise 8.2.8 asks why.

Q7 — Quantum neural networks (slides 37–41)

  • (17-3 16:44–19:11) Perceptron = the basic unit of all neural networks. It works like a neuron: if the input signal is large enough (above the threshold), it "wakes up" and fires 1.
  • (17-3 19:48–20:20) The parameters are the weights and the bias. Change them and you get a different perceptron.
  • (17-3 21:19–21:47) Quantum perceptron: "Instead of having weights, we have phases. From weights to phases." Combined with a tensor product.
  • (17-3 22:26–23:09) A classical NN has a linear part (weights = linear regression) and a non-linear part (activation function).
  • (17-3 23:09–23:59) ⭐⭐ WHY no activation function: "In the quantum perceptron everything is non-linear. Even the rotation is non-linear. Think about rotation, it's a circle. That means we don't need the activation function at all… The rotation itself is an activation function." (Repeated at 31:14–31:36.)
  • (17-3 24:45–25:22) QMLP: the input layer is just a channel with no perceptron. The hidden and output layers are quantum perceptrons.
  • (17-3 26:36–29:39) ⭐ WHY a hidden layer: going from 5 features to 2 classes directly is hard. With too many dimensions "everything is spread in the space" and you can't see grouping. The hidden layer compresses (dimensionality reduction) so groups appear and a plane can separate them. The number of hidden perceptrons = the output dimension of that layer.
  • (17-3 30:24–30:43) Deep learning = an MLP with more than one hidden layer.
  • (17-3 31:43–32:26) Backprop: compute the loss, then update from the last layer to the first, one set of parameters at a time.
  • (17-3 32:26–33:29) ⭐ "How do you update? SGD, and you use the parameter shift rule to update each parameter." Step 3 of slide 41 = PSR.
  • (17-3 34:26–34:54) ⭐ Practical use: "we use a quantum algorithm as the activation function. We mix the classical NN with a quantum algorithm. We don't use pure quantum algorithms."
  • (17-3 37:19–37:31) "We use quantum algorithms in place of activation functions. We don't need the hyperbolic tangent."
  • (17-3 38:27–39:46) PyTorch automatically estimates parameters separately: classical layers by SGD/Adam (he used Adam), quantum layers by the parameter shift rule.
  • (17-3 40:28–41:40) ⭐ The advantage of hybrid: flexibility of the activation function. Sigmoid and tanh are fixed to one shape; a quantum layer is a learnable activation function, which can reduce the complexity of the classical model.
  • (17-3 41:53–42:21) Limitation: CPU/GPU-to-QPU latency, because the hardware sits separately. A GPU/QPU card (NVIDIA) would fix this.
  • (17-3 43:02–43:50) IBM runs in milliseconds; photonic QCs (PsiQuantum) aim for GHz. Hybrid models will arrive "when the platform is mature."
  • (17-3 44:14) "This is only an anchor for the beginning of your career."

Funny lines / catchphrases (for the video)

  • (17-1 12:04) "You may die. Okay." (opening line)
  • (17-1 15:50) He updated to iOS 27 thirty minutes before class and the screen mirroring broke.
  • (17-1 48:46) Anecdote: Qwen comes from Chinese "qiān wèn", a thousand questions. "My French is rusty."
  • (17-1 53:59) He calls the ansatz by a sound-alike Thai swear word. (17-2 00:37) "HEA — don't read it in Thai."
  • (17-1 56:34) "We prefer trainability… because we cannot wait. We all have ADHD."
  • (17-2 03:58–04:43) How to dodge a hard question in your senior-project defence: "Due to time limitations / hardware limitations, we could not conduct this experiment."
  • (17-2 17:51) SGD = "hill descending algorithm". (17-2 24:28) "ETA, not estimated time of arrival."
  • (17-2 37:24) "Easy peasy lemon squeezy." (17-2 49:07) "Looks like an Einstein equation but it's not, believe me."
  • (17-2 57:42) "5-minute break, because your brain is medium rare already."
  • (17-3 15:34) "A 5-minute break never exists in Thailand. Five minutes means 10."
  • (17-3 46:31) Asked for a selfie: "I prefer a selfie in the final exam room while everybody is doing the paper. I'm a psycho. I know."
  • XOR code comment: "The accuracy is 100%. You should be proud of yourself. ;)"
  • (Nov 10-2 47:28) The "reciprocate" girlfriend joke. (Nov 10-2 55:01) VQA = a "configurable sausage machine".