[ BENCHMARKS / v5.0 / TASKS / 40_attention ]

Scaled dot-product attention (single head) in Python.

Single-head scaled dot-product attention over plain lists, with a softmax that stays exact for scores in the thousands, without numpy or torch.

Unit
40_attention
Category
LLM / MLAttention
Language
Python
Difficulty
Medium600 s wall clock (10 min)
Origin
From v4, upgraded
Ranked rows passed
7/7single seed each

The prompt

The agent receives exactly this text as its task, verbatim. The harness adds its own system prompt and, in some campaign arms, guidance of its own; the harness chapter describes those. The task’s setup also writes the files its working directory starts with (a worked sample, a repository or a service, where the prompt names them); they are not reproduced here.

Prompt · 40_attention
Create /tmp/eval_attn/attention.py with a function attention(Q, K, V) that implements single-head scaled dot-product attention. Inputs are 2D lists of floats: Q is (n_q x d_k), K is (n_k x d_k), V is (n_k x d_v). Return a 2D list (n_q x d_v) of floats: softmax(Q @ K^T / sqrt(d_k)) @ V, where softmax is taken along each row of the n_q x n_k score matrix. The softmax must be numerically stable: scores with magnitudes in the thousands, positive or negative, must still give the correct result with no overflow or division by zero. Graded on hidden inputs with a tolerance of 1e-6 (relative for values above 1). Use only the Python standard library (math); do not use the numpy or torch libraries.

What it tests and why it is in the suite

What it asks. Single-head scaled dot-product attention over plain lists, with a softmax that stays exact for scores in the thousands, without numpy or torch.

Why it is here. From v4, upgraded for v5: seeded hidden tests inside the validator and no expected-output files for them. With autograd and the stable softmax it covers LLM / ML.

In the suite README: evals/README.md:134 · evals/README.md:148

How it is graded

The validator holds its test cases where the agent cannot read them, and runs them against what the agent left on disk once it stops. Since the upgrade its cases are generated from a seed and no expected output for them is in the agent’s directory (the worked sample the prompt names is only a sample); a mismatch reports only the failing case’s index. The unit was proven like the new ones (reference passes; wrong, empty, leaking and, where timed, slow solutions fail) and passed the same adversarial review.

Upstream: the prover’s controls · one unit’s life cycle · why v5 is built this way

How each ranked run did

One run per board row, the DGX Spark pair first, then the RTX 5090, then the gold standard. Each is a single seed: a pass or a fail on one unit is one draw, and a difference between two rows on one unit says little on its own. Claude Opus 5.5 is the unranked reference, in its own scaffold.

DGX Spark pair

One RTX 5090

Gold standard · unranked

  • Claude Opus 5.5Claude Code tools, no turn cap, 2× wallPassedPassed the validator.