QuantumCore

Hands-on lab · 1 step

Train a hardware-efficient ansatz to GHZ

The circuit is a fixed hardware-efficient ansatz on 33 qubits with 22 layers: in each layer every qubit gets RYR_Y then RZR_Z, followed by the CNOT ladder CNOT(0,1)\mathrm{CNOT}(0,1), CNOT(1,2)\mathrm{CNOT}(1,2). All 1212 angles start at 00, where the circuit outputs ∣000⟩\lvert000\rangle. Choose angle values so that the output is the GHZ state 12(∣000⟩+∣111⟩)\tfrac1{\sqrt2}(\lvert000\rangle+\lvert111\rangle), using the identity-at-zero and basis-state tracking arguments of the lesson.

0/1 step passedBest score 0/100

Step 1: Reach the GHZ state with the HEA template

The circuit structure is locked: you may only change the values of the 1212 trainable parameters. The parameter named t_l_q_k\texttt{t\_}l\texttt{\_}q\texttt{\_}k is the angle θl,q,k\theta_{l,q,k} of layer l∈{0,1}l\in\{0,1\} on qubit q∈{0,1,2}q\in\{0,1,2\}, with k=0k=0 for the RYR_Y rotation and k=1k=1 for the RZR_Z rotation. Layer ll is Wl(θ)=CNOT(1,2) CNOT(0,1)∏q=02RZ(θl,q,1) RY(θl,q,0),W_l(\theta)=\mathrm{CNOT}(1,2)\,\mathrm{CNOT}(0,1)\prod_{q=0}^{2}R_Z(\theta_{l,q,1})\,R_Y(\theta_{l,q,0}), so in time order: RYR_Y then RZR_Z on each qubit, then CNOT(0,1)\mathrm{CNOT}(0,1), then CNOT(1,2)\mathrm{CNOT}(1,2). The circuit is W1(θ)W0(θ)W_1(\theta)W_0(\theta) applied to ∣000⟩\lvert000\rangle, with RP(θ)=e−iθP/2R_P(\theta)=e^{-i\theta P/2} and qubit 00 the leftmost (most significant) bit.

Set the parameters so that the output state is ∣GHZ⟩=12(∣000⟩+∣111⟩).\lvert\mathrm{GHZ}\rangle=\frac1{\sqrt2}\big(\lvert000\rangle+\lvert111\rangle\big). The grader requires the fidelity F=∣⟨GHZ∣ψ(θ)⟩∣2≥0.99F=\lvert\langle\mathrm{GHZ}\vert\psi(\theta)\rangle\rvert^2\ge0.99. A single non-zero angle suffices.

  • 3 qubits
  • no measurements
  • structure fixed: change parameters only
  • free parameters: t_0_0_0, t_0_0_1, t_0_1_0, t_0_1_1, t_0_2_0, t_0_2_1, t_1_0_0, t_1_0_1, t_1_1_0, t_1_1_1, t_1_2_0, t_1_2_1

One gate per line or separated by ;, e.g. H(0); CNOT(0,1); RY(1, pi/3); measure(1 -> 0). Qubit 0 is the top wire (most significant bit); controls come first. # starts a comment.

Measure into a classical bit with measure(q -> c); apply a gate only when a bit is set with X(2) if c1==1 (several bits, first = most significant: if c[0,1]==3).

Parameters
= 0
= 0
= 0
= 0
= 0
= 0
= 0
= 0
= 0
= 0
= 0
= 0
Circuit diagram of your answerRY(t_0_0_0) on q0; RZ(t_0_0_1) on q0; RY(t_0_1_0) on q1; RZ(t_0_1_1) on q1; RY(t_0_2_0) on q2; RZ(t_0_2_1) on q2; X on q1 controlled by q0; X on q2 controlled by q1; RY(t_1_0_0) on q0; RZ(t_1_0_1) on q0; RY(t_1_1_0) on q1; RZ(t_1_1_1) on q1; RY(t_1_2_0) on q2; RZ(t_1_2_1) on q2; X on q1 controlled by q0; X on q2 controlled by q1q0q1q2RY(t_0_0_0)RZ(t_0_0_1)RY(t_0_1_0)RZ(t_0_1_1)RY(t_0_2_0)RZ(t_0_2_1)RY(t_1_0_0)RZ(t_1_0_1)RY(t_1_1_0)RZ(t_1_1_1)RY(t_1_2_0)RZ(t_1_2_1)
Statevector amplitudes
BasisAmplitude α|α|Phase arg αProbability
|000⟩1
1.0000
0
100.00%
7 basis states with zero amplitude hidden