How a Linear picks its precision
Every Linear picks one physicalspec at construction. The order is fixed in LinearBase.__init__ (phyai/src/phyai/layers/linear/layers.py): four options, highest priority first.
Most of the time you only meet option 3: the plan is built automatically when the checkpoint loads, and you pass nothing.
Automatic loading from a checkpoint
load_quant_plan(checkpoint_dir) (layers/quant/active.py) reads two places:
quantization_configinconfig.json, falling back tocompression_config- a standalone
hf_quant_config.json(used by ModelOpt)
None and the model stays bf16. If it finds one, it hands off to an importer to recognize the framework and build the plan. Three are recognized today:
- HF fp8
- compressed-tensors
- NVIDIA ModelOpt
quant_method is fp8 in config.json:weight_block_size present means block granularity; absent means per-channel. Any activation_scheme other than "static" means dynamic activation quantization. Layers listed in ignored_layers (or modules_to_not_convert) are skipped and stay bf16.Hand-writing a QuantPlan
When automatic loading is not enough, you can assemble the rule table yourself. AQuantPlan is an ordered sequence of Rules plus a fallback default. Each Rule pairs a Matcher with a QuantScheme; a scheme of None means skip (stay bf16).
Matcher supports four kinds of match:
resolve walks top to bottom; the first matching Rule wins, and if none match it uses default.
Passing a scheme to a single Linear
To change one layer without building a whole table, passscheme straight to that Linear. It skips the plan and goes directly to materialize:
How scales are loaded
The scale parameters a physical spec allocates (weight_scale, input_scale, weight_global_scale) get their hf_keys and loader attached by LinearBase._attach_optional_scales, marked optional. A pre-quantized checkpoint’s scales then load automatically, and a plain bf16 checkpoint that lacks them does not error on the missing keys.
