quantization chooses the precision for each layer, and the top-level rules section selects execution kernels. After loading an unquantized FP16, BF16, or FP32 checkpoint, the system applies PTQ to the weights according to your configuration.
Load a kernel policy
Save the configuration in the next section askernel-policy.yaml. In a Python environment with PhyAI and humming-kernels installed, specify the file through an environment variable:
run_model.py with your model’s launch script and keep its existing arguments, including the checkpoint path. Run the model in BF16 or FP16.
In Python, pass the configuration containing KernelConfig to EngineArgs(config=config):
kernel_policy and config.kernel.config_path.
PHYAI_KERNEL_CONFIG overrides Python and server YAML settings when the Engine starts. Clear an old environment setting before switching to either of those entry points:
Customize quantized layers and precision
The following complete policy uses INT4 for MLP weights and INT8 for attention projection weights, while keeping layer 0 at its original precision. The example assumes layer prefixes start withmodel.layers.<layer-number>. Replace them with your model’s prefixes.
quantization.rules are checked from top to bottom and stop at the first match. Put exclusions first. scheme: null skips a layer, and default: null keeps the configured precision for unmatched layers. PTQ during loading currently uses method: rtn and stage: load.
Each quantization rule’s match must use exactly one selector:
These names are the
prefix values passed when creating PhyAI Linear layers. They differ from checkpoint tensor keys and may differ from named_modules() paths. Check where your model creates its Linear layers to confirm their prefixes. If the model fuses q_proj/k_proj/v_proj, match the fused qkv_proj layer. Likewise, match gate_up_proj for fused gate_proj/up_proj weights.
Common precision fields:
Common combinations are listed below.
null means input: null, which keeps BF16/FP16 activations. For A8, also set granularity: per_channel and dynamic: true.
For example, replace a rule’s
weight and input fields with these settings to use FP8 E4M3 block A8:
quantization, create a new Engine and reload the weights. Editing the YAML does not change the precision of an existing instance. If you omit the entire quantization section, the system uses the checkpoint and model’s existing configuration. Load an already quantized checkpoint through its existing loading path.
Customize execution kernels
The top-levelrules section configures execution kernels. You can limit candidates by operation, role, dtype, device, and call shape. For example, append this attention rule to the top-level rules list in the file above:
All fields in a kernel’s
match must match. Common examples include dtype.input: bf16, quant.format: int4, device.arch: ">=sm80", and shape.M: "<=64". Here, role is an operation role. Layer prefixes belong in quantization rules; kernel match does not accept their glob or regex selectors.
Each ordinary kernel rule must choose one candidate setting:
restrict_to: A full kernel ID or an ID wildcard pattern, such as"humming.gemm.*".prefer: An ordered list of full kernel IDs, such as[flashinfer.gemm.bf16, torch.gemm.bf16]. Other ordinary implementations are excluded from the candidates; compatible reference fallbacks are allowed by default.
defaults: {fallback: error} at the top level of the policy. Humming quantized weights require a compatible Humming kernel. Forcing an ordinary BF16 GEMM for them will fail.
params passes parameters that the selected kernel supports. For example, add this to the Humming rule:
quantization. Changing only prefer, restrict_to, or params does not requantize the weights.
Check the configuration
List the GEMM kernel IDs in your installed version:INT8. Changing the layer number to 0 returns None. Parsing does not verify checkpoint contents, GPU capabilities, or model accuracy. Follow it with loading and inference through your normal model entry point.

