speculators.models.utils
Functions:
-
flatten_rope_parameters–Flatten nested per-layer-type
rope_parametersfor rotary embedding init. -
resolve_draft_intermediate_size–Resolve a dense draft MLP
intermediate_sizefrom a verifier config.
flatten_rope_parameters
Flatten nested per-layer-type rope_parameters for rotary embedding init.
Models like Laguna store separate rope configs per layer type (sliding_attention, full_attention). Rotary embedding classes expect a flat dict with rope_type/rope_theta at the top level. This helper selects the sliding_attention variant when nested parameters are detected and returns a deep-copied config; otherwise returns the original unchanged.
Source code in speculators/models/utils.py
resolve_draft_intermediate_size
Resolve a dense draft MLP intermediate_size from a verifier config.
The draft is an independent small dense decoder, so its FFN width is a design choice rather than something to reconcile with the verifier's routed capacity:
- Dense verifiers expose
intermediate_sizedirectly; the draft mirrors it. - MoE verifiers have no dense
intermediate_size(their FFN is a routed set of small experts), so the draft falls back to the widely used3 * hidden_sizegated-MLP ratio -- the Qwen3 dense convention that the dflash draft decoder follows. Pass--draft-configto set it explicitly instead.
Raises:
-
ValueError–when the verifier config exposes neither
intermediate_sizenorhidden_size(degenerate config; pass--draft-config).