Repository navigation
feat(quantization): add builtin one-click model quantize CLI pipeline - #2466
Open
presentyourlove wants to merge 1 commit into
Open
presentyourlove wants to merge 1 commit into
presentyourlove wants to merge 1 commit into
Conversation
Introduce 'exo quantize <model-id> --bits [1|1.58|2]' CLI command pipeline with dynamic layer sensitivity protection, SmoothQuant activation scaling calibration, and automatic Exo model card (.toml) generation, enabling offline model quantization without third-party dependencies.
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.
Description
This PR implements Frontier Dimension 1.1: Built-in One-Click Model Quantization CLI (
exo quantize), providing an end-to-end local quantization pipeline without external tooling dependencies.Background & Motivation
Deploying extreme low-bit models on edge devices typically relies on pre-quantized community weights (e.g. GGUF or MLX weights on Hugging Face). When users wish to serve newly released foundation models or proprietary fine-tuned checkpoints, obtaining high-quality ultra-low-bit representations is a major friction point.
With
exo quantize <model-id> --bits [1|1.58|2] --output <dir>, users can quantize any model locally. The pipeline automatically analyzes architectural sensitivity (protecting critical attention output and gate layers), calibrates activation outliers via SmoothQuant, and auto-generates registered Exo.tomlmodel cards for immediate cluster inference.Key Changes
Quantization CLI Types & Reports (
src/exo/shared/types/quantize_cli.py):QuantizationConfig: Encapsulates model ID, bit depth (1-bit, 1.58-bit, 2-bit), calibration samples, and layer protection toggles.LayerSensitivityRecord&QuantizationReport: Records per-layer sensitivity classification and final compression metrics.Quantization Compiler & Calibration Engine (
src/exo/worker/engines/quantization/quantize_compiler.py):ModelSensitivityAnalyzer: Automatically detects critical backbone layers (embed_tokens,lm_head,norm) and sensitive projection heads (o_proj,gate_proj), preserving them at FP16.SmoothQuantCalibrator: ImplementsExoModelCardGenerator: Automatically generates and writes.tomlmodel cards into the target directory.QuantizeCompiler: Coordinates the end-to-end compilation workflow.CLI Command & Exo Main Dispatch (
src/exo/cli/commands/quantize.py,src/exo/main.py,src/exo/__main__.py):exo quantizeCLI subcommand with progress and summary output.exo.mainandexo.__main__.Unit Tests (
src/exo/shared/tests/test_quantize_cli.py):.tomlmodel card generation.Verification
.venv/Scripts/pytest.exe src/exo/shared/tests/test_quantize_cli.py # 6 passed in 0.09s.venv/Scripts/ruff.exe check src/exo/shared/types/quantize_cli.py src/exo/worker/engines/quantization/quantize_compiler.py src/exo/worker/engines/quantization/__init__.py src/exo/cli/commands/quantize.py src/exo/cli/__init__.py src/exo/shared/tests/test_quantize_cli.py # All checks passed!python -m exo quantize meta-llama/Llama-3.2-1B --bits 1.58 --output ./test_quant_out # Successfully compiled and generated model_card.tomlRelated Issues
人人都能跑llm.md(Built-in One-Click Model Quantization CLI)