← Back to learning

Mamba × TTT · IRSTD

A hidden state can itself be a learner.

Use a hand-checkable gradient step to understand internal memory, external supervision and inference boundaries.

About 25 min

Course chapters
Progress and notes stay in this browser.

One acronym, different questions

Classic TTT prepares an auxiliary self-supervised task during training and uses it to adjust shared features at test time under distribution shifts. TTT layers instead treat a small model’s parameters as sequence state, making internal learning part of representation computation. The ideas are related, but TTT does not universally mean entropy minimization.

RouteWhat learns?Role here
Classic TTT / test-domain adaptationShared features or selected model parametersHistorical and conceptual comparison
TTT layersInner state model W; outer θ controls its inputs and readoutWorking hypothesis and experimental focus

Classic TTT · ICML 2020 ↗ · TTT layers · 2024 / ICML 2025 ↗

Write with K and V, read with Q

Project a token x into a key k, value v and query q. The inner model fW learns a mapping from k to v; q reads a representation from the updated model. W changes with the current sequence. θ contains projections, initialization or other network parameters, as defined by the implementation.

k = θK x, v = θV x, q = θQ x
ℓinner(W) = ½‖fW(k) − v‖²
W′ = W − η∇W ℓinner(W)
z = fW′(q)

This is a teaching form of associative reconstruction. Real layers may add normalization, residuals, token/chunk batching and learned step sizes. It is not a complete implementation, and the inner loss receives no test mask.

Why is the outer loop necessary?

During IRSTD training, predicted masks and training annotations define the outer objective. The outer loop learns useful k/v/q views and how to send the inner readout into a segmentation decoder. It learns how internal learning can help detection, rather than merely minimizing each image’s inner loss.

training image → tokens / projections θ → inner updates of W → dense features → decoder → mask
Lseg(prediction, training mask) → update trainable outer parameters θ

Follow the selected baseline for differentiation through updates, detach boundaries, analytical updates or gradient approximations. Arbitrarily wrapping the whole inner process in no_grad breaks this contract. Inserting a new TTT layer into a trained MiM model does not guarantee useful behavior without training.

Interactive: predict the next gradient step

Start with w₀=0, k=2, v=1, η=0.1 and q=3: the gradient is −2, w₁=0.2 and the readout is 0.6. Increase the learning rate and observe when loss oscillates or grows. Lower inner loss is not evidence of higher detection accuracy.

State lifetime

PhaseOuter θInner WLabels
Source trainingUpdated through the outer task objectiveInitialized and internally trained as the layer specifiesTraining masks supervise the outer task
Single-image inferenceUsually fixedInitialized at image/layer boundaries; prescribed updates runNo test masks
Next independent imageStill fixedReset by default; verify the selected algorithmHeld-out labels belong only to the evaluator

When updates are part of normal TTT computation, disabling them is a mechanism ablation, not the original baseline. Carrying state between independent images also requires an explicit protocol.

From the toy equation to a reproducible model

Record the inner model, initialization, objective, learning rate and steps, projections, token/chunk order, reset scope, precision and gradient path. TTT-Linear uses a linear state model; TTT-MLP uses a nonlinear small network. A richer state model is not automatically faster or more memory-efficient.

Next: why vision cannot simply copy text →

Pause and check your understanding

What do a TTT layer’s inner steps usually update during inference?

Connect this unit to your IRSTD work

Progress and notes stay in this browser.