Repository navigation
Match a skip-list entry from the start only up to a module boundary - #49771
Conversation
0489006 to
1d88f2d
Compare
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
1d88f2d to
a063a21
Compare
a063a21 to
552b916
Compare
| """Return False if an entry of `patterns` covers `full_name`, True otherwise. | ||
|
|
||
| An entry covers the names it matches from the start up to a module boundary, and the names ending with it. | ||
| So `"model.layers.1"` covers `model.layers.1.mlp` but not `model.layers.10`. | ||
| """ | ||
| if patterns is None: | ||
| return True | ||
|
|
||
| # We should avoid converting in the following situations: | ||
| # 1. The pattern appears as a prefix followed by a dot in `full_name` | ||
| # (e.g., "model.decoder.layer.11." matches "model.decoder.layer.11.attn.weight"). | ||
| # 2. The pattern matches `full_name` exactly or via regex | ||
| # (e.g., "lm_head" matches "lm_head"; "model.decoder.layer.*" matches "model.decoder.layer.11.attn.weight"). | ||
| # 3. `full_name` ends with the pattern | ||
| # (e.g., "fc1" matches "model.decoder.layers.23.fc1"). |
There was a problem hiding this comment.
why a new docstring, shouldnt we just adjust the existing cases instead?
There was a problem hiding this comment.
fair, restored the original comment block and adjusted the cases for the boundary rule, docstring's gone
There was a problem hiding this comment.
why is the test in mxfp4? do we not have a general utils test file?
There was a problem hiding this comment.
weirdly that's the test checking it, and no quantization utils test file, i can create one
There was a problem hiding this comment.
moved it to a new tests/quantization/test_quantizers_utils.py with main's cases + the new ones, out of mxfp4
should_convert_module matched an entry from the start of the module name with
no boundary after it, so "model.layers.1" also skipped model.layers.10 to 19,
and Qwen3.8-27B-FP8's router entry "mlp.gate" also skipped the quantized
mlp.gate_proj (its FP8 weight then reached a bf16 linear). A match from the
start now has to end on a "." it consumed, or right before a "." or the end
of the name, which keeps regex entries that carry their own boundary such as
"^model\.audio_tower(?:\.|$)". The endswith clause Hub skip-lists rely on
("gate" covering shared_expert_gate) is unchanged.
Supersedes #47990, which anchors with "$" and so stops matching such regex
entries.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
446dc5d to
18d5d46
Compare
|
[For maintainers] Suggested jobs to run (before merge) run-slow: mxfp4 |
What.
should_convert_modulematched a skip-list entry with a barere.match, so"model.layers.1"also skippedlayers 10 to 19. A match from the start now ends at a module boundary. An entry still covers its sub-tree, a regex
with its own boundary still works, and a name still covers the names ending in it (
"gate"coversshared_expert_gate).Why we need it. Loading real FP8 checkpoints with the fine-grained FP8 support (#49777) blocked on it.
Qwen3.8-27B-FP8 lists its routers as
mlp.gate, which also skipped the quantizedmlp.gate_proj. Its FP8 weightthen reached a bf16 linear. Every quantizer that takes
modules_to_not_convertuses this function, so main has thesame bug, and any skip-list naming a layer by index hits it too. The key is wrapped in a group so the boundary applies
to every alternative of a key with
|.Supersedes #47990, which anchors with
$and so stops matching regex entries that carry their own boundary, such as^model\.audio_tower(?:\.|$).Behaviour change. A skip-list entry no longer covers longer siblings (
model.layers.1vsmodel.layers.10,mlp.gatevsmlp.gate_proj).Depends on. main. First PR of the fine-grained stack.
How tested.
tests/quantization/test_quantizers_utils.py, a new general test file.test_should_convert_modulemoves there from the MXFP4 suite, with the new cases.
The comments and docstrings that say why each change exists are there for readability. Feel free to ask for any of them to go if it's self-evident.
🤖 Generated with Claude Code