Worked: A ternary weight was packed into a 2-bit code to save memory. To use it you must decode back to {-1,0,+1}. The naive decode is a select-chain: np.where(c==1, 1, np.where(c==3, -1, 0)) — for every weight, test the code and pick a value. It is correct, and on a GPU it is the bottleneck: per-element branches serialise and stall the memory pipeline (measured: ~62% of the first kernel's time).
Your turn: The codes were chosen so decoding needs NO branches. With +1 -> 0b01 (1), -1 -> 0b11 (3), 0 -> 0b00 (0), the single expression (c ^ 2) - 2 recovers the weight: 0^2-2 = 0, 1^2-2 = +1, 3^2-2 = -1. Fill the gap: W_fast = (c ^ 2) - 2. One xor, one subtract, fully vectorised — no np.where.
Independent: The grader proves the point that matters: W_fast must equal both the branchy decode AND the original weights to the last bit (max error exactly 0) — a faster kernel that changed the answer would be worthless. Then read the measured ledger from the Charlot Lab kernel project (real RTX 4050 medians, bit-correct): the select-chain kernel ran 2.58x vs bf16; the branch-free decode runs 5.83x — a 2.26x tax removed — against an 8x memory-ratio ceiling. Ask yourself why 5.8x and not 8x: some unpack and reduction overhead always remains, and at batch-1 the GPU is not fully saturated. The honest number is a real 5.8x, not a slogan.