Skip to main content

Module knobs

Module knobs 

Source
Expand description

Runtime configuration knobs.

A knob is a named, typed runtime setting — a kernel-selection toggle or a heuristic threshold. Its value is resolved, in priority order, from an explicit programmatic override, then the calling thread’s KnobScope, then the process environment, then the global values a deployment config installed (set_config_global), then a compiled-in default.

A knob declared scopable is read while a model is transformed or prepared, so a KnobScope entered around those calls tunes it for that one model. Every other knob is read elsewhere (machine detection, eval) and only takes a process-wide value.

Knobs are declared with [declare_knob!] and register themselves into a stack-wide inventory (this crate is the lowest in the stack, so linalg and everything above can declare). The inventory lets every knob be listed and documented from one place, and set through the API on targets where environment variables are unavailable (e.g. wasm).

A knob is the lowest, deployer-facing layer of configuration; it is not a substitute for settings that must travel with a model.

Re-exports§

pub use inventory;

Structs§

Knob
A declared knob. Construct via [declare_knob!] rather than directly so it is registered for listing.
KnobInfo
Type-erased description of a declared knob, collected stack-wide for listing and documentation.
KnobScope
Knob values tuned for one model: entered around the calls that transform and prepare it, they reach every scopable knob read on this thread meanwhile.

Traits§

KnobValue
A type usable as a knob value: parseable from the string sources (env / API) and renderable for listing.

Functions§

all
All declared knobs, sorted by name.
clear_str
Drop a knob’s programmatic override by name. Returns false if not declared.
list
Render all declared knobs as a human-readable list.
set_config_global
Install a process-wide value below the environment, for a deployment config. Setting a knob again to a different value fails: two configs in one process must agree on what they both set globally.
set_str
Set a knob by name from a raw string — the environment-style source, for hosts where environment variables are unavailable (e.g. wasm). Returns false if no knob by that name is declared.