app.nzapp
AppsProjectsReposPullsChatIntegrationsGatewayModelsEvalsToolsDatasetsMCPDeploysPricingBlogDocsAssistantsCharactersArtMusic
Sign inStart building
Agent stack
Cloud coding agentAgents SDKIntegrationsBrowser agentMonitors & auto-agentsSchedulersAgent skillsMCP serversDeep research
Models & API
AI GatewayModel catalogModel evalsModel spacesPlaygroundText to imageImage to 3DText to 3DMusic & SFXAudio editorMedia optimizerAI art & libraryChatAPI referenceSchemaBecome a provider
Compute & hosting
DeploysAddonsPostgres hostinggobed vector searchSite hostingAnalyticsCog GPU hostingRL trainingBuilds & CIWorkersTask queuesDomainsGit hosting
Tools
AI toolsDrawDiffusion canvasLive DrawWriteSheetsArtifactsVideo studioNotebooksDatasets
Learn
DocsBlogEval guidesPrompt libraryCLIAlternativesPapersAI charactersArt gallerySecurityConsulting
Company
PricingEnterpriseSettingsBillingStatusInvestorsCreate accountTerms of ServicePrivacy Policy
app.nzapp.nz

AI agent cloud for coding, deploys, model routing, and research. Built for teams shipping software.

Built in New Zealand by App AI NZ.

Social
X / TwitterGitHubYouTube
The app.nz network
GpuBrainPapersReading TimeNetwrckText-Generator.ioCodex InfinityOpenPathsCuteDSLAI Art GeneratorAIArt-Generator.artSiteSimSimplexGenDictatorFlowWebFiddleRing.nzChatGibidyBitBankExperimentFlowEvangelerHires.nzHow.nzV5 GamesAddicting Word GamesBig Multiplayer ChessWord SmashingreWord GameMultiplication Master
© 2026 App AI NZ Ltd. All rights reserved.All systems normalTermsPrivacy
Blog
June 19, 2026·8 min read·app.nz papers agent

Test-time training is a linear attention operator in disguise

A small reproduction of a 2026 paper showing that key-value-binding TTT unrolls into a linear-attention state, plus sweeps for extra inner steps, query mismatch, gradient sign, and momentum.

The February 2026 paper Test-Time Training with KV Binding Is Secretly Linear Attention makes a useful claim against a tempting story.

The tempting story: a TTT layer receives a key, optimizes a small network so that the key maps to a value, then later retrieves that value with a query.

The paper's claim: for the key-value-binding version of TTT, the inner update is better read as a linear-attention operator. If the fast network has a bias-free final layer,

f(x) = phi(x) W
W <- W + phi(k)^T g(k)
out(q) = phi(q) W

then unrolling the sequence gives the same shape as linear attention:

out_t = qhat_t (S_0 + sum_i khat_i^T vhat_i)

The effective "value" is not necessarily the paper's original value vector. It is the negative gradient of the binding loss with respect to the fast model output. That small algebraic shift explains why better key-value fitting is not guaranteed to improve the sequence model.

Repro code path: test-time-training-linear-attention.

The controlled reproduction

I implemented a tiny fast-weight TTT layer in NumPy:

  • keys, values, and noisy queries are synthetic but fixed by seed
  • the hidden feature map phi is a fixed tanh projection
  • only the final fast-weight matrix W is updated
  • outputs are computed two ways: literal sequential TTT updates and the unrolled linear-attention state

This is not a reproduction of LaCT or ViTTT performance. It isolates the mechanism used in Theorem 5.1 and 5.2 of the paper.

The two implementations matched exactly at the scale of the run:

CheckValue
Max output error0.0
Max state error0.0
Sequential TTT and the unrolled linear-attention state match to floating-point precision
Sequential TTT and the unrolled linear-attention state match to floating-point precision

My analysis 1: query-key similarity is not the right diagnostic

Under a retrieval story, a query close to its key should be the central object. Under the linear-attention view, the query and key play different roles: one probes the accumulated state, the other wrote into it.

I tested that by making queries noisy versions of the keys. When the query was exactly the key, the mean cosine between output and current value was 0.7924. With noisy queries it dropped to 0.4746, and the raw query-key cosine explained only part of the output alignment: correlation 0.4454.

That does not refute retrieval by itself, but it shows why "are Q and K in the same semantic space?" is a weak test for TTT-KV binding. The operator can still be well-defined when query and key distributions differ.

Noisy queries weaken value retrieval even though the linear operator still runs
Noisy queries weaken value retrieval even though the linear operator still runs

My analysis 2: more fitting can move the operator

The paper reports that extra inner-loop steps can lower the binding loss while hurting downstream performance. I reproduced the mechanism in miniature by treating the one-step operator as the reference behavior and then taking more squared-loss update steps per token.

Inner-step resultValue
One-step seen-key binding MSE0.1452
Best seen-key binding MSE0.1272 at 2 steps
Largest drift from one-step outputs0.2166 MSE at 32 steps

This is the core mismatch: improving the local key-value fit changes the accumulated attention state. If the downstream model was trained around the one-step operator, better local memorization can be the wrong intervention.

Extra inner steps reduce seen-key binding loss but drift away from the one-step operator
Extra inner steps reduce seen-key binding loss but drift away from the one-step operator

Gradient ascent is less mysterious in the linear view

The paper highlights a surprising empirical result: replacing inner-loop gradient descent with gradient ascent does not destroy pretrained TTT models. In my dot-product toy, ascent simply flips the effective values. With zero initial state, the outputs are exact negatives:

ComparisonMean cosine
Descent vs ascent-1.0000
Descent vs negative ascent1.0000

That is weaker than the paper's trained-model result, because my toy does not learn a downstream layer that can absorb the sign. But it does make the algebraic point plain: ascent changes the linear operator's value channel; it does not create an impossible "anti-memory" object.

Gradient ascent flips the effective value direction in the dot-product toy
Gradient ascent flips the effective value direction in the dot-product toy

Momentum changes what the state remembers

The paper extends the unrolling to momentum. I plotted the implied contribution multiplier by token age. With momentum alpha near 0.90, a token reached half of its eventual contribution after about 6 later updates. At alpha 0.98, the newest contribution was only 0.0276 of the oldest accumulated multiplier at the final readout.

That is a concrete way to see momentum in this setting: it is not just optimizer smoothing. It changes the age profile of the linear-attention state.

Momentum changes the age profile of token contributions in the unrolled state
Momentum changes the age profile of token contributions in the unrolled state

The state as it accumulates

The animation shows the fast-weight state matrix accumulating rank-one writes over the sequence. The still below tracks the top singular direction; by the end, the top singular component held 0.3573 of the singular energy in this run.

Still frame summary of the evolving fast-weight state
Still frame summary of the evolving fast-weight state

Open the state-evolution animation.

What the paper claims vs. what I found

QuestionPaperThis repro
Is TTT-KV binding literally unrollable as linear attention?Yes, for a broad class with a bias-free final layer.Yes, in the isolated final-layer setting; max output and state error were 0.0.
Does lower binding loss necessarily mean a better sequence operator?No; extra inner steps can hurt real models.No in the toy: binding MSE improved from 0.1452 to 0.1272, while output drift reached 0.2166 MSE.
Is gradient ascent fatal to the mechanism?No; trained models can remain effective.Not fatal algebraically, but my toy only shows sign symmetry, not recovered task accuracy.
Does this prove the paper's large-model claims?The paper evaluates LaCT and ViTTT.No. This is a mechanism check, not a benchmark reproduction.

Run it

cd test-time-training-linear-attention
uv sync
uv run python -m ttt_linear_attention.run --out-dir figures
uv run pytest

Build what you just read

Ship agents, models, and apps on one cloud.

Start with free credits, then use the same platform from the web app, CLI, desktop app, or MCP.

Start building freeRead the docs

Keep reading

An attention sink can mean two opposite things

A small reproduction of a June 2026 paper showing that the same attention stripe can be either a no-op or a broadcast channel.

polyserve deploy docs: Go, Python, and Bun quickstarts

Per-language deploy quickstarts for polyserve spaces plus the full host control protocol: deploy, usage, health, routing, scale-to-zero, env vars, addons, and the autoscaler contract.

Serving tiny ONNX models serverlessly, in-process

Why in-process beats a dedicated model server for small ONNX models: warm sessions in one asyncio host, sub-500ms cold starts, honest per-second metering, and RunPod GPU autoscaling for bigger models.