Module resolve

Module resolve 

Source
Expand description

2026-09-25: Kernel-target resolution: which compiled target serves a checkpoint. The rules are pure functions over ResolveCandidates, so they are tested without compiled kernels.

(model_type, hidden_size) alone can collide: kernels/gb10/qwen3.6-27b and kernels/gb10/qwen3.8-27b both declare (qwen3_5, 5120).

The rules:

  1. Exact (model_type, Some(hidden_size)) declarations are tried before wildcard (model_type, None) ones.
  2. Within the first tier that matches, one target name wins outright.
  3. Several names are a collision, broken by match_names: a candidate survives when one of its needles is a case-insensitive substring of a checkpoint reference (HF id, --model-name, resolved model dir). Exactly one surviving name wins.
  4. Zero or several survivors are TargetResolveError::Ambiguous; the wildcard tier is not tried.
  5. --kernel-target <name> pins a target and skips the tie-break, but the pinned target must declare the checkpoint’s model_type for this hidden_size or a wildcard (TargetResolveError::PinIncompatible).

Owner: kernels crate. Invariants:

  • Resolution never chooses between different target names by iteration order: a collision it cannot break is an error.
  • build.rs (validate_collision_match_names) panics when a target in a collision of the build’s targets has no match_names.

Structs§

ResolveCandidate
2026-09-25: The parts of one compiled target that resolution reads, borrowed so production can wrap TargetPtxSets without copying blobs.

Enums§

TargetResolveError
2026-09-25: Why resolution could not choose a target.

Functions§

ptx_for_config
2026-09-25: The compiled target that serves a checkpoint, by the module’s rules: resolve_pinned when pinned_target (--kernel-target) is set, else resolve_target over all_ptx_sets(). Ok(None) when no compiled target declares the pair.
ptx_for_exact_target
2026-09-25: The compiled target with exactly this (model, quant) identity, or None. For callers that already know the resolved target, such as the dashboard’s kernel table, which looks up the target serve published.
resolve_pinned
2026-09-25: Resolve a --kernel-target pin, matched case-insensitively against target names. The first same-named candidate that declares the checkpoint’s model_type with this hidden_size or a wildcard wins; the tie-break is not consulted.
resolve_target
2026-09-25: Which candidate serves (model_type, hidden_size) for a checkpoint identified by model_refs: its index, Ok(None) when no tier declares the pair, or TargetResolveError::Ambiguous when a collision does not break to exactly one name.