Crate metrale_kernels

Crate metrale_kernels 

Source
Expand description

2026-09-25: The compiled kernel registry: the kernel blobs build.rs embeds per target, and the per-model sampling and behaviour defaults baked from each target’s MODEL.toml.

Each compiled target is a TargetPtxSet keyed by its KernelTarget (arch, model, quant). ptx_modules(), all_ptx_sets(), TARGET_DEFAULTS and TARGET_SM_COUNT are generated by build.rs into OUT_DIR/target_ptx.rs from the kernels/<hw>/<model>/<quant>/ directories that METRALE_TARGET_HW, METRALE_TARGET_MODEL (default *) and METRALE_TARGET_QUANT (default nvfp4) select.

Owner: kernels crate. Invariants:

  • ModelBehavior::default() and the build-time [behavior] parse share the constants in behavior_defaults.rs.

Re-exports§

pub use resolve::ResolveCandidate;
pub use resolve::TargetResolveError;
pub use resolve::ptx_for_config;
pub use resolve::ptx_for_exact_target;
pub use attn_splitk::MAX_DECODE_SPLITS;
pub use attn_splitk::SplitkPolicy;

Modules§

attn_splitk
2026-09-25: Paged-decode attention launch geometry: the split-K count, the split-K workspace size and the GQA-packed kernel gate, as pure functions of configuration.
resolve
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.

Structs§

DflashConfig
2026-09-25: A target’s DFlash drafter pairing, from MODEL.toml [dflash] (parse_dflash in build_parse.rs). The section requires draft_model; the other keys default as noted.
ModelBehavior
2026-09-25: Model-specific behaviour flags from MODEL.toml [behavior], parsed at build time by build_parse_behavior.rs. “Default” below is the value of an absent key, which equals ModelBehavior::default().
ModelTypeMatch
2026-09-25: One (model_type, hidden_size) pair a kernel target supports, from MODEL.toml [[model_types]].
SamplingCategory
2026-09-25: One MODEL.toml [sampling.<category>] table, parsed by build_parse.rs (parse_sampling_presets). An absent table, or an absent key, takes the value SamplingCat::default() gives in build.rs.
SamplingPresets
2026-09-25: Model-specific sampling presets from MODEL.toml [sampling.*], one per category.
TargetDefaults
2026-09-25: One compiled target’s serving defaults. A const that build.rs writes into OUT_DIR/target_ptx.rs and lib.rs include!s, so crate::TARGET_DEFAULTS is known at compile time.
TargetPtxSet
2026-09-25: One compiled kernel target: its KernelTarget identity, kernel blobs and MODEL.toml declarations.

Constants§

DECODE_DOMAIN
2026-09-25: Domain separator mixed with the model fingerprint to form the SSM decode-ring cold-tier namespace (derive_decode_ns_salted in metrale-model-engine), which keeps decode keys apart from other key spaces derived from the same fingerprint.
DECODE_ROLLBACK_RING_SLOTS
2026-09-25: Deepest per-sequence decode-rollback ring (boundary SSM-state snapshots): the default depth, the top of the auto-fit ladder, and the largest value --ssm-decode-ring-slots accepts. A model without SSM layers gets no ring.
DEFAULT_EFFORT_CAPPED_AT_CEILING
2026-09-25: Default [behavior].effort_capped_at_ceiling: whether the qualitative reasoning_effort levels are clamped at E (max_thinking_budget, or --max-thinking-budget).
DEFAULT_MAX_INTER_TOOL_PROSE
2026-09-25: Default [behavior].max_inter_tool_prose: the cap on free-text tokens between tool calls on a tool request. 0 is reserved: the runtime resolver (resolve_max_inter_tool_prose) maps it to “guard disabled”. A model can pin a tighter bound in its MODEL.toml, as kernels/strix/qwen3.6-35b-a3b does with 384.
DEFAULT_MAX_THINKING_BUDGET
2026-09-25: Default [behavior].max_thinking_budget: the anchor E of the reasoning_effort ladder and the budget of a thinking-on request that names none.
KERNEL_SET_HASH
2026-09-25: Hash of the generated target_ptx.rs text (content_hash in build.rs), emitted as the METRALE_KERNEL_SET_HASH rustc-env on both the compiling and the skip-stub path. Reading it here with env! ties this crate’s build to the generated file’s content.
ROLLBACK_RESTEER_CAP
2026-09-25: Most watchdog-triggered rollbacks one sequence may perform; at this count rollback_to_boundary declines and the watchdog ends the response instead of re-steering.
TARGET_CLOSURES
2026-09-25: What each kernel target in this binary was compiled from, as JSON: a map of "hardware/model/quant" to {hash, arch, compiler, flags}, computed by build.rs’s closure_attestation. The benchmark record copies it (bench_record.rs, with_closure), so a record attests to the binary’s sources rather than to the working tree.
TARGET_DEFAULTS
TARGET_SM_COUNT
Streaming multiprocessors on the hardware this binary’s kernels were built for, from kernels/<hw>/HARDWARE.toml [hardware] sm_count.

Functions§

all_ptx_sets
available_targets
2026-09-25: Every compiled kernel target, one entry per target (all_ptx_sets()); empty under the METRALE_SKIP_BUILD stub.
metallib_modules
ptx_for_model
2026-09-25: The first compiled target whose model name contains needle (case-sensitive), or None.
ptx_modules