Hands-on lab · 1 step
Build strongly entangling layers
Implement PennyLane-convention strongly entangling layers as a list of Circuit-IR operations: on every wire the general rotation , then the cyclic CNOT block with the layer-dependent range . The grader compares the unitary of your circuit with the reference unitary on weight tensors of shapes , , and , requiring process fidelity at least .
Step 1: Implement stronglyEntanglingLayers
Complete the TypeScript function
stronglyEntanglingLayers(weights: number[][][], n: number): Operation[]
that returns the operations of strongly entangling layers on qubits, in time order.
Shapes. weights has shape : weights[l][i] = [phi, theta, omega] holds the three angles of wire in layer . The circuit has rotations and, for , CNOTs. Qubit is the most significant bit and .
Layer ():
- on every wire the rotation written as the three operations
{ kind: 'gate', gate: 'RZ', targets: [i], params: [phi] }, then'RY'with[theta], then'RZ'with[omega]; - if , with the range the CNOTs for in this order, each written
{ kind: 'gate', gate: 'CNOT', targets: [control, target] }. For there are no CNOTs.
Grading. For every test the grader builds the circuit { numQubits: n, ops } from your list, computes its unitary and compares it with the reference unitary through the process fidelity , so a different but equivalent gate sequence also passes. The weights of the hidden tests are with drawn from mulberry32(seed) in the order , , . The tests are grouped into three checks:
- rot-symmetric (hidden): one layer with on every wire, (seed ) and (seed );
- single-layer: the visible test zero-weights-L1-n2 and hidden random tests of shapes (seed ) and (seed );
- multi-layer (hidden): shapes (seed ) and (seed ).
Visible test. weights = [[[0, 0, 0], [0, 0, 0]]] and n = 2: all rotations are the identity and , so the circuit is followed by . On basis labels , hence with , , , .