Carry temporal state only within its declared stream
Separate causal feature buffers, chunk boundaries, lookahead, and reset policy so streaming predictions match the model's actual information boundary.
On this page
The question for today
What you’ll understand
- Define stream identity and discontinuities that reset temporal state.
- Compare chunked and continuous execution under an identical causal model.
- Count future-frame lookahead separately from transport and processing latency.
A streaming model can remember earlier evidence through recurrent state, cached temporal features, or convolution buffers. That memory belongs to a particular stream and execution configuration. Keeping it across chunks can preserve the intended model, while keeping it across unrelated recordings can contaminate predictions. Conversely, resetting at every network chunk can erase useful context. State handling is therefore part of the model's semantic contract, not merely a serving optimization. A useful test changes chunk boundaries while preserving the same source sequence and expected causal behavior.
Give state an identity, lifetime, and reset rule
Define a state key using the source stream, episode or session, and relevant model/preprocessing version. Also define how timestamp discontinuities, resolution changes, missing chunks, and an explicit new episode are handled. A reset may require warmup before predictions are comparable with a fully conditioned stream. Logging only a request identifier can hide state reuse between cameras or users; log the state identity and reset reason alongside the output interval.
A simple recurrence illustrates why the initial state matters. Real video systems may instead cache several past feature maps, as in MoViNets' stream-buffer design, but those buffers still represent particular preceding observations. Do not assume buffers are portable between different model weights, spatial shapes, frame cadences, or preprocessing configurations. Either validate compatibility explicitly or reset with a documented loss of context. State restoration must reproduce the configuration and prior evidence that originally defined it.
A future dependency changes when an output is available
Causal temporal operations use no future inputs relative to their declared prediction boundary. A centered temporal convolution or bidirectional attention window generally has a different contract because it consumes later evidence. For a regular verified cadence, a known right-context count implies a minimum media lookahead. Variable timestamps require the actual time difference to the last required frame instead of a universal frame-count formula. Decoder reordering, transport, batching, and computation can add further elapsed delay.
Keep media time and feature-ready elapsed time distinct when testing causality. If an output needs a frame not yet decoded and available, its earliest emission cannot precede that dependency's availability plus the remaining serial computation. A model trained on centered offline clips cannot become causal merely by calling its function on a live stream. It needs a compatible architecture and training/evaluation setup, or an explicitly delayed decision contract that reports the lookahead.
Use boundary and reset oracles rather than throughput alone
For a fixed deterministic causal model, compare one continuous execution with several chunk partitions while carrying exactly the required state. Fix evaluation mode, numerical tolerance, padding rules, and the initial state. Include one-frame chunks, a long gap, a new source, and a changed configuration. An intentional reset can change boundary predictions, so compare it with the corresponding reset oracle rather than declaring every difference a numerical bug. Recovery tests should also establish whether restored state contains all required prior context.
The optimization lab isolates dependence on an initial value without pretending to execute a video model. Reset, set both η=0.5,x₀=2, predict x₂=0.5, then take two Steps. Reset and set both η=0.5,x₀=0; the value remains zero. Each Step is one iteration. This model has no incoming frames, additive input term, stream keys, or feature buffers, so it does not implement the recurrence in the worked example. It only makes one consequence of carrying an initial condition observable.
Work it through
Expose state leaking between two recordings
A fictional scalar streaming rule is h_next=0.5h+x with reset state zero. Recording A has inputs [1,1], and unrelated recording B has inputs [0,0]. Compare correct per-recording resets with accidentally carrying A's final state into B.
Starting A at zero gives h₁=0.5×0+1=1 and h₂=0.5×1+1=1.5. That final value belongs to recording A.
A proper reset gives B states 0.5×0+0=0 and then zero again. With the leaked initial state 1.5, B instead yields 0.75 and 0.375.
Use B's expected [0,0] outputs as the negative fixture. A difference caused solely by whether A ran first demonstrates forbidden cross-recording history under this declared reset contract, even if every individual function call succeeds.
The leaked outputs [0.75,0.375] encode another recording's history. Chunk continuity within A and isolation between A and B require different state-lifetime decisions.
The living notebook
Explore the model
Interactive lab · optimization
Inspect an initial-condition difference with a scoped recurrence
Reset → set both η=0.5,x₀=2; predict x₂=0.5 and take two Steps. Reset → set both η=0.5,x₀=0 predicts zero throughout. Parameter edits retain elapsed time. This x²/2 optimization recurrence has no frames, forcing inputs, stream identities, or video-state implementation.
- Position x0
- 2
- Objective x²/2
- 2
- Iteration behavior
- Stable step
Gradient descent on f(x) = x²/2: xₙ = (1 − η)ⁿx₀. Playback advances two discrete iterations per second. Values outside |x| ≤ 4 are explicitly reported. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA carried initial value can affect later output; correct video state needs its own identity, update, and reset contract.
Pause & reason
Check your understanding
Your turn
Try it yourself
A verified constant-rate fixture runs at 25 frames/s, and an operation requires two future frames after the target frame. What is its minimum media lookahead? Would that be the complete end-to-end latency for a live source?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Count the two regular frame intervals, then distinguish media spacing from feature availability and remaining computation.
Compare with the solution
The lookahead is 2/25=0.08 s, or 80 ms. This is not the complete live latency: capture/transport, decoder dependencies, queueing, and remaining computation can add delay. For an irregular source, use the actual required-frame timestamp difference and feature-ready times instead of assuming two intervals have this duration. An advertised zero-lookahead contract would be incompatible with this operation's stated dependency set.
Keep the idea
Take it with you
- State must be keyed to its stream, configuration, and declared reset boundary.
- Future dependencies impose availability constraints even when output timestamps remain unchanged.
- Chunk-equivalence and cross-stream isolation fixtures test different state contracts.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.