Module tree_shape

Module tree_shape 

Source
Expand description

2026-09-25: Spine-plus-hedge draft trees for tree speculative decoding: the tree shape, its verify-row layout and the accepted path.

Owner: model-layers (speculative). Invariants:

  • TreeShape::parse returns only shapes that pass validate: every depth holds 1..=MAX_RANK nodes, and the tree holds at most MAX_NODES.
  • TreeDraft::rows puts the root at row 0, the spine at rows 1..=L in depth order, then the hedges in the order of hedges.

A tree is a spine (the drafter’s top-1 chain) plus hedge leaves: lower-ranked siblings of spine nodes, with no children. So every node’s parent is the root or a spine node. A shape is a comma-separated list of per-depth node counts, e.g. "1,2,2,2": depth d holds one spine node and count_d - 1 hedges, and the verify width is the node count plus the root row.

Structs§

HedgeNode
2026-09-25: One hedge leaf: the drafter’s rank-rank candidate at depth.
TreeDraft
2026-09-25: A proposed draft tree for one verify step.
TreeRow
2026-09-25: One verify row. Row 0 is the root.
TreeShape

Constants§

MAX_NODES
2026-09-25: Largest node count validate accepts for the whole tree, excluding the root row.
MAX_RANK
2026-09-25: Largest node count validate accepts at one depth: the spine node plus up to three hedges.