Skip to main content

Module round_stream

Module round_stream 

Source
Expand description

ROUND-STREAM: the model-generic device machinery for pre-issued M-round speculative bursts with zero per-round host readbacks (extracted from the qwen spec loop 2026-07-12 so the gemma/next-model loops reuse it instead of re-growing their own).

The pieces that live here are pure device-buffer plumbing — every model-specific thing (the draft-chain graph, the verify trunk, commit semantics) stays in the caller:

  • StreamBufs: the per-burst device buffers (verify tokens, break, pending, ring, accept counters, device position) sized from (k, m_rounds).
  • kv_len_ptr_table: the per-layer kvl.len_d pointer table the device rollback kernel walks (pointers are stable for the cache’s lifetime — cache.rs note).
  • drain_ring: the one host sync per M rounds — reads the ring and appends tokens.

The kernels these feed (spec_accept_greedy_dc, spec_ring_commit, spec_rollback_stream, spec_seed_gather, spec_assemble_verify) are already model-generic in lib.rs; this module is the buffer/lifecycle half.

Structs§

StreamBufs

Functions§

kv_len_ptr_table
Per-layer kvl.len_d device-pointer table (+ the position counter appended when pos_ctr is given) for spec_rollback_stream. Pointers are stable for the cache’s lifetime; 0 marks layers without KV (linear-attention / KV-shared).