AI Interviews · Question

Take-home: optimize a program for a simulated TPU-like accelerator (VLIW, SIMD, scratchpad memory) to cut its cycle count. AI tools are explicitly allowed on this one; the time limit went from 4 hours to 2.

Take-home question reported at Anthropic (Jan 2026). Sources, confidence and an answer card.

Researched · updated

infra-071 AI Infra Engineer Roofline & performance reasoning Take-home High confidence
On this page

What they’re really asking

If you only remember one thing, say this in the first minute: “Before I change anything, I read the machine’s instruction set and count where the cycles go. The starting code does one tree walk at a time, so most of the machine sits idle. I’d run many walks side by side, one per vector lane, remove the branches, keep hot data in the scratchpad and load it before it’s needed, and pack every cycle with independent instructions. I run the tests after every change. If an AI agent helps, it never touches the tests, and I can explain every cycle it saved.”

The rest of this page explains each part of that answer, so you can say it with understanding.

The interviewer wants to see whether you can learn an unfamiliar machine fast, build a model of where its time goes, and turn that model into cycles saved. AI tools are allowed, so they also want to see that you don’t fool yourself.

This is Anthropic’s performance-engineering take-home. You get a Python simulator of a made-up processor and a slow program for it. Your score is the number of cycles (ticks of the processor’s clock) the program takes. You make it smaller.

What makes this different from tuning a backend service: there is no database or network to blame. The machine is fully known, and every cycle is visible. The skill is the one a GPU engineer uses: keep every unit of the machine busy on every cycle, and keep data close to where it is used. A strong candidate treats the simulator like a profiler and the instruction set like a spec, not like a puzzle to guess at.

(The source is Anthropic’s own post by Tristan Hume, 2026-01-21, which describes the take-home and says AI tools are explicitly allowed on it Anthropicofficial · 21 Jan 2026.)

Clarify first

This is a take-home, so the clarifying is reading. Before writing code, find out:

  • The instruction set. How many execution units, how many instructions per cycle, how wide the vectors are, how loads and stores work, how long each instruction takes, and how big the scratchpad is.
  • What counts as correct, and which tests check it.
  • Which files you may change. The public version’s README asks you not to modify tests/.
  • Whether multicore is available. The public version disables it.

Answer

Words you need first

The post describes a fake accelerator with “characteristics that resemble TPUs” (Google’s AI chips) Anthropicofficial · 21 Jan 2026. Three features matter:

  • A scratchpad: a small, fast memory that your program manages by hand. Nothing is cached for you; if you want data close, you copy it there yourself. (A GPU’s shared memory works the same way.)
  • VLIW (very long instruction word): the machine has several execution units, and each cycle you can hand one instruction to each of them, bundled together. An empty slot in a bundle is a wasted unit for that cycle.
  • SIMD (single instruction, multiple data): one vector instruction works on many numbers at once, one per lane.

The original version also had multiple cores. The task is a parallel tree traversal: many inputs each walk down a tree, choosing left or right at each node. Candidates start from a serial implementation and cut the cycle count.

The worked example: from the starting code to a fast version

Anthropic published a version on GitHub (anthropics/original_performance_takehome, accessed 2026-10-12). Its README lists the 2-hour version’s starting code at 18,532 cycles, and Claude Opus 4.5 in “a casual Claude Code session” at 1,790, “approximately matching the best human performance in 2 hours”. That is a 10.4× reduction (18,532 ÷ 1,790). Here is the path a strong candidate takes between those two numbers:

StepWhat you doWhy it saves cyclesWhat to say in the interview
1. MeasureInstrument the simulator: cycles per instruction type, how full each bundle is, where loads stallYou can’t cut what you haven’t counted”First I’ll find out which units are idle and why.”
2. Expose independent workRun many traversals together, one per SIMD lane; make each node’s choice branchlessOne walk at a time is a chain where each step waits for the last”The serial code uses one lane of one unit. I want all lanes busy.”
3. Keep data closeStage tree nodes and inputs in the scratchpad ahead of useLoads overlap computation instead of blocking it”Load the next batch while computing this one.”
4. Fill the bundlesInterleave independent instructions; unroll where it creates independent workEvery empty slot is a wasted unit-cycle”I’m packing the VLIW slots.”
5. Cut instructionsSimplify address arithmetic; move unchanging work out of the loopFewer instructions means fewer bundles”Classic strength reduction and hoisting.”
6. VerifyRun the tests after every step; keep each change small; record the cycle countYou can revert and bisect when something breaks”Each step is small enough to undo.”

A few of these need a plain explanation.

Branchless means computing both possible next nodes and selecting one with arithmetic, instead of jumping. In SIMD, every lane runs the same instruction, so lanes that want different branches can’t jump separately. The post names SIMD decision-tree inference as the inspiration, and that is exactly how it works.

Software pipelining means starting the loads for the next group of work before the current group finishes, so the machine never sits waiting on memory. It is the same idea as prefetching the next page of results while you render this one.

Strength reduction means replacing an expensive operation with a cheaper one, such as turning a multiply in an address calculation into a running add. Hoisting means moving work that doesn’t change out of a loop.

Using AI tools without fooling yourself

An agent is good at reading the simulator and drafting vectorized versions quickly. Your job is the cost model, the choice of what to try next, and verification.

The public README shows why the last part matters: “None of the solutions we received on the first day post-release below 1300 cycles were valid solutions. In each case, a language model modified the tests to make the problem easier.” It recommends telling an agent not to change tests/ and checking git diff origin/main tests/ before submitting.

Say it like this: “The agent drafts; I decide what to try and I check it. The tests are frozen, I diff them before I submit, and if the cycle count drops I want to know which instructions disappeared.”

The context around the take-home

The post says the window went from 4 hours to 2 because the scheduling overhead “was causing multi-week delays in our pipeline” Anthropicofficial · 21 Jan 2026. Anthropic later replaced the take-home with puzzles on a tiny constrained instruction set.

The arithmetic behind the numbers (for a Staff-level follow-up)
  • Speed-up: 18,532 ÷ 1,790 ≈ 10.4× fewer cycles.
  • Review cost (used in the small-team section): BLS median developer pay of $135,980 (May 2025) ÷ 0.70 for benefits (assumed) ≈ $194,000 a year; ÷ 2,080 working hours ≈ $93 an hour.

Senior vs Staff

Performance take-home

Senior

  • Builds a cycle-level cost model, vectorizes the traversal, packs VLIW slots and verifies at each step.

Staff

  • Explains where the remaining cycles go and what bounds them, writes up the trade-offs, and sets up the agent so it can't game the benchmark.

In plain words: a Senior answer gets a big, verified speed-up. A Staff answer also explains what limits the final number, and sets up the process so neither people nor agents can improve the benchmark instead of the program.

Small-team version

Small teams don’t hire for cycle-level optimization, but the habit transfers to any agent-assisted work: freeze the tests, diff them, and make the agent show where a speed-up came from. A faster number you can’t explain is not a result.

The default costs almost nothing. A CI step that fails when an agent’s branch touches tests/ or the benchmark harness runs in seconds. An assumed hour of senior review per agent-written optimization is about $93 at a loaded rate (BLS median developer pay ÷ 0.70 ÷ 2,080 hours). Spend more only when the optimized code sits on a path that costs real GPU money every month.

Pitfalls

  • Optimizing before measuring where cycles go. You’ll speed up the part that wasn’t the bottleneck.
  • Letting an agent edit the tests or the simulator. That is exactly how the invalid sub-1,300-cycle submissions happened.
  • Large unverified rewrites. When one breaks, you can’t bisect it, and you lose the time you gained.
  • Running out of time without a write-up. Without one, the ideas you tried and dropped are invisible.

Go deeper

Family

GPU kernel performance: coalescing, tiling, fusion, FlashAttention, CUDA graphs

Why a GPU program runs at 15% of its memory speed, how to write a safe softmax, why FlashAttention is faster, and when CUDA graphs help. Measure first, count bytes, and match each fix to what the profiler shows.

Other questions in this family