Conversation
…with explicit block FP8 Quark can export a model whose global scheme is MXFP4 while pinning individual layers to block-quantized FP8 in `layer_quant_config`. Two things stopped those layers from being served correctly. `apply_weight_name_mapper` rewrote only `exclude_layers`, so `layer_quant_config` and `kv_cache_group` kept the checkpoint's own weight names. Every lookup for a pinned layer missed and silently fell back to the global MXFP4 config, which loads the wrong precision without raising. `_find_matched_config` also could not express "no explicit entry", because it returned the global config on a miss. Split out `_find_matched_layer_config`, which returns None instead, and dispatch layers that carry an explicit block-FP8 entry to `Fp8LinearMethod` / `Fp8MoEMethod`. A fused module whose shards are only partially specified now raises rather than picking one shard's scheme. `should_ignore_layer` additionally honors a direct name match before expanding packed mappings, so a checkpoint that ships an already-fused vision `qkv` and lists that fused name in `exclude` is respected.
Contributor
Author
|
Closing as superseded. The config-resolution work here is now carried by #38546: routing The Between them the MXFP4 checkpoint resolves correctly, so there is nothing left here that is not covered. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Quark can export a model whose global scheme is MXFP4 while pinning individual layers to block FP8 in
layer_quant_config.apply_weight_name_mapperrewrote onlyexclude_layers, so that dict kept the checkpoint's own weight names, every lookup missed, and the layer silently fell back to global MXFP4 — wrong precision, no error._find_matched_configcould not express "no explicit entry" either, because a miss returned the global config. This splits out_find_matched_layer_config, which returnsNone, and routes pinned layers toFp8LinearMethod/Fp8MoEMethod.Resolved scheme for
amd/GLM-5.3-Flash-Quark-MXFP4, queried with runtime layer names:model.layers.7.self_attn.q_a_projfp4per_groupfp8_e4m3per_block[128,128]model.layers.45.mlp.experts.7.up_projfp4per_groupfp8_e4m3per_block[128,128]model.layers.3.mlp.experts.0.up_projfp4per_groupfp4per_groupvisual.blocks.0.attn.qkv_projAll 924
layer_quant_configentries in that checkpoint are block FP8.Scope
Quark checkpoints only, no hardware gate. Resolution is unchanged for a checkpoint with no
layer_quant_configand for a model defining nohf_to_sglang_mapper: the new helper returnsNoneand the wrapper falls back to the global config exactly as before. It does change for an existing Quark checkpoint that pins layers toper_blockFP8 — those now reach the FP8 methods instead of the Quark scheme, which is the intent. Other quantization backends are untouched.#38546 owns the MXFP4 MoE weight and runner path; this PR only decides which quantization method each layer is given.
layer_quant_confignames some but not all shards of one fused moduleshould_ignore_layerdirect-name matchexcludeentry names an already-fused module, e.g. a pre-fused visionqkvkv_cache_grouprouted through the mapperhf_to_sglang_mapperand the checkpoint sets that groupTest plan
The resolution table above isolates this PR as the single variable; it and the companion model-side PR #38999 are needed together, so accuracy is for the stack. Both rows below differ only in the checkpoint.
rocm/sgl-dev:v0.5.19-rocm720-mi35x-20260909, AITER4ad99832main480b14eda+ #38541–#38547 + #38999--thinking, temperature 1.0, top-p 0.95, max 4,096 output tokenszai-org/GLM-5.3-Flash, block FP8amd/GLM-5.3-Flash-Quark-MXFP4MXFP4 lands 0.61 points below block FP8, one pass each — at the edge of this model's run-to-run spread rather than inside it: six reference runs spanned 96.82% to 97.35%, and #36607 measured 97.19% for this checkpoint at TP4. Read it as parity pending a repeat pass, not a demonstrated regression.
test_quark_config.pyandtest_quark_utils.py: 26 passed.isort,blackand Ruff clean.