Skip to main content

load_drafter

Function load_drafter 

Source
pub fn load_drafter(
    e: &Engine,
    dir: &Path,
    flag: &str,
    n_trunk: usize,
    n_embd: usize,
    n_vocab: usize,
) -> Result<DflashDrafter, String>
Expand description

Load a DFlash2 drafter named by flag from dir, validating every contract that binds a drafter to a TARGET — family-agnostic, because each one is a property of the pair, not of the family:

  • the checkpoint is a DFlash2DraftModel (the selector family is the only draft source this seam serves);
  • cfg.hidden == n_embd (the drafter consumes the target’s features and projects through the target’s embed/lm_head);
  • cfg.target_layer_ids name valid trunk layers;
  • cfg.mask_token_id is inside the target vocab.

A set flag that cannot load is a LOUD failure, never a silent plain fallback. Every error is prefixed {flag}={dir} so the operator sees the flag they typed; the glm5 call site’s message bytes are unchanged by construction.