Module target_defaults

Module target_defaults 

Source
Expand description

2026-09-25: The compiled target’s serving defaults, resolved against the environment: the target’s declaration first, a METRALE_* override second.

The declaration is metrale_kernels::TARGET_DEFAULTS, which build.rs bakes from the [defaults] table of the compiled target’s kernels/<hw>/HARDWARE.toml. A target with no table gets build_defaults::baseline (crates/kernels/build_defaults.rs).

§The override grammar (boolean levers, resolve_toggle)

inputmeaning
variable absentthe target’s declaration
0, false, off, no (any case, trimmed)off, from the environment
any other value, including emptyon, from the environment

Two presence-gated kill switches outrank both the declaration and the positive variable, whatever their value: METRALE_NO_DECODE_SPLIT_SILU (decode_split_silu) and METRALE_NO_ATTN_DECODE_BATCH (attn_ncol_gemv). The head band (resolve_batchm_max), the W8A8 row caps (resolve_max_m) and the split-K policy have their own rules, documented on their resolvers.

§One resolution, one log line

resolved is the process-wide resolution. The dispatch sites read it, and metrale-server logs it once as summary_line, which tags values that came from the environment with (env). ModelLevers resolves decode_split_silu itself, from declared through the same resolve_toggle.

§Adding a lever

A lever needs all of: the field in metrale_kernels::TargetDefaults (crates/kernels/src/target_defaults.rs), the parse arm in crates/kernels/build_defaults.rs, the row in every kernels/<hw>/HARDWARE.toml that has a [defaults] table, the TargetLevers field and its arm in resolve, its entry in format_levers, and a test. parse_defaults panics on an unknown key, so a row without its parse arm fails the build.

Owner: model-layers ops (target serving defaults). Invariants:

  • resolved keeps its first completed resolution; later calls return that table.
  • A value is tagged Source::Env exactly when an environment variable decided it.

Structs§

Resolved
2026-09-25: A resolved lever and where it came from.
TargetLevers
2026-09-25: Every serving lever this target declares, resolved against the environment.

Enums§

Source
2026-09-25: Where a resolved value came from.

Constants§

BASELINE_BATCHM_MAX
2026-09-25: The head band a target without a [defaults] table gets. build_defaults::baseline (crates/kernels/build_defaults.rs) repeats it as a literal. target_defaults_tests::the_baseline_band_is_the_frozen_one checks this constant against DENSE_GEMV_BATCHM_DECODE_MAX_M and the test file’s copy of the gb10 declaration; gb10_declares_the_baseline_apart_from_the_measured_w8a8_ceiling (crates/kernels/tests/target_defaults.rs) checks the real gb10 declaration against the literal.

Functions§

declared
2026-09-25: The baked declaration this binary carries, for callers that resolve from their own inputs (ModelLevers).
format_levers
2026-09-25: summary_line over a table the caller already has. Pure, so tests can format any target’s line without touching the process environment or the cached resolved table.
resolve
2026-09-25: The whole table, as a pure function of a declaration and a variable lookup, so tests resolve any target’s table without touching the process environment.
resolve_batchm_max
2026-09-25: The BF16 decode head’s batched-GEMV band: the widest m that takes dense_gemv_batchm. Wider batches take a tile GEMM that reassociates the reduction, so moving the edge changes the head’s output bits.
resolve_max_m
2026-09-25: Upper M for the W8A8 dense-FFN prefill, per projection shape.
resolve_toggle
2026-09-25: The override grammar for a boolean lever, as a pure function.
resolved
2026-09-25: The process-wide resolution, computed on the first call and cached.
summary_line
2026-09-25: target defaults (<hw>): …, the one line naming every resolved value and which came from the environment. Built here so the line and the resolution are the same code.