WHAT CHANGES?

What changes, and why?

Compare responsibilities and state across lessons, then inspect their framework pseudocode.

s01

Follow a request through the engine

An engine round is a coordination boundary, not exactly one token for one request.

Read lesson
s03

Connect execution state with the cache

Request state, processed positions, and cache ownership must advance together.

Read lesson

Teaching excerpt diff

RemovedAdded
s01_request_flow.pys03_kv_cache.py
−# Framework pseudocode, not an executable implementation.
−for request in inputs:
−    llm_engine.add_request(request)
+# Framework pseudocode for request-owned cache state.
+state = sequence_table[request_id]
+blocks = block_manager.resolve(state.block_table)
+metadata = build_input_metadata(
+    query_tokens=planned_tokens,
+    cached_positions=state.computed_positions,
+    cache_blocks=blocks,
+)
+worker.execute_model_step(metadata, cache_engine.cache)
  
−while llm_engine.has_unfinished_requests():
−    ready_outputs = llm_engine.step()
−    collect(ready_outputs)
− 
−collect(llm_engine.flush_inflight_reqs())
− 
−# Inside a scheduled round:
−# Scheduler -> Worker -> ModelRunner -> sampling
−# -> ready state updates and request outputs
−# A round may cover several requests and token positions.
+# Execution consumes input positions and updates cache state.
+# A selected token becomes input only if the request continues.
+# Reclaim blocks only when their references are no longer needed.

The comparison uses framework reading pseudocode to explain responsibilities and state dependencies.