Skip to content

armgit / Soup

Public Imported from GitHub
0

Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.

fix(autopilot): budget mxfp4 prequantized base as dequantized bf16 (#1653) (#1656)

Nurkhan Esenbekb18c50ca3636
diff --git a/changelog.d/0.75.1/1656.fixed.md b/changelog.d/0.75.1/1656.fixed.md
new file mode 100644
index 00000000..fc1f2f60
--- /dev/null
+++ b/changelog.d/0.75.1/1656.fixed.md
@@ -0,0 +1 @@
+- **Budget `mxfp4` bases as dequantized bf16 in autopilot (#1653 by @kok-o in #1656).** `decide_quantization` now enforces the VRAM budget for `mxfp4` pre-quantized models which dequantize on load to bf16 (2 bytes per parameter), preventing generation of configurations that cannot load on the target GPU budget.
diff --git a/docs/performance-and-quantization.md b/docs/performance-and-quantization.md
index c81b347a..07a7482a 100644
--- a/docs/performance-and-quantization.md
+++ b/docs/performance-and-quantization.md
@@ -1367,7 +1367,7 @@ soup deploy autopilot --target rtx-4090-24gb \
--measure-candidates 4bit,gptq,awq
```
-Autopilot also detects pre-quantized bases automatically — `TheBloke/Llama-2-7B-Chat-GPTQ` is recommended `gptq` instead of stacking 4-bit on top. Detection runs against the base-model name regex AND any local `config.json`'s `quantization_config.quant_method`. Out-of-cwd model paths are silently skipped (soft-probe semantics).
+Autopilot also detects pre-quantized bases automatically - `TheBloke/Llama-2-7B-Chat-GPTQ` is recommended `gptq` instead of stacking 4-bit on top. Detection runs against the base-model name regex AND any local `config.json`'s `quantization_config.quant_method`. Out-of-cwd model paths are silently skipped (soft-probe semantics). A detected `mxfp4` base is budgeted as the bf16 model it loads (2 bytes per parameter), and Autopilot refuses a `--gpu-budget` below that.
AWQ and GPTQ export are deprecated and will be removed in the next release: both upstream projects (AutoAWQ and AutoGPTQ) are archived and neither extra can be installed next to `[train]`. Until then `soup export --format awq` and `--format gptq` work as before and start with a `Deprecated:` notice that names the formats to move to (`gguf`, `onnx`, `tensorrt`, `bitnet`, `tq1_0`).
diff --git a/src/soup_cli/autopilot/decisions.py b/src/soup_cli/autopilot/decisions.py
index dc093a16..b2e87c4e 100644
--- a/src/soup_cli/autopilot/decisions.py
+++ b/src/soup_cli/autopilot/decisions.py
@@ -242,7 +242,20 @@ def decide_quantization(
don't silently stack a fresh BNB 4-bit on top of an already-quantized base.
"""
if prequantized is not None:
- return _validate_prequantized(prequantized)
+ canonical = _validate_prequantized(prequantized)
+ if canonical == "mxfp4":
+ from soup_cli.utils.hardware_fit import _BYTES_PER_PARAM_BY_QUANT
+
+ bytes_per_param = _BYTES_PER_PARAM_BY_QUANT.get("mxfp4", 2.0)
+ model_gb_dequant = model_params_b * bytes_per_param
+ if vram_gb < model_gb_dequant:
+ raise ValueError(
+ f"Model too large for VRAM budget: {model_params_b}B model "
+ f"in mxfp4 is dequantized on load and needs at least "
+ f"{model_gb_dequant:.1f}GB in bf16, got {vram_gb:.1f}GB. "
+ "Try a smaller model or increase --gpu-budget."
+ )
+ return canonical
# Rough: 1 param byte each in 8bit, 0.5 in 4bit, 2 in fp16
model_gb_fp16 = model_params_b * 2.0
diff --git a/tests/test_autopilot.py b/tests/test_autopilot.py
index 51d54657..19908bb2 100644
--- a/tests/test_autopilot.py
+++ b/tests/test_autopilot.py
@@ -130,6 +130,25 @@ class TestDecisionEngine:
with pytest.raises(ValueError):
decide_quantization(model_params_b=70.0, vram_gb=4.0)
+ def test_mxfp4_base_is_budgeted_as_bf16(self):
+ from soup_cli.autopilot.decisions import decide_quantization
+
+ with pytest.raises(ValueError, match="Model too large for VRAM budget"):
+ decide_quantization(20.0, 16.0, prequantized="mxfp4")
+ assert decide_quantization(20.0, 48.0, prequantized="mxfp4") == "mxfp4"
+ assert decide_quantization(20.0, 16.0, prequantized="gptq") == "gptq"
+
+ def test_mxfp4_budget_is_two_bytes_per_parameter(self):
+ from soup_cli.autopilot.decisions import decide_quantization
+
+ # 20B x 2 bytes = 40 GB: just under it refuses, exactly at it passes.
+ with pytest.raises(ValueError, match=r"dequantized on load.*40\.0GB in bf16"):
+ decide_quantization(20.0, 39.9, prequantized="mxfp4")
+ assert decide_quantization(20.0, 40.0, prequantized="mxfp4") == "mxfp4"
+ assert decide_quantization(20.0, 40.0, prequantized="MXFP4") == "mxfp4"
+ with pytest.raises(ValueError, match=r"dequantized on load.*40\.0GB in bf16"):
+ decide_quantization(20.0, 39.9, prequantized="MXFP4")
+
def test_decide_quantization_8bit_tier(self):
from soup_cli.autopilot.decisions import decide_quantization