Refactor quantization into a shared extension/llm/export/quant package (#21044)#21044
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21044
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 1 New Failure, 1 Unrelated Failure, 3 Unclassified FailuresAs of commit d18198d with merge base 564e655 ( NEW FAILURE - The following job has failed:
UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@metascroy has exported this pull request. If you are a Meta employee, you can view the originating Diff in D112867629. |
This PR needs a
|
| from executorch.backends.cuda.quantize_op_dispatch.int4_dispatch import _dequant_matmul | ||
| from executorch.examples.models.gemma4_31b.quant.pack_cuda import pack_linear_for_cuda | ||
| from executorch.examples.models.gemma4_31b.quant.quantize import ( | ||
| from executorch.examples.models.gemma4_31b.cuda_packers import pack_linear_for_cuda |
There was a problem hiding this comment.
if the cuda packers are shared (at least across gemma4_31b and
qwen3_5_moe), why not also have this in something like extension.llm.cuda_packers?
pytorch#21044) Summary: Pull Request resolved: pytorch#21044 Consolidates the quantization/packing logic that was previously duplicated across per-model directories into a single reusable package under extension/llm/export/quant, and introduces a model-free checkpoint loader. Key changes: - New extension/llm/export/quant package exposing a stable API: - convert.py: Convert, to_exportable/to_default, fuse_along_output, identity - quantize.py: quantize_model/quantize_weight/quantize_stream + dequantize - recipe.py: QuantConfig / QuantRecipe / QuantRule - New extension/llm/export/load.py: model-free (iter_checkpoint) and model-aware (load_checkpoint) readers that stream GGUF / safetensors weights, remap names to FQNs, and wrap quantized subclasses in portable Exportable* form. Backend-specific layout (CUDA coalesced int4, MLX gather buffers) is a separate terminal pass. - Extended int4.py / gguf.py to plug into the shared conversion path. - Removed the old per-model examples/models/gemma4_31b/quant/ packers (pack.py, pack_cuda.py, pack_mlx.py) and moved packing into examples/models/gemma4_31b/cuda_packers.py, wiring gemma4_31b and qwen3_5_moe onto the shared package. - Added unit tests for the new package and the gemma4_31b packers/pipelines. Differential Revision: D112867629
72badd5 to
a181426
Compare
pytorch#21044) Summary: Pull Request resolved: pytorch#21044 Consolidates the quantization/packing logic that was previously duplicated across per-model directories into a single reusable package under extension/llm/export/quant, and introduces a model-free checkpoint loader. Key changes: - New extension/llm/export/quant package exposing a stable API: - convert.py: Convert, to_exportable/to_default, fuse_along_output, identity - quantize.py: quantize_model/quantize_weight/quantize_stream + dequantize - recipe.py: QuantConfig / QuantRecipe / QuantRule - New extension/llm/export/load.py: model-free (iter_checkpoint) and model-aware (load_checkpoint) readers that stream GGUF / safetensors weights, remap names to FQNs, and wrap quantized subclasses in portable Exportable* form. Backend-specific layout (CUDA coalesced int4, MLX gather buffers) is a separate terminal pass. - Extended int4.py / gguf.py to plug into the shared conversion path. - Removed the old per-model examples/models/gemma4_31b/quant/ packers (pack.py, pack_cuda.py, pack_mlx.py) and moved packing into examples/models/gemma4_31b/cuda_packers.py, wiring gemma4_31b and qwen3_5_moe onto the shared package. - Added unit tests for the new package and the gemma4_31b packers/pipelines. Differential Revision: D112867629
a181426 to
f8a5ace
Compare
pytorch#21044) Summary: Pull Request resolved: pytorch#21044 Consolidates the quantization/packing logic that was previously duplicated across per-model directories into a single reusable package under extension/llm/export/quant, and introduces a model-free checkpoint loader. Key changes: - New extension/llm/export/quant package exposing a stable API: - convert.py: Convert, to_exportable/to_default, fuse_along_output, identity - quantize.py: quantize_model/quantize_weight/quantize_stream + dequantize - recipe.py: QuantConfig / QuantRecipe / QuantRule - New extension/llm/export/load.py: model-free (iter_checkpoint) and model-aware (load_checkpoint) readers that stream GGUF / safetensors weights, remap names to FQNs, and wrap quantized subclasses in portable Exportable* form. Backend-specific layout (CUDA coalesced int4, MLX gather buffers) is a separate terminal pass. - Extended int4.py / gguf.py to plug into the shared conversion path. - Removed the old per-model examples/models/gemma4_31b/quant/ packers (pack.py, pack_cuda.py, pack_mlx.py) and moved packing into examples/models/gemma4_31b/cuda_packers.py, wiring gemma4_31b and qwen3_5_moe onto the shared package. - Added unit tests for the new package and the gemma4_31b packers/pipelines. Differential Revision: D112867629
f8a5ace to
577db1d
Compare
pytorch#21044) Summary: Pull Request resolved: pytorch#21044 Consolidates the quantization/packing logic that was previously duplicated across per-model directories into a single reusable package under extension/llm/export/quant, and introduces a model-free checkpoint loader. Key changes: - New extension/llm/export/quant package exposing a stable API: - convert.py: Convert, to_exportable/to_default, fuse_along_output, identity - quantize.py: quantize_model/quantize_weight/quantize_stream + dequantize - recipe.py: QuantConfig / QuantRecipe / QuantRule - New extension/llm/export/load.py: model-free (iter_checkpoint) and model-aware (load_checkpoint) readers that stream GGUF / safetensors weights, remap names to FQNs, and wrap quantized subclasses in portable Exportable* form. Backend-specific layout (CUDA coalesced int4, MLX gather buffers) is a separate terminal pass. - Extended int4.py / gguf.py to plug into the shared conversion path. - Removed the old per-model examples/models/gemma4_31b/quant/ packers (pack.py, pack_cuda.py, pack_mlx.py) and moved packing into examples/models/gemma4_31b/cuda_packers.py, wiring gemma4_31b and qwen3_5_moe onto the shared package. - Added unit tests for the new package and the gemma4_31b packers/pipelines. Differential Revision: D112867629
577db1d to
a6129f4
Compare
pytorch#21044) Summary: Pull Request resolved: pytorch#21044 Consolidates the quantization/packing logic that was previously duplicated across per-model directories into a single reusable package under extension/llm/export/quant, and introduces a model-free checkpoint loader. Key changes: - New extension/llm/export/quant package exposing a stable API: - convert.py: Convert, to_exportable/to_default, fuse_along_output, identity - quantize.py: quantize_model/quantize_weight/quantize_stream + dequantize - recipe.py: QuantConfig / QuantRecipe / QuantRule - New extension/llm/export/load.py: model-free (iter_checkpoint) and model-aware (load_checkpoint) readers that stream GGUF / safetensors weights, remap names to FQNs, and wrap quantized subclasses in portable Exportable* form. Backend-specific layout (CUDA coalesced int4, MLX gather buffers) is a separate terminal pass. - Extended int4.py / gguf.py to plug into the shared conversion path. - Removed the old per-model examples/models/gemma4_31b/quant/ packers (pack.py, pack_cuda.py, pack_mlx.py) and moved packing into examples/models/gemma4_31b/cuda_packers.py, wiring gemma4_31b and qwen3_5_moe onto the shared package. - Added unit tests for the new package and the gemma4_31b packers/pipelines. Differential Revision: D112867629
a6129f4 to
f8cae64
Compare
pytorch#21044) Summary: Pull Request resolved: pytorch#21044 Consolidates the quantization/packing logic that was previously duplicated across per-model directories into a single reusable package under extension/llm/export/quant, and introduces a model-free checkpoint loader. Key changes: - New extension/llm/export/quant package exposing a stable API: - convert.py: Convert, to_exportable/to_default, fuse_along_output, identity - quantize.py: quantize_model/quantize_weight/quantize_stream + dequantize - recipe.py: QuantConfig / QuantRecipe / QuantRule - New extension/llm/export/load.py: model-free (iter_checkpoint) and model-aware (load_checkpoint) readers that stream GGUF / safetensors weights, remap names to FQNs, and wrap quantized subclasses in portable Exportable* form. Backend-specific layout (CUDA coalesced int4, MLX gather buffers) is a separate terminal pass. - Extended int4.py / gguf.py to plug into the shared conversion path. - Removed the old per-model examples/models/gemma4_31b/quant/ packers (pack.py, pack_cuda.py, pack_mlx.py) and moved packing into examples/models/gemma4_31b/cuda_packers.py, wiring gemma4_31b and qwen3_5_moe onto the shared package. - Added unit tests for the new package and the gemma4_31b packers/pipelines. Reviewed By: Gasoonjia Differential Revision: D112867629
f8cae64 to
6bc7094
Compare
pytorch#21044) Summary: Pull Request resolved: pytorch#21044 Consolidates the quantization/packing logic that was previously duplicated across per-model directories into a single reusable package under extension/llm/export/quant, and introduces a model-free checkpoint loader. Key changes: - New extension/llm/export/quant package exposing a stable API: - convert.py: Convert, to_exportable/to_default, fuse_along_output, identity - quantize.py: quantize_model/quantize_weight/quantize_stream + dequantize - recipe.py: QuantConfig / QuantRecipe / QuantRule - New extension/llm/export/load.py: model-free (iter_checkpoint) and model-aware (load_checkpoint) readers that stream GGUF / safetensors weights, remap names to FQNs, and wrap quantized subclasses in portable Exportable* form. Backend-specific layout (CUDA coalesced int4, MLX gather buffers) is a separate terminal pass. - Extended int4.py / gguf.py to plug into the shared conversion path. - Removed the old per-model examples/models/gemma4_31b/quant/ packers (pack.py, pack_cuda.py, pack_mlx.py) and moved packing into examples/models/gemma4_31b/cuda_packers.py, wiring gemma4_31b and qwen3_5_moe onto the shared package. - Added unit tests for the new package and the gemma4_31b packers/pipelines. Reviewed By: Gasoonjia Differential Revision: D112867629
6bc7094 to
7b40560
Compare
pytorch#21044) Summary: Pull Request resolved: pytorch#21044 Consolidates the quantization/packing logic that was previously duplicated across per-model directories into a single reusable package under extension/llm/export/quant, and introduces a model-free checkpoint loader. Key changes: - New extension/llm/export/quant package exposing a stable API: - convert.py: Convert, to_exportable/to_default, fuse_along_output, identity - quantize.py: quantize_model/quantize_weight/quantize_stream + dequantize - recipe.py: QuantConfig / QuantRecipe / QuantRule - New extension/llm/export/load.py: model-free (iter_checkpoint) and model-aware (load_checkpoint) readers that stream GGUF / safetensors weights, remap names to FQNs, and wrap quantized subclasses in portable Exportable* form. Backend-specific layout (CUDA coalesced int4, MLX gather buffers) is a separate terminal pass. - Extended int4.py / gguf.py to plug into the shared conversion path. - Removed the old per-model examples/models/gemma4_31b/quant/ packers (pack.py, pack_cuda.py, pack_mlx.py) and moved packing into examples/models/gemma4_31b/cuda_packers.py, wiring gemma4_31b and qwen3_5_moe onto the shared package. - Added unit tests for the new package and the gemma4_31b packers/pipelines. Reviewed By: Gasoonjia Differential Revision: D112867629
7b40560 to
d18198d
Compare
Summary:
Consolidates the quantization/packing logic that was previously duplicated
across per-model directories into a single reusable package under
extension/llm/export/quant, and introduces a model-free checkpoint loader.
Key changes:
model-aware (load_checkpoint) readers that stream GGUF / safetensors weights,
remap names to FQNs, and wrap quantized subclasses in portable Exportable*
form. Backend-specific layout (CUDA coalesced int4, MLX gather buffers) is a
separate terminal pass.
(pack.py, pack_cuda.py, pack_mlx.py) and moved packing into
examples/models/gemma4_31b/cuda_packers.py, wiring gemma4_31b and
qwen3_5_moe onto the shared package.
Reviewed By: Gasoonjia
Differential Revision: D112867629