Async and Hogwild! Inference

Speculative decoding (Phase 10 · 15) parallelizes tokens within one sequence. Multi-agent frameworks parallelize across whole sequences but force explicit coordination (voting, sub-task splitting). Hogwild! Inference (Rodionov et al., arXiv:2504.06261) does something else: run N instances of the same LLM in parallel against a SHARED key-value cache. Each worker sees every other worker's generated tokens instantly. Modern reasoning models — QwQ, DeepSeek-R1 — can self-coordinate through that shared cache without any fine-tuning. The approach is experimental but it opens an entirely new axis of inference parallelism that sits orthogonal to spec decode. This lesson implements a two-worker Hogwild! simulator in stdlib Python and explains why the shared-cache collaboration emerges from the existing model's reasoning abilities.

Build 1 hr Python (stdlib)

Prerequisites: Phase 10 · 12 (inference optimization), Phase 10 · 15 (speculative decoding)

#Learning Objectives

  • Describe the three common parallel-LLM topologies (voting, sub-task, Hogwild!) and name which problems each one targets.
  • State the core Hogwild! setup: multiple workers, one shared KV cache, emergent coordination via self-prompting.
  • Compute the wall-time speedup of Hogwild! as a function of worker count N, task-level parallelism p, and coordination overhead c.
  • Implement a two-worker Hogwild! simulator on a toy problem and observe the emergent task division.
Full Access lesson

Keep going. The rest of this lesson is one step away.

Unlock all 503 lessons, video, code, quizzes and every future update. Pay in your own currency with Paystack.

The text and code of this lesson are based on AI Engineering from Scratch by Rohit Ghumare, MIT licensed.