fix(forge): honor quantize:false module overrides - #281
Open
shiftedx wants to merge 1 commit into
Open
Conversation
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
Forge's mixed-precision converter currently turns every matching
module_overridesentry into a quantization-parameter dictionary. An entry such as:{"suffix": "linear_attn.in_proj_a", "quantize": false}therefore ignores the exclusion and silently falls through to the default 8-bit override values.
This change makes
build_predicatereturn the literalFalsevalue expected bymlx_lm.utils.quantize_modelwhen a matching override explicitly sets"quantize": false. The matched module stays at source precision; ordinary mixed-precision overrides, layer filtering, first-match precedence, and body fallback behavior are unchanged.The converter docstring now records the exclusion contract, and the regression test verifies both the excluded path and an unmatched body path.
Why this matters
Hybrid recipes use source-precision exclusions for numerically sensitive projections while quantizing the rest of the trunk. Before this fix, those recipes completed without an error but produced q8 tensors for the modules that were intended to remain BF16, changing both model size and the requested quality/performance tradeoff.
Verification
uv run --frozen --extra dev ruff check mtplx/commands/forge_mixed_convert.py tests/test_forge_mixed_convert.py— passeduv run --frozen --extra dev pytest -q tests/test_forge_mixed_convert.py— 10 passedMTPLX_CONFIG=<isolated-empty-path> uv run --frozen --extra dev pytest -q tests/test_no_mlx_imports.py tests/test_public_cli.py tests/test_runtime_kpis.py— 268 passeduv run --frozen --extra dev python -m build— sdist and wheel builtscripts/hygiene_scan.sh— passedscripts/fresh_venv_smoke.sh— passedA real Qwen 3.8 27B conversion was also structurally inspected: all 96 requested recurrent-projection exclusions remained BF16, none gained quantization scale/bias tensors or quantization-config entries, and the other 234 mixed-precision overrides were still applied.