Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.
Python cliconsumer-gpudpofine-tuningggufhuggingfacellmllmopslocal-ailocal-llmloralow-vrammachine-learningollamapeftpythonpytorchqlorasfttransformers
refactor(export): remove deprecated awq and gptq export formats (#1710) (#1951)
Nariman Abdikarim5a6df6b63bbc
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 14130820..ee54b967 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -266,7 +266,7 @@ an issue number or a version. Existing test files keep their names.| test_multi_adapter.py | Multi-adapter serving: validation, parsing, FastAPI endpoints, CLI || test_data_sample.py | Data sampling: random/diverse/hard strategies, CLI, edge cases || test_adapters.py | Adapter management: list/info/compare, discovery, metadata |-| test_awq_gptq_export.py | AWQ/GPTQ export: format support, CLI, quantize mocks, calibration, security |+| test_export_removed_formats.py | AWQ/GPTQ removal verification: rejection at CLI, pyproject extras, codebase clean || test_packing.py | Sample packing: config, YAML, trainer integration, sweep || test_data_split.py | Data split: ratio/absolute/stratified splits, seed, edge cases || test_curriculum.py | Curriculum learning: config, length sort, buckets, sweep |diff --git a/README.ar.md b/README.ar.mdindex 0a358f38..19096307 100644--- a/README.ar.md+++ b/README.ar.md@@ -1,4 +1,4 @@-<!-- synced-from: README.md sha256:4675902b8ea66e77e0822a60fdc9d3205a11eb02fb70cdf3b5670bd9ef1af391 -->+<!-- synced-from: README.md sha256:b10e7bad5b4287de70b59bd0776c162f21da7e7cc0e2eda004dfdfc2bcc7fd24 --><p align="center">🌍 <a href="README.md">English</a> | <a href="README.tr.md">Türkçe</a> | <strong>العربية</strong> | <a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a></p><p align="center">@@ -135,9 +135,6 @@ soup trainثنائي الجانب متينًا إزاء التباين، ويوقّع `soup adapters sign --backend sigstore`و`soup attest emit --sign sigstore` باستخدام Sigstore OIDC بلا مفاتيح(<span dir="ltr">`pip install "soup-cli[sigstore]"`</span>).-- **قيد الإيقاف التدريجي (Deprecated):** سيُزال `soup export --format awq` و<span dir="ltr">`--format gptq`</span>- في v0.77؛ فكلا المشروعين الأصليين مؤرشف ولا يُثبَّت أي من الملحقين (extras) إلى جانب- <span dir="ltr">`[train]`</span>.> Python **3.11–3.13** فقط. وعلى الإصدار 3.14 وما بعده كان pip يختار حزم PyTorch (wheels) غير مختبرة تنهار في> الامتداد الأصلي قبل أن يعمل Soup أصلًا.@@ -216,7 +213,7 @@ soup merge --adapter ./output # ادمج LoRA فيsoup export --model ./output --format gguf --quant q4_k_m # GGUF لـ Ollama / llama.cpp```-وتوجد أهداف تصدير أخرى (ONNX وTensorRT وAWQ وGPTQ وBitNet) وخيارات النشر في+وتوجد أهداف تصدير أخرى (ONNX وTensorRT وBitNet) وخيارات النشر في[`docs/serving-and-export.md`](docs/serving-and-export.md).## واجهة الويبdiff --git a/README.ja.md b/README.ja.mdindex afb0cf1c..f1e1b0de 100644--- a/README.ja.md+++ b/README.ja.md@@ -1,4 +1,4 @@-<!-- synced-from: README.md sha256:4675902b8ea66e77e0822a60fdc9d3205a11eb02fb70cdf3b5670bd9ef1af391 -->+<!-- synced-from: README.md sha256:b10e7bad5b4287de70b59bd0776c162f21da7e7cc0e2eda004dfdfc2bcc7fd24 --><p align="center">🌍 <a href="README.md">English</a> | <a href="README.tr.md">Türkçe</a> | <a href="README.ar.md">العربية</a> | <strong>日本語</strong> | <a href="README.zh.md">中文</a></p><p align="center">@@ -135,8 +135,6 @@ LLM の学習は、今でも骨の折れる作業です。経験豊富なチー使わなかった最も速い実行より 2.9x 速くデコードできました)。`soup ab` は、分散に頑健な両側検定を実行します。`soup adapters sign --backend sigstore` と `soup attest emit --sign sigstore` は、Sigstore のキーレス OIDC で署名します(`pip install "soup-cli[sigstore]"`)。-- **非推奨:** `soup export --format awq` と `--format gptq` は v0.77 で削除されます。どちらの- 上流プロジェクトもアーカイブ済みで、どちらの extra も `[train]` と一緒にはインストールできません。> Python は **3.11–3.13** のみ対応です。3.14 以降では、pip がテストされていない PyTorch の wheel を解決し、> Soup が動き出す前にネイティブ拡張の中でクラッシュしていました。@@ -217,7 +215,7 @@ soup merge --adapter ./output # LoRA をベースsoup export --model ./output --format gguf --quant q4_k_m # Ollama / llama.cpp 向けの GGUF```-その他のエクスポート先(ONNX、TensorRT、AWQ、GPTQ、BitNet)とデプロイのオプションは、+その他のエクスポート先(ONNX、TensorRT、BitNet)とデプロイのオプションは、[`docs/serving-and-export.md`](docs/serving-and-export.md) にあります。## Web UIdiff --git a/README.md b/README.mdindex 1ccd8110..38c36a6c 100644--- a/README.md+++ b/README.md@@ -136,8 +136,6 @@ that will refuse them. A config that loaded before can stop loading: run2.9x faster than the fastest without). `soup ab` runs a two-sided, variance-robust test, and`soup adapters sign --backend sigstore` and `soup attest emit --sign sigstore` sign withSigstore keyless OIDC (`pip install "soup-cli[sigstore]"`).-- **Deprecated:** `soup export --format awq` and `--format gptq` will be removed in v0.77; both- upstream projects are archived and neither extra installs next to `[train]`.> From v0.77, Python **3.11–3.13** only: 3.10 reached end of life on 2026-10-01 (pip there stays> on v0.76); on 3.14+, pip falls back to v0.72.4 (no upper bound) and untested PyTorch wheels.@@ -218,7 +216,7 @@ soup merge --adapter ./output # merge LoRA into thsoup export --model ./output --format gguf --quant q4_k_m # GGUF for Ollama / llama.cpp```-More export targets (ONNX, TensorRT, AWQ, GPTQ, BitNet) and deployment options live in+More export targets (ONNX, TensorRT, BitNet) and deployment options live in[`docs/serving-and-export.md`](docs/serving-and-export.md).## Web UIdiff --git a/README.tr.md b/README.tr.mdindex 9539f755..7e6b59b2 100644--- a/README.tr.md+++ b/README.tr.md@@ -1,4 +1,4 @@-<!-- synced-from: README.md sha256:4675902b8ea66e77e0822a60fdc9d3205a11eb02fb70cdf3b5670bd9ef1af391 -->+<!-- synced-from: README.md sha256:b10e7bad5b4287de70b59bd0776c162f21da7e7cc0e2eda004dfdfc2bcc7fd24 --><p align="center">🌍 <a href="README.md">English</a> | <strong>Türkçe</strong> | <a href="README.ar.md">العربية</a> | <a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a></p><p align="center">@@ -138,8 +138,6 @@ veriyor ve onları reddedecek sürümü belirtiyor. Daha önce yüklenen bir yapkod çözmede 2.9x daha hızlıydı). `soup ab`, iki yönlü, varyansa karşı dayanıklı bir test çalıştırır;`soup adapters sign --backend sigstore` ve `soup attest emit --sign sigstore` ise Sigstore anahtarsızOIDC ile imzalar (`pip install "soup-cli[sigstore]"`).-- **Kullanımdan kaldırıldı:** `soup export --format awq` ve `--format gptq` v0.77'de kaldırılacak; her- iki üst proje de arşivlenmiş durumda ve ekstralardan hiçbiri `[train]` ile yan yana kurulamıyor.> v0.77'den itibaren yalnızca Python **3.11–3.13**. Python 3.10, 2026-10-01'de kullanım ömrünün> sonuna (end of life) ulaştı; 3.10 üzerinde pip v0.76'yı kurmaya devam eder. 3.14+ sürümlerinde@@ -222,7 +220,7 @@ soup merge --adapter ./output # LoRA'yı tabana bisoup export --model ./output --format gguf --quant q4_k_m # Ollama / llama.cpp için GGUF```-Diğer dışa aktarma hedefleri (ONNX, TensorRT, AWQ, GPTQ, BitNet) ve dağıtım seçenekleri+Diğer dışa aktarma hedefleri (ONNX, TensorRT, BitNet) ve dağıtım seçenekleri[`docs/serving-and-export.md`](docs/serving-and-export.md) içinde yer alır.## Web Arayüzüdiff --git a/README.zh.md b/README.zh.mdindex 7d3bba9a..8bcf1180 100644--- a/README.zh.md+++ b/README.zh.md@@ -1,4 +1,4 @@-<!-- synced-from: README.md sha256:4675902b8ea66e77e0822a60fdc9d3205a11eb02fb70cdf3b5670bd9ef1af391 -->+<!-- synced-from: README.md sha256:b10e7bad5b4287de70b59bd0776c162f21da7e7cc0e2eda004dfdfc2bcc7fd24 --><p align="center">🌍 <a href="README.md">English</a> | <a href="README.tr.md">Türkçe</a> | <a href="README.ar.md">العربية</a> | <a href="README.ja.md">日本語</a> | <strong>中文</strong></p><p align="center">@@ -131,8 +131,6 @@ NF4 达到 **952 MHz 下 119.6 tok/s,峰值 3.32 GB**(修复前)——与`soup ab` 运行双侧、对方差稳健的检验,`soup adapters sign --backend sigstore` 和`soup attest emit --sign sigstore` 使用 Sigstore 免密钥 OIDC 签名(`pip install "soup-cli[sigstore]"`)。-- **已弃用:** `soup export --format awq` 和 `--format gptq` 将在 v0.77 移除;这两个上游项目都已归档,- 两个 extra 也都无法与 `[train]` 一起安装。> 仅支持 Python **3.11–3.13**。在 3.14+ 上,pip 过去会解析到未测试过的 PyTorch> wheel,在 Soup 运行之前就崩在原生扩展里。@@ -212,7 +210,7 @@ soup merge --adapter ./output # 把 LoRA 合进基soup export --model ./output --format gguf --quant q4_k_m # 导出 GGUF 给 Ollama / llama.cpp```-更多导出目标(ONNX、TensorRT、AWQ、GPTQ、BitNet)和部署选项在+更多导出目标(ONNX、TensorRT、BitNet)和部署选项在[`docs/serving-and-export.md`](docs/serving-and-export.md)。## Web UIdiff --git a/changelog.d/0.76.0/1951.removed.md b/changelog.d/0.76.0/1951.removed.mdnew file mode 100644index 00000000..981c8290--- /dev/null+++ b/changelog.d/0.76.0/1951.removed.md@@ -0,0 +1 @@+- **Removed deprecated `awq` and `gptq` export and quantize formats and extras (#338, #1690, #1710, in #1951 by @Nari-Ab).** Both upstream projects (`autoawq` and `auto-gptq`) are archived and incompatible with `[train]`. `soup export --format awq` / `--format gptq` and `soup quantize --to awq` / `--to gptq` are now refused at the CLI with non-zero exit codes naming the remaining supported formats (`gguf`, `onnx`, `tensorrt`, `bitnet`, `tq1_0`, `torchao`, `gguf-ud`). `soup export` also lost `--bits`, `--group-size`, and `--calibration-samples`, so scripts passing them now exit 2 with `No such option`; `--calibration-data` is now read only by `--format gguf-ud`. The `[awq]` and `[gptq]` extras and related export helpers are removed in v0.77; users who still need AWQ or GPTQ export should remain on 0.76.x.diff --git a/docs/backends-and-ops.md b/docs/backends-and-ops.mdindex 133aefad..151d640c 100644--- a/docs/backends-and-ops.md+++ b/docs/backends-and-ops.md@@ -945,7 +945,7 @@ the tokenizer still comes from the adapter folder.are recorded as such; a cache-path hint on any backend is still unverified. Standalonewrapper/sweep invocations do not automatically establish a run scope. Metadata iswritten for the final artifact, not each intermediate checkpoint. Other exporters-(including ONNX/TensorRT and native AWQ/GPTQ/torchao loaders), remote adapter sidecars+(including ONNX/TensorRT and native torchao loaders), remote adapter sidecarsand independent teacher/reward/scorer repositories do not gain a binding guarantee.Evaluation engines that bypass the shared live-eval loader (including lm-eval'sadapter benchmark path and vLLM) also remain unbound in this stage.diff --git a/docs/cli-reference.md b/docs/cli-reference.mdindex 093e220f..62978cf2 100644--- a/docs/cli-reference.md+++ b/docs/cli-reference.md@@ -79,7 +79,7 @@ Usage: `soup [OPTIONS] <command> [ARGS]...`| [`soup env`](#soup-env) | Hermetic env lockfile + ABI drift detection (v0.64.0). || [`soup eval`](#soup-eval) | Evaluate models: benchmarks, custom evals, LLM judge, leaderboard. || [`soup expect`](#soup-expect) | Run an expectations suite against a JSONL dataset. |-| [`soup export`](#soup-export) | Export a model to GGUF, ONNX, TensorRT-LLM, AWQ, GPTQ, or TorchAO format. |+| [`soup export`](#soup-export) | Export a model to GGUF, ONNX, TensorRT-LLM, BitNet, or TorchAO format. || [`soup fetch`](#soup-fetch) | Fetch a ready-to-edit example config from the bundled catalog. || [`soup history`](#soup-history) | Show the lineage tree for all entries with a given name. || [`soup infer`](#soup-infer) | Run batch inference on a JSONL file of prompts. |@@ -2328,14 +2328,14 @@ Usage: `soup expect [OPTIONS] DATA SUITE`## `soup export`-Export a model to GGUF, ONNX, TensorRT-LLM, AWQ, GPTQ, or TorchAO format.+Export a model to GGUF, ONNX, TensorRT-LLM, BitNet, or TorchAO format.Usage: `soup export [OPTIONS]`| Name | Type | Default | Required | Help ||---|---|---|---|---|| `--model`, `-m` | text | | yes | Path to model directory (full model or LoRA adapter) |-| `--format`, `-f` | text | `gguf` | | Export format: gguf, onnx, tensorrt, awq, gptq, bitnet, tq1_0, torchao, gguf-ud (torchao needs --quant-config; awq and gptq are deprecated and will be removed in Soup v0.77) |+| `--format`, `-f` | text | `gguf` | | Export format: gguf, onnx, tensorrt, bitnet, tq1_0, torchao, gguf-ud (torchao needs --quant-config) || `--quant`, `-q` | text | `q4_k_m` | | Quantization type: q4_0, q4_k_m, q5_k_m, q8_0, f16, f32 || `--output`, `-o` | text | | | Output file path. Default: <model-name>.<quant>.gguf || `--base`, `-b` | text | | | Base model ID (for LoRA adapters). Auto-detected if not set. |@@ -2343,10 +2343,7 @@ Usage: `soup export [OPTIONS]`| `--onnx-task` | text | `text-generation` | | ONNX export task: text-generation (causal LM) or feature-extraction (embedding) || `--deploy` | text | | | Auto-deploy after export. Currently supported: ollama || `--deploy-name` | text | | | Model name for deployment (used with --deploy) |-| `--bits` | integer | `4` | | Quantization bits for AWQ/GPTQ: 4 or 8 |-| `--group-size` | integer | `128` | | Group size for AWQ/GPTQ quantization |-| `--calibration-data` | text | | | Path to calibration JSONL. Required for AWQ and GPTQ. |-| `--calibration-samples` | integer | `128` | | Number of calibration samples for AWQ/GPTQ |+| `--calibration-data` | text | | | Path to calibration JSONL for imatrix GGUF export. || `--registry-id` | text | | | Attach exported artifact to this registry entry (default: auto-match by source --model output dir) || `--trust-remote-code` | flag | off | | Allow loading models that ship custom Python via auto_map. Default deny (v0.36.0). Only enable if you trust the source. || `--quant-config` | text | | | Path to YAML for torchao PTQ export (v0.53.1 #142). Required when --format=torchao. |@@ -3059,8 +3056,8 @@ Usage: `soup quantize [OPTIONS] MODEL_PATH`| Name | Type | Default | Required | Help ||---|---|---|---|---|| `MODEL_PATH` | text | | yes | Source checkpoint (safetensors directory or single .safetensors). |-| `--to` | text | `gguf` | | Target format: gguf \| gptq \| awq \| onnx \| tensorrt (awq and gptq are deprecated and will be removed in Soup v0.77). |-| `--bits` | integer | `4` | | Quantization bits (1-16; respected by gguf/gptq/awq). |+| `--to` | text | `gguf` | | Target format: gguf \| onnx \| tensorrt. |+| `--bits` | integer | `4` | | Quantization bits (1-16; respected by gguf). || `--output`, `-o` | text | | | Destination directory (default: <model_path>-<to>). |## `soup quickstart`diff --git a/docs/commands.md b/docs/commands.mdindex 4fba8f86..86296a11 100644--- a/docs/commands.md+++ b/docs/commands.md@@ -46,8 +46,6 @@ soup export --model ./output --format gguf Export to GGUF (Ollama)soup export --model ./output --deploy ollama Export GGUF + auto-deploy to Ollamasoup export --model ./output --format onnx Export to ONNXsoup export --model ./output --format tensorrt Export to TensorRT-LLM-soup export --model ./output --format awq --calibration-data cal.jsonl Export to AWQ (4-bit; deprecated, removed in Soup v0.77)-soup export --model ./output --format gptq --calibration-data cal.jsonl Export to GPTQ (4-bit; deprecated, removed in Soup v0.77)soup export --model ./output --format gguf --verbose Show export phases and stream converter/quantizer logs while they run (#1760)soup export --model ./output --format gguf --no-install-deps Never invoke pip; refuse missing conversion packages before merge/toolchain work (#1760)soup deploy ollama --model m.gguf --name x Deploy GGUF to Ollamadiff --git a/docs/models.md b/docs/models.mdindex 5faa926e..5f473d1d 100644--- a/docs/models.md+++ b/docs/models.md@@ -159,11 +159,8 @@ spelling is unchanged. See [the README's install section](../README.md#1-install| `liger` | `pip install "soup-cli[liger]"` | Liger Kernel fused ops || `ring-attn` | `pip install "soup-cli[ring-attn]"` | Ring FlashAttention (sequence parallelism) || `onnx` / `tensorrt` | `pip install "soup-cli[onnx]"` | ONNX / TensorRT-LLM export |-| `awq` / `gptq` | `pip install "soup-cli[awq]"` | AWQ / GPTQ quantized export; not installable alongside `[train]` (see below) || `trackers` | `pip install "soup-cli[trackers]"` | MLflow / SwanLab / Trackio logging || `remote` | `pip install "soup-cli[remote]"` | Remote datasets (s3 / gs / az / oci) || `dev` | `pip install "soup-cli[dev]"` | Tests + lint + types (pytest, ruff, mypy, pre-commit) |-**`[awq]` and `[gptq]` cannot be installed alongside `[train]`.** AWQ export was measured working only with `transformers` 4.52.4 or older, while `[train]` requires `transformers>=5.16.1`; `auto-gptq` publishes no Python 3.12 wheel; and both upstream projects (AutoAWQ and AutoGPTQ) are archived. Run AWQ or GPTQ export from a separate environment. Both export formats are deprecated and will be removed in Soup v0.77 ([#338](https://github.com/MakazhanAlpamys/Soup/issues/338)); until then `soup export --format awq` and `--format gptq` start with a notice that names the formats to move to (`gguf`, `onnx`, `tensorrt`, `bitnet`, `tq1_0`).-The complete, authoritative extras list is in [`pyproject.toml`](../pyproject.toml).diff --git a/docs/performance-and-quantization.md b/docs/performance-and-quantization.mdindex 0f94a0a9..cab7888e 100644--- a/docs/performance-and-quantization.md+++ b/docs/performance-and-quantization.md@@ -1617,12 +1617,6 @@ group_size: 32EOFsoup export --model ./merged --format torchao --quant-config ./q.yaml --output ./out-# AWQ/GPTQ export (deprecated, removed in Soup v0.77) — an explicit local calibration set is required-soup export --model ./merged --format awq \- --calibration-data ./calib.jsonl --output ./out-awq-soup export --model ./merged --format gptq \- --calibration-data ./calib.jsonl --output ./out-gptq-# Unsloth Dynamic 2.0 / IQ / Apple-ARM GGUF via llama.cpp imatrixsoup export --model ./merged --format gguf-ud \--gguf-flavour UD-Q4_K_XL \@@ -1638,10 +1632,6 @@ soup deploy autopilot --target rtx-4090-24gb \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 Soup v0.77: 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`).--Direct AWQ and GPTQ exports require `--calibration-data`. Soup refuses a missing or unusable JSONL before importing the quantizer or loading the model. This keeps calibration inputs explicit and prevents AutoAWQ from silently downloading its large default dataset. Use `--calibration-samples` to cap the number of usable JSONL rows (default: 128).-The advanced GGUF pipeline uses POSIX `O_NOFOLLOW` to defeat the TOCTOU race between the dispatch-time symlink check and the actual open of the calibration data — a crafted environment cannot race-swap the calibration file between validate and read.`soup deploy autopilot --measure` caches results at `~/.soup/deploy_autopilot_cache.json` keyed on `(base, profile, eval-tasks)`. Repeat invocations short-circuit; pass `SOUP_DEPLOY_AUTOPILOT_CACHE=<path>` to redirect (constrained to home / cwd / tempdir). The recommended candidate uses soft-fallback: first `OK` by insertion order, else the candidate with the smallest delta (least drop relative to its own baseline).diff --git a/docs/serving-and-export.md b/docs/serving-and-export.mdindex 2668cbe1..20709e10 100644--- a/docs/serving-and-export.md+++ b/docs/serving-and-export.md@@ -2,7 +2,7 @@[← Back to the Soup README](../README.md)-> The OpenAI-compatible inference server, batch inference, benchmarking, merge/export (GGUF/ONNX/TensorRT/AWQ/GPTQ), the Anthropic Messages endpoint, speculative decoding, deploy autopilot, the Web UI, and Agent Forge.+> The OpenAI-compatible inference server, batch inference, benchmarking, merge/export (GGUF/ONNX/TensorRT/BitNet/TorchAO), the Anthropic Messages endpoint, speculative decoding, deploy autopilot, the Web UI, and Agent Forge.**Contents:**@@ -247,8 +247,8 @@ Auto-detected chat templates: `chatml`, `llama`, `mistral`, `vicuna`, `zephyr` (`soup export` integrates with Soup's local artifact registry and deployment workflows:-- **Deploying on export (`--deploy`)**: `--deploy ollama` is supported for GGUF-family formats (`gguf`, `gguf-ud`, `bitnet`, `tq1_0`). For non-GGUF formats (`onnx`, `tensorrt`, `awq`, `gptq`, `torchao`), `--deploy` fails fast with an informative error because Ollama cannot load non-GGUF weight files. Use `--deploy-name` to assign a custom model name in Ollama.-- **Registering exports (`--registry-id`)**: Pass `--registry-id <id>` to record and attach exported artifacts to a local registry entry across all export formats (`gguf`, `gguf-ud`, `bitnet`, `tq1_0`, `onnx`, `tensorrt`, `awq`, `gptq`, `torchao`). When an export produces a directory (such as multi-shard safetensors, ONNX data, or TensorRT engine files in `<output>/engine/*.engine`), all produced weight and engine files are discovered and attached to the registry entry.+- **Deploying on export (`--deploy`)**: `--deploy ollama` is supported for GGUF-family formats (`gguf`, `gguf-ud`, `bitnet`, `tq1_0`). For non-GGUF formats (`onnx`, `tensorrt`, `torchao`), `--deploy` fails fast with an informative error because Ollama cannot load non-GGUF weight files. Use `--deploy-name` to assign a custom model name in Ollama.+- **Registering exports (`--registry-id`)**: Pass `--registry-id <id>` to record and attach exported artifacts to a local registry entry across all export formats (`gguf`, `gguf-ud`, `bitnet`, `tq1_0`, `onnx`, `tensorrt`, `torchao`). When an export produces a directory (such as multi-shard safetensors, ONNX data, or TensorRT engine files in `<output>/engine/*.engine`), all produced weight and engine files are discovered and attached to the registry entry.## Batch Inference@@ -814,7 +814,7 @@ soup quantize ./out --to gguf --bits 4soup quantize ./out --to onnx -o ./out-onnx```-Prints the equivalent `soup export …` invocation (escaped via `shlex.quote`) for copy-paste. Intentionally does NOT in-process call `soup export` — Typer commands aren't safe to re-enter. `--to awq` and `--to gptq` still print their command, followed by a notice that the two formats are deprecated and will be removed in Soup v0.77.+Prints the equivalent `soup export …` invocation (escaped via `shlex.quote`) for copy-paste. Intentionally does NOT in-process call `soup export` — Typer commands aren't safe to re-enter.## Llama.cpp Proxydiff --git a/pyproject.toml b/pyproject.tomlindex 7fe802af..1ee47a1b 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -182,8 +182,6 @@ ring-attn = ["ring-flash-attn>=0.1.0"]onnx = ["optimum[onnxruntime]>=1.16.0"]tensorrt = ["tensorrt_llm>=0.9.0"]audio = ["librosa>=0.10.0", "soundfile>=0.12.0", "torchaudio>=2.6.0,<3.0.0"]-awq = ["autoawq>=0.2.0"]-gptq = ["auto-gptq>=0.7.0"]sglang = ["sglang>=0.5.1", "fastapi>=0.104.0", "uvicorn>=0.24.0", "httpx>=0.24.0"]mlx = ["mlx>=0.20.0",diff --git a/src/soup_cli/commands/export.py b/src/soup_cli/commands/export.pyindex 2da74faa..75992cba 100644--- a/src/soup_cli/commands/export.py+++ b/src/soup_cli/commands/export.py@@ -20,7 +20,7 @@ from soup_cli.utils.terminal import for_terminal, strip_controlconsole = Console()SUPPORTED_FORMATS = (- "gguf", "onnx", "tensorrt", "awq", "gptq",+ "gguf", "onnx", "tensorrt",# v0.52.0 Part D — BitNet 1.58-bit + TQ1_0 GGUF.# Live llama.cpp conversion (v0.71.20 #134); needs a built llama.cpp toolchain."bitnet", "tq1_0",@@ -30,43 +30,12 @@ SUPPORTED_FORMATS = (# v0.53.1 #139 — UD/IQ/Apple-ARM GGUFs via llama.cpp imatrix."gguf-ud",)-# #338 — AWQ and GPTQ export are deprecated: both upstream projects are archived-# and neither extra installs next to the train extra. The two formats still run-# for one more release; the notice names the formats to move to. Maps the format-# to the upstream project the notice names.-DEPRECATED_FORMATS = {"awq": "AutoAWQ", "gptq": "AutoGPTQ"}-REPLACEMENT_FORMATS = ("gguf", "onnx", "tensorrt", "bitnet", "tq1_0")GGUF_QUANT_TYPES = ("q4_0", "q4_k_m", "q5_k_m", "q8_0", "f16", "f32")LLAMA_CPP_DIR_NAME = "llama.cpp"# Pin to a known release tag for supply-chain safetyLLAMA_CPP_TAG = "b5270"-def deprecated_format_notice(fmt: str) -> Optional[str]:- """The deprecation line for an export format, or ``None`` when it stays.-- Plain text with no console markup: ``soup export`` and ``soup quantize``- both print it behind a ``Deprecated:`` label.- """- upstream = DEPRECATED_FORMATS.get(fmt)- if upstream is None:- return None- replacements = ", ".join(REPLACEMENT_FORMATS[:-1]) + f" or {REPLACEMENT_FORMATS[-1]}"- return (- f"--format {fmt} is deprecated and will be removed in "- f"Soup v{DEPRECATED_VALUE_REJECTION_VERSION}: "- f"{upstream} is archived upstream and the {fmt} extra cannot be installed "- f"next to the train extra. Use --format {replacements} instead."- )---def _warn_deprecated_format(fmt: str) -> None:- """Print the deprecation notice for ``fmt``, if it has one."""- notice = deprecated_format_notice(fmt)- if notice is not None:- console.print(f"[yellow]Deprecated:[/] {notice}")--def export(model: str = typer.Option(...,@@ -79,9 +48,8 @@ def export("--format","-f",help=(- "Export format: gguf, onnx, tensorrt, awq, gptq, bitnet, tq1_0, torchao, "- "gguf-ud (torchao needs --quant-config; awq and gptq are deprecated and "- f"will be removed in Soup v{DEPRECATED_VALUE_REJECTION_VERSION})"+ "Export format: gguf, onnx, tensorrt, bitnet, tq1_0, torchao, "+ "gguf-ud (torchao needs --quant-config)"),),quant: str = typer.Option(@@ -122,25 +90,10 @@ def export("--deploy-name",help="Model name for deployment (used with --deploy)",),- bits: int = typer.Option(- 4,- "--bits",- help="Quantization bits for AWQ/GPTQ: 4 or 8",- ),- group_size: int = typer.Option(- 128,- "--group-size",- help="Group size for AWQ/GPTQ quantization",- ),calibration_data: Optional[str] = typer.Option(None,"--calibration-data",- help="Path to calibration JSONL. Required for AWQ and GPTQ.",- ),- calibration_samples: int = typer.Option(- 128,- "--calibration-samples",- help="Number of calibration samples for AWQ/GPTQ",+ help="Path to calibration JSONL for imatrix GGUF export.",),registry_id: Optional[str] = typer.Option(None,@@ -188,7 +141,7 @@ def export(help="GGUF only: never invoke pip; refuse missing conversion dependencies before work.",),):- """Export a model to GGUF, ONNX, TensorRT-LLM, AWQ, GPTQ, or TorchAO format."""+ """Export a model to GGUF, ONNX, TensorRT-LLM, BitNet, or TorchAO format."""# v0.53.10 #152 — pre-fetch the base model from a non-HF hub. ``model``# is typically a local merged dir / adapter dir; only ``base`` is rewritten.if hub and hub != "hf":@@ -206,17 +159,22 @@ def export(model_path = Path(model)# --- Validate ---- if not model_path.exists():- console.print(f"[red]Model path not found: {model_path}[/]")- raise typer.Exit(1)-if fmt not in SUPPORTED_FORMATS:+ removed_notice = ""+ if fmt in ("awq", "gptq"):+ removed_notice = (+ f"\n[yellow]--format {fmt} was removed in v{DEPRECATED_VALUE_REJECTION_VERSION}.[/]"+ )console.print(- f"[red]Unsupported format: {fmt}[/]\n"+ f"[red]Unsupported format: {fmt}[/]{removed_notice}\n"f"Supported: {', '.join(SUPPORTED_FORMATS)}")raise typer.Exit(1)+ if not model_path.exists():+ console.print(f"[red]Model path not found: {model_path}[/]")+ raise typer.Exit(1)+if (verbose or no_install_deps) and fmt != "gguf":flags = [name for name, enabled in (("--verbose", verbose), ("--no-install-deps", no_install_deps),@@ -261,32 +219,6 @@ def export()return- # --- AWQ export path ---- if fmt == "awq":- output_path = _export_awq(- model_path, output, base, bits, group_size,- calibration_data, calibration_samples, trust_remote_code,- )- if output_path is not None:- _maybe_attach_export(- artifact_path=str(output_path), kind="awq",- explicit_id=registry_id, source_model=str(Path(model)),- )- return-- # --- GPTQ export path ---- if fmt == "gptq":- output_path = _export_gptq(- model_path, output, base, bits, group_size,- calibration_data, calibration_samples, trust_remote_code,- )- if output_path is not None:- _maybe_attach_export(- artifact_path=str(output_path), kind="gptq",- explicit_id=registry_id, source_model=str(Path(model)),- )- return-# --- TorchAO PTQ export path (v0.53.1 #142) ---if fmt == "torchao":output_path = _export_torchao_cli(@@ -1087,385 +1019,6 @@ def _export_tensorrt(return output_path-def _validate_output_path(output: Optional[str]) -> Optional[Path]:- """Validate output path stays under cwd (path traversal protection)."""- if output is None:- return None- # realpath + commonpath containment (is_under_cwd) — Path.resolve() +- # relative_to() breaks on Windows 8.3 short names.- from soup_cli.utils.paths import is_under_cwd-- out_path = Path(output).resolve()- if not is_under_cwd(output):- console.print("[red]Output path must be under the current working directory.[/]")- raise typer.Exit(1)- return out_path---def _validate_calibration_path(calibration_data: Optional[str]) -> Optional[Path]:- """Validate calibration data path stays under cwd."""- if calibration_data is None:- return None- from soup_cli.utils.paths import is_under_cwd-- cal_path = Path(calibration_data).resolve()- if not is_under_cwd(calibration_data):- console.print("[red]Calibration data path must be under the current working directory.[/]")- raise typer.Exit(1)- if not cal_path.exists():- console.print(f"[red]Calibration data not found: {cal_path}[/]")- raise typer.Exit(1)- return cal_path---class _CalibrationDataReadError(ValueError):- """A calibration JSONL could not be decoded or read safely."""---def _load_calibration_texts(cal_path: Optional[Path], max_samples: int = 128) -> list:- """Load calibration texts from JSONL file."""- if cal_path is None:- return []- texts = []- try:- with open(cal_path, encoding="utf-8") as fh:- for line in fh:- line = line.strip()- if not line:- continue- try:- row = json.loads(line)- except json.JSONDecodeError:- continue- if not isinstance(row, dict):- continue- # Support "text" field or concatenate all non-empty values.- if "text" in row:- value = row["text"]- text = "" if value is None else str(value)- else:- text = " ".join(str(v) for v in row.values() if v)- if text.strip():- texts.append(text)- if len(texts) >= max_samples:- break- except UnicodeError as exc:- raise _CalibrationDataReadError(- f"Calibration data is not valid UTF-8: {cal_path}"- ) from exc- except OSError as exc:- raise _CalibrationDataReadError(- f"Could not read calibration data {cal_path}: {exc}"- ) from exc- return texts---def _standardize_gptq_shard_name(output_path: Path, bits: int, group_size: int) -> None:- """auto_gptq's save_quantized names its shard gptq_model-<bits>bit-<group>g.safetensors,- a name AutoModelForCausalLM.from_pretrained does not look for; rename it to the- standard model.safetensors so the exported directory reloads."""- shard = output_path / f"gptq_model-{bits}bit-{group_size}g.safetensors"- standard = output_path / "model.safetensors"- if shard.exists() and not standard.exists():- shard.rename(standard)---def _export_awq(- model_path: Path,- output: Optional[str],- base: Optional[str],- bits: int = 4,- group_size: int = 128,- calibration_data: Optional[str] = None,- calibration_samples: int = 128,- trust_remote_code: bool = False,-) -> Optional[Path]:- """Export model to AWQ format via autoawq."""- # First, so it is there whatever stops the run (most stop at the extra).- _warn_deprecated_format("awq")- # Validate bits- valid_bits = {4, 8}- if bits not in valid_bits:- console.print(- f"[red]Invalid --bits {bits}. Must be one of: {sorted(valid_bits)}[/]"- )- raise typer.Exit(1)-- # Validate output path (security: path traversal protection)- validated_output = _validate_output_path(output)-- # Validate calibration path (security: path traversal protection)- cal_path = _validate_calibration_path(calibration_data)- if cal_path is None:- console.print(- "[red]AWQ export requires --calibration-data.[/]\n"- "AutoAWQ otherwise downloads its large default calibration dataset: "- "pass a calibration JSONL, e.g. [bold]--calibration-data path/to/data.jsonl[/]."- )- raise typer.Exit(1)- try:- calib_data = _load_calibration_texts(cal_path, max_samples=calibration_samples)- except _CalibrationDataReadError as exc:- console.print(f"[red]{exc}[/]")- raise typer.Exit(1) from exc- if not calib_data:- console.print(f"[red]No usable calibration samples found in {cal_path}.[/]")- raise typer.Exit(1)-- try:- from awq import AutoAWQForCausalLM- except ImportError as exc:- if exc.name != "awq":- console.print(f"[red]autoawq import failed:[/] {exc}")- raise typer.Exit(1)- console.print(- "[red]autoawq not installed.[/]\n"- "Install with: [bold]pip install \"soup-cli\\[awq]\"[/]\n"- "Or directly: [bold]pip install autoawq[/]"- )- raise typer.Exit(1)-- from transformers import AutoTokenizer-- # Check if LoRA adapter — merge first- adapter_config_path = model_path / "adapter_config.json"- is_adapter = adapter_config_path.exists()- merge_dir = None- source_path = model_path-- if is_adapter:- console.print("[yellow]LoRA adapter detected - merging with base model first...[/]")- base_model = base or _detect_base_model(adapter_config_path)- if not base_model:- console.print(- "[red]Cannot detect base model from adapter_config.json.[/]\n"- "Please specify with [bold]--base[/] flag."- )- raise typer.Exit(1)- merge_dir = model_path.parent / f".soup_merge_tmp_{model_path.name}"- _merge_adapter(str(model_path), base_model, str(merge_dir), trust_remote_code)- source_path = merge_dir-- default_out = model_path.parent / f"{model_path.name}_awq"- output_path = validated_output if validated_output else default_out-- console.print(- Panel(- f"Model: [bold]{source_path}[/]\n"- f"Format: [bold]AWQ[/]\n"- f"Bits: [bold]{bits}[/]\n"- f"Group size: [bold]{group_size}[/]\n"- f"Output: [bold]{output_path}[/]",- title="Export Plan",- )- )-- try:- console.print(- Panel(- "[yellow]Warning:[/] Loading model with trust_remote_code=True.\n"- "This may execute custom code from the model directory.",- title="Security Notice",- )- )- console.print("[dim]Loading model for AWQ quantization...[/]")- model = AutoAWQForCausalLM.from_pretrained(str(source_path))- from soup_cli.utils.trust_remote import (- model_requires_trust_remote_code,- resolve_trust_remote_code,- )-- requires_tok = model_requires_trust_remote_code(str(source_path)) or False- trc_tok = resolve_trust_remote_code(- str(source_path),- requested=trust_remote_code,- console=console,- requires_remote_code=requires_tok,- )- tokenizer = AutoTokenizer.from_pretrained(str(source_path), trust_remote_code=trc_tok)-- quant_config = {"zero_point": True, "q_group_size": group_size, "w_bit": bits}-- console.print(f"[dim]Quantizing to AWQ {bits}-bit (group_size={group_size})...[/]")- model.quantize(tokenizer, quant_config=quant_config, calib_data=calib_data)-- console.print("[dim]Saving quantized model...[/]")- model.save_quantized(str(output_path))- tokenizer.save_pretrained(str(output_path))-- except Exception as exc:- console.print(f"[red]AWQ export failed:[/] {exc}")- raise typer.Exit(1)- finally:- if merge_dir and merge_dir.exists():- console.print("[dim]Cleaning up temporary merge files...[/]")- shutil.rmtree(merge_dir, ignore_errors=True)-- console.print(- Panel(- f"Output: [bold]{output_path}[/]\n"- f"Format: [bold]AWQ {bits}-bit[/]\n\n"- f"Use with vLLM:\n"- f" [bold]from vllm import LLM[/]\n"- f" [bold]llm = LLM(model='{output_path}', quantization='awq')[/]",- title="[bold green]AWQ Export Complete![/]",- )- )- return output_path---def _export_gptq(- model_path: Path,- output: Optional[str],- base: Optional[str],- bits: int = 4,- group_size: int = 128,- calibration_data: Optional[str] = None,- calibration_samples: int = 128,- trust_remote_code: bool = False,-) -> Optional[Path]:- """Export model to GPTQ format via auto-gptq."""- # First, so it is there whatever stops the run (most stop at the extra).- _warn_deprecated_format("gptq")- # Validate bits- valid_bits = {4, 8}- if bits not in valid_bits:- console.print(- f"[red]Invalid --bits {bits}. Must be one of: {sorted(valid_bits)}[/]"- )- raise typer.Exit(1)-- # Validate output path (security: path traversal protection)- validated_output = _validate_output_path(output)-- # Validate calibration path (security: path traversal protection)- cal_path = _validate_calibration_path(calibration_data)- if cal_path is None:- console.print(- "[red]GPTQ export requires --calibration-data.[/]\n"- "auto-gptq has no built-in calibration dataset: "- "pass a calibration JSONL, e.g. [bold]--calibration-data path/to/data.jsonl[/]."- )- raise typer.Exit(1)- try:- calib_texts = _load_calibration_texts(cal_path, max_samples=calibration_samples)- except _CalibrationDataReadError as exc:- console.print(f"[red]{exc}[/]")- raise typer.Exit(1) from exc- if not calib_texts:- console.print(f"[red]No usable calibration samples found in {cal_path}.[/]")- raise typer.Exit(1)-- try:- from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig- except ImportError as exc:- if exc.name != "auto_gptq":- console.print(f"[red]auto-gptq import failed:[/] {exc}")- raise typer.Exit(1)- console.print(- "[red]auto-gptq not installed.[/]\n"- "Install with: [bold]pip install \"soup-cli\\[gptq]\"[/]\n"- "Or directly: [bold]pip install auto-gptq[/]"- )- raise typer.Exit(1)-- from transformers import AutoTokenizer-- # Check if LoRA adapter — merge first- adapter_config_path = model_path / "adapter_config.json"- is_adapter = adapter_config_path.exists()- merge_dir = None- source_path = model_path-- if is_adapter:- console.print("[yellow]LoRA adapter detected - merging with base model first...[/]")- base_model = base or _detect_base_model(adapter_config_path)- if not base_model:- console.print(- "[red]Cannot detect base model from adapter_config.json.[/]\n"- "Please specify with [bold]--base[/] flag."- )- raise typer.Exit(1)- merge_dir = model_path.parent / f".soup_merge_tmp_{model_path.name}"- _merge_adapter(str(model_path), base_model, str(merge_dir), trust_remote_code)- source_path = merge_dir-- default_out = model_path.parent / f"{model_path.name}_gptq"- output_path = validated_output if validated_output else default_out-- console.print(- Panel(- f"Model: [bold]{source_path}[/]\n"- f"Format: [bold]GPTQ[/]\n"- f"Bits: [bold]{bits}[/]\n"- f"Group size: [bold]{group_size}[/]\n"- f"Output: [bold]{output_path}[/]",- title="Export Plan",- )- )-- try:- console.print(- Panel(- "[yellow]Warning:[/] Loading model with trust_remote_code=True.\n"- "This may execute custom code from the model directory.",- title="Security Notice",- )- )- console.print("[dim]Loading model for GPTQ quantization...[/]")- quantize_config = BaseQuantizeConfig(- bits=bits,- group_size=group_size,- desc_act=False,- )- model = AutoGPTQForCausalLM.from_pretrained(- str(source_path), quantize_config=quantize_config- )- from soup_cli.utils.trust_remote import (- model_requires_trust_remote_code,- resolve_trust_remote_code,- )-- requires_tok = model_requires_trust_remote_code(str(source_path)) or False- trc_tok = resolve_trust_remote_code(- str(source_path),- requested=trust_remote_code,- console=console,- requires_remote_code=requires_tok,- )- tokenizer = AutoTokenizer.from_pretrained(str(source_path), trust_remote_code=trc_tok)-- calib_data = [tokenizer(t, return_tensors="pt") for t in calib_texts]-- console.print(f"[dim]Quantizing to GPTQ {bits}-bit (group_size={group_size})...[/]")- model.quantize(calib_data)-- console.print("[dim]Saving quantized model...[/]")- model.save_quantized(str(output_path))- tokenizer.save_pretrained(str(output_path))- _standardize_gptq_shard_name(output_path, bits, group_size)-- except Exception as exc:- console.print(f"[red]GPTQ export failed:[/] {exc}")- raise typer.Exit(1)- finally:- if merge_dir and merge_dir.exists():- console.print("[dim]Cleaning up temporary merge files...[/]")- shutil.rmtree(merge_dir, ignore_errors=True)-- console.print(- Panel(- f"Output: [bold]{output_path}[/]\n"- f"Format: [bold]GPTQ {bits}-bit[/]\n\n"- f"Use with vLLM:\n"- f" [bold]from vllm import LLM[/]\n"- f" [bold]llm = LLM(model='{output_path}', quantization='gptq')[/]",- title="[bold green]GPTQ Export Complete![/]",- )- )- return output_path--def _auto_deploy_ollama(output_path: Path, model_name: str, deploy_target: str, deploy_name: Optional[str]):diff --git a/src/soup_cli/commands/quantize.py b/src/soup_cli/commands/quantize.pyindex 2de04e87..d86d882d 100644--- a/src/soup_cli/commands/quantize.py+++ b/src/soup_cli/commands/quantize.py@@ -15,11 +15,9 @@ import typerfrom rich.console import Consolefrom rich.markup import escape-from soup_cli.config.deprecation import DEPRECATED_VALUE_REJECTION_VERSION-console = Console()-VALID_FORMATS = frozenset({"gguf", "gptq", "awq", "onnx", "tensorrt"})+VALID_FORMATS = frozenset({"gguf", "onnx", "tensorrt"})def quantize(@@ -30,16 +28,12 @@ def quantize(to: str = typer.Option("gguf","--to",- help=(- "Target format: gguf | gptq | awq | onnx | tensorrt "- "(awq and gptq are deprecated and will be removed in "- f"Soup v{DEPRECATED_VALUE_REJECTION_VERSION})."- ),+ help="Target format: gguf | onnx | tensorrt.",),bits: int = typer.Option(4,"--bits",- help="Quantization bits (1-16; respected by gguf/gptq/awq).",+ help="Quantization bits (1-16; respected by gguf).",),output: str = typer.Option(None,@@ -68,8 +62,6 @@ def quantize(parts = ["soup", "export", "--model", model_path, "--format", canonical]if canonical == "gguf":parts.extend(["--quant", f"q{bits}_K_M"])- elif canonical in ("gptq", "awq"):- parts.extend(["--bits", str(bits)])if output:parts.extend(["--output", output])rendered = " ".join(shlex.quote(part) for part in parts)@@ -78,9 +70,3 @@ def quantize(console.print("[dim]Tip: `soup export --help` lists every advanced quantization flag.[/]")- # #338 -- the command above still runs, but the format is on its way out.- from soup_cli.commands.export import deprecated_format_notice-- notice = deprecated_format_notice(canonical)- if notice is not None:- console.print(f"[yellow]Deprecated:[/] {notice}")diff --git a/src/soup_cli/mcp_server/registry.py b/src/soup_cli/mcp_server/registry.pyindex 01de01f8..dac730b3 100644--- a/src/soup_cli/mcp_server/registry.py+++ b/src/soup_cli/mcp_server/registry.py@@ -1191,7 +1191,7 @@ def _mutating_specs("type": "object","properties": {"model": {"type": "string", "description": "Adapter/model path or id."},- "format": {"type": "string", "description": "gguf / onnx / awq / gptq / ..."},+ "format": {"type": "string", "description": "gguf / onnx / tensorrt / ..."},"output": {"type": "string", "description": "Optional output path."},},"required": ["model", "format"],diff --git a/tests/test_awq_gptq_export.py b/tests/test_awq_gptq_export.pydeleted file mode 100644index ad7f4016..00000000--- a/tests/test_awq_gptq_export.py+++ /dev/null@@ -1,1110 +0,0 @@-"""Tests for AWQ and GPTQ export — config, validation, CLI."""--import builtins-import re-import tempfile-from pathlib import Path-from unittest.mock import MagicMock-from unittest.mock import patch as mock_patch--import pytest-from typer import Exit as ClickExit--from soup_cli.commands.export import SUPPORTED_FORMATS--# Rich colours per character on a colour-capable runner and WRAPS at the-# terminal width, drawing box borders between the fragments of a wrapped help-# line. Strip ANSI escapes and box-drawing characters, then collapse-# whitespace, before any substring match on CLI output.-_ANSI_RE = re.compile(r"\x1b\[[0-9;?]*[A-Za-z]")-_BOX_RE = re.compile(r"[\u2500-\u257f]")---def _plain(text: str) -> str:- """ANSI- and border-stripped, whitespace-collapsed CLI output."""- return " ".join(_BOX_RE.sub(" ", _ANSI_RE.sub("", text)).split())---def _mock_import(awq_mock=None, gptq_mock=None):- """Create a side_effect for builtins.__import__ that intercepts awq/auto_gptq."""- real_import = builtins.__import__-- def custom_import(name, *args, **kwargs):- if name == "awq" and awq_mock is not None:- return awq_mock- if name == "auto_gptq" and gptq_mock is not None:- return gptq_mock- return real_import(name, *args, **kwargs)-- return custom_import---# ─── Format Support Tests ────────────────────────────────────────────────---class TestExportFormatsExtended:- """Test that AWQ and GPTQ formats are registered."""-- def test_awq_format_supported(self):- assert "awq" in SUPPORTED_FORMATS-- def test_gptq_format_supported(self):- assert "gptq" in SUPPORTED_FORMATS-- def test_format_count(self):- """v0.53.1 — 7 prior formats + torchao + gguf-ud = 9."""- assert len(SUPPORTED_FORMATS) == 9-- def test_all_formats_present(self):- """v0.53.1 — adds torchao + gguf-ud to the v0.52.0 baseline."""- expected = {- "gguf", "onnx", "tensorrt", "awq", "gptq",- "bitnet", "tq1_0",- "torchao", "gguf-ud",- }- assert set(SUPPORTED_FORMATS) == expected---# ─── AWQ Export CLI Tests ─────────────────────────────────────────────────---class TestAwqExportCLI:- """Test AWQ export via CLI."""-- def test_awq_export_missing_model_path(self, tmp_path):- """soup export --format awq should fail if model path doesn't exist."""- from typer.testing import CliRunner-- from soup_cli.cli import app-- runner = CliRunner()- result = runner.invoke(- app, ["export", "--model", str(tmp_path / "nonexistent"), "--format", "awq"]- )- assert result.exit_code != 0-- def test_awq_format_in_help(self):- """Export help should mention awq format."""- from typer.testing import CliRunner-- from soup_cli.cli import app-- runner = CliRunner()- result = runner.invoke(app, ["export", "--help"])- assert "awq" in result.output.lower()-- def test_gptq_format_in_help(self):- """Export help should mention gptq format."""- from typer.testing import CliRunner-- from soup_cli.cli import app-- runner = CliRunner()- result = runner.invoke(app, ["export", "--help"])- assert "gptq" in result.output.lower()-- def test_calibration_help_names_both_required_formats(self):- """The shared option must not imply AWQ can omit calibration data.-- Asserted on the Click parameter rather than on rendered ``--help``:- Rich wraps prose inside its box borders at any terminal width, so a- substring match on the rendered text breaks on an unrelated width or- help-string change.- """- import typer-- from soup_cli.cli import app-- cmd = typer.main.get_command(app).commands["export"]- param = next(p for p in cmd.params if "--calibration-data" in p.opts)-- assert param.help == "Path to calibration JSONL. Required for AWQ and GPTQ."---# ─── GPTQ Export CLI Tests ────────────────────────────────────────────────---class TestGptqExportCLI:- """Test GPTQ export via CLI."""-- def test_gptq_export_missing_model_path(self, tmp_path):- """soup export --format gptq should fail if model path doesn't exist."""- from typer.testing import CliRunner-- from soup_cli.cli import app-- runner = CliRunner()- result = runner.invoke(- app, ["export", "--model", str(tmp_path / "nonexistent"), "--format", "gptq"]- )- assert result.exit_code != 0---# ─── AWQ Export Function Tests ────────────────────────────────────────────---class TestAwqExportFunction:- """Test _export_awq logic."""-- def test_export_awq_import_error(self, tmp_path, monkeypatch):- """AWQ export should print friendly error when autoawq not installed."""- from typer.testing import CliRunner-- from soup_cli.cli import app-- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")- monkeypatch.chdir(tmp_path)-- runner = CliRunner()- result = runner.invoke(- app,- [- "export", "--model", str(model_dir), "--format", "awq",- "--calibration-data", str(cal_file),- ],- )- assert result.exit_code != 0- assert "autoawq" in result.output.lower() or "not installed" in result.output.lower()-- def test_export_awq_no_calibration_data_raises(self, tmp_path, capsys):- """AWQ must not delegate missing calibration data to AutoAWQ's implicit- large dataset download, and must fail before importing or loading a model."""- model_dir = tmp_path / "model"- model_dir.mkdir()-- real_import = builtins.__import__-- def reject_awq_import(name, *args, **kwargs):- if name == "awq":- pytest.fail("AWQ was imported before calibration validation")- return real_import(name, *args, **kwargs)-- import soup_cli.commands.export as export_mod-- with mock_patch.object(builtins, "__import__", side_effect=reject_awq_import):- with pytest.raises(ClickExit):- export_mod._export_awq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=None,- )- output = _plain(capsys.readouterr().out)- assert "AWQ export requires --calibration-data" in output- assert "default calibration dataset" in output-- def test_export_awq_empty_calibration_file_raises(self, tmp_path):- """An empty or malformed calibration file fails before model loading."""- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text("\nnot json\n", encoding="utf-8")-- real_import = builtins.__import__-- def reject_awq_import(name, *args, **kwargs):- if name == "awq":- pytest.fail("AWQ was imported before calibration validation")- return real_import(name, *args, **kwargs)-- import soup_cli.commands.export as export_mod-- with mock_patch.object(builtins, "__import__", side_effect=reject_awq_import):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- with pytest.raises(ClickExit):- export_mod._export_awq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(cal_file),- )-- @pytest.mark.parametrize(- "payload",- ["[]", "null", '"plain JSON string"', "42"],- ids=["array", "null", "string", "number"],- )- def test_export_awq_rejects_non_object_json_rows(self, tmp_path, capsys, payload):- """Valid JSON scalars and arrays are not valid JSONL calibration rows."""- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text(f"{payload}\n", encoding="utf-8")-- real_import = builtins.__import__-- def reject_awq_import(name, *args, **kwargs):- if name == "awq":- pytest.fail("AWQ was imported before calibration validation")- return real_import(name, *args, **kwargs)-- import soup_cli.commands.export as export_mod-- with mock_patch.object(builtins, "__import__", side_effect=reject_awq_import):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- with pytest.raises(ClickExit):- export_mod._export_awq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(cal_file),- )-- assert "No usable calibration samples" in capsys.readouterr().out-- def test_export_awq_rejects_non_utf8_calibration_before_import(self, tmp_path, capsys):- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_bytes(b'\xff{"text": "sample"}\n')-- real_import = builtins.__import__-- def reject_awq_import(name, *args, **kwargs):- if name == "awq":- pytest.fail("AWQ was imported before calibration validation")- return real_import(name, *args, **kwargs)-- import soup_cli.commands.export as export_mod-- with mock_patch.object(builtins, "__import__", side_effect=reject_awq_import):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- with pytest.raises(ClickExit):- export_mod._export_awq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(cal_file),- )-- # Rich's highlighter colours the "8" in "UTF-8" as a number.- assert "not valid UTF-8" in _plain(capsys.readouterr().out)-- def test_export_awq_rejects_unreadable_calibration_before_import(self, tmp_path, capsys):- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_dir = tmp_path / "calibration-directory"- cal_dir.mkdir()-- real_import = builtins.__import__-- def reject_awq_import(name, *args, **kwargs):- if name == "awq":- pytest.fail("AWQ was imported before calibration validation")- return real_import(name, *args, **kwargs)-- import soup_cli.commands.export as export_mod-- with mock_patch.object(builtins, "__import__", side_effect=reject_awq_import):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_dir,- ):- with pytest.raises(ClickExit):- export_mod._export_awq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(cal_dir),- )-- assert "Could not read calibration data" in capsys.readouterr().out-- def test_export_awq_calls_quantize(self, tmp_path):- """AWQ export should pass the explicit calibration rows to AutoAWQ."""- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")-- mock_model = MagicMock()- mock_awq_class = MagicMock()- mock_awq_class.from_pretrained = MagicMock(return_value=mock_model)- mock_tokenizer = MagicMock()-- awq_mod = MagicMock()- awq_mod.AutoAWQForCausalLM = mock_awq_class-- import soup_cli.commands.export as export_mod-- out_path = tmp_path / "out"- with mock_patch.object(builtins, "__import__", side_effect=_mock_import(awq_mock=awq_mod)):- with mock_patch(- "transformers.AutoTokenizer.from_pretrained",- return_value=mock_tokenizer,- ):- with mock_patch(- "soup_cli.commands.export._validate_output_path",- return_value=out_path,- ):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- export_mod._export_awq(- model_dir, str(out_path), None,- bits=4, group_size=128,- calibration_data=str(cal_file),- )- mock_awq_class.from_pretrained.assert_called_once()- mock_model.quantize.assert_called_once_with(- mock_tokenizer,- quant_config={"zero_point": True, "q_group_size": 128, "w_bit": 4},- calib_data=["sample"],- )- mock_model.save_quantized.assert_called_once()-- def test_export_awq_default_output_path(self, tmp_path):- """Default AWQ output path should be model_name + _awq suffix."""- model_dir = tmp_path / "my_model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")-- mock_model = MagicMock()- mock_awq_class = MagicMock()- mock_awq_class.from_pretrained = MagicMock(return_value=mock_model)- mock_tokenizer = MagicMock()-- awq_mod = MagicMock()- awq_mod.AutoAWQForCausalLM = mock_awq_class-- import soup_cli.commands.export as export_mod-- with mock_patch.object(builtins, "__import__", side_effect=_mock_import(awq_mock=awq_mod)):- with mock_patch(- "transformers.AutoTokenizer.from_pretrained",- return_value=mock_tokenizer,- ):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- export_mod._export_awq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(cal_file),- )- save_call = mock_model.save_quantized.call_args- output_path = save_call[0][0]- assert "my_model_awq" in output_path-- def test_export_awq_with_calibration_data(self, tmp_path):- """AWQ export with calibration data should load and pass it."""- import json-- model_dir = tmp_path / "model"- model_dir.mkdir()-- cal_file = tmp_path / "cal.jsonl"- lines = [json.dumps({"text": f"sample {i}"}) for i in range(10)]- cal_file.write_text("\n".join(lines), encoding="utf-8")-- mock_model = MagicMock()- mock_awq_class = MagicMock()- mock_awq_class.from_pretrained = MagicMock(return_value=mock_model)- mock_tokenizer = MagicMock()-- awq_mod = MagicMock()- awq_mod.AutoAWQForCausalLM = mock_awq_class-- import soup_cli.commands.export as export_mod-- out_path = tmp_path / "out"- with mock_patch.object(builtins, "__import__", side_effect=_mock_import(awq_mock=awq_mod)):- with mock_patch(- "transformers.AutoTokenizer.from_pretrained",- return_value=mock_tokenizer,- ):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- with mock_patch(- "soup_cli.commands.export._validate_output_path",- return_value=out_path,- ):- export_mod._export_awq(- model_dir, str(out_path), None,- bits=4, group_size=128,- calibration_data=str(cal_file),- )- quant_call = mock_model.quantize.call_args- assert quant_call is not None- assert "calib_data" in quant_call.kwargs-- def test_export_awq_invalid_bits(self, tmp_path):- """Invalid bits value should raise ClickExit."""- model_dir = tmp_path / "model"- model_dir.mkdir()-- import soup_cli.commands.export as export_mod-- with pytest.raises(ClickExit):- export_mod._export_awq(- model_dir, None, None, bits=3, group_size=128,- calibration_data=None,- )-- def test_export_awq_calibration_path_traversal(self, tmp_path):- """Calibration data path should be confined to cwd."""- model_dir = tmp_path / "model"- model_dir.mkdir()-- import soup_cli.commands.export as export_mod-- with pytest.raises(ClickExit):- export_mod._export_awq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(Path("C:/Windows/System32/drivers/etc/hosts")),- )---# ─── GPTQ Export Function Tests ───────────────────────────────────────────---class TestGptqExportFunction:- """Test _export_gptq logic."""-- def test_export_gptq_import_error(self, tmp_path, monkeypatch):- """GPTQ export should print friendly error when auto-gptq not installed."""- from typer.testing import CliRunner-- from soup_cli.cli import app-- monkeypatch.chdir(tmp_path)- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")-- real_import = builtins.__import__-- def custom_import(name, *args, **kwargs):- if name == "auto_gptq":- raise ModuleNotFoundError("No module named 'auto_gptq'", name="auto_gptq")- return real_import(name, *args, **kwargs)-- monkeypatch.setattr(builtins, "__import__", custom_import)-- runner = CliRunner()- result = runner.invoke(- app,- [- "export", "--model", str(model_dir), "--format", "gptq",- "--calibration-data", str(cal_file),- ],- )- assert result.exit_code != 0- assert "auto-gptq" in result.output.lower() or "not installed" in result.output.lower()-- def test_export_gptq_no_calibration_data_raises(self, tmp_path, capsys):- """GPTQ has no built-in fallback dataset: no --calibration-data must raise,- never fall through to model.quantize(tokenizer) (auto-gptq expects examples,- not a tokenizer, and rejects one with 'object is not iterable')."""- model_dir = tmp_path / "model"- model_dir.mkdir()-- mock_gptq_class = MagicMock()- gptq_mod = MagicMock()- gptq_mod.AutoGPTQForCausalLM = mock_gptq_class- gptq_mod.BaseQuantizeConfig = MagicMock-- import soup_cli.commands.export as export_mod-- with mock_patch.object(- builtins, "__import__", side_effect=_mock_import(gptq_mock=gptq_mod)- ):- with pytest.raises(ClickExit):- export_mod._export_gptq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=None,- )- mock_gptq_class.from_pretrained.assert_not_called()- assert "--calibration-data" in capsys.readouterr().out-- def test_export_gptq_empty_calibration_file_raises(self, tmp_path):- """A --calibration-data file that yields zero usable samples (empty,- or only malformed JSON lines) must raise the same way as no file at- all, before the model is ever loaded."""- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text("\n\nnot json\n", encoding="utf-8")-- mock_gptq_class = MagicMock()- gptq_mod = MagicMock()- gptq_mod.AutoGPTQForCausalLM = mock_gptq_class- gptq_mod.BaseQuantizeConfig = MagicMock-- import soup_cli.commands.export as export_mod-- with mock_patch.object(- builtins, "__import__", side_effect=_mock_import(gptq_mock=gptq_mod)- ):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- with pytest.raises(ClickExit):- export_mod._export_gptq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(cal_file),- )- mock_gptq_class.from_pretrained.assert_not_called()-- def test_export_gptq_calls_quantize(self, tmp_path):- """GPTQ export should call AutoGPTQForCausalLM methods."""- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")-- mock_model = MagicMock()- mock_gptq_class = MagicMock()- mock_gptq_class.from_pretrained = MagicMock(return_value=mock_model)- mock_tokenizer = MagicMock()-- gptq_mod = MagicMock()- gptq_mod.AutoGPTQForCausalLM = mock_gptq_class- gptq_mod.BaseQuantizeConfig = MagicMock-- import soup_cli.commands.export as export_mod-- out_path = tmp_path / "out"- out_path.mkdir()- with mock_patch.object(- builtins, "__import__", side_effect=_mock_import(gptq_mock=gptq_mod)- ):- with mock_patch(- "transformers.AutoTokenizer.from_pretrained",- return_value=mock_tokenizer,- ):- with mock_patch(- "soup_cli.commands.export._validate_output_path",- return_value=out_path,- ):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- export_mod._export_gptq(- model_dir, str(out_path), None,- bits=4, group_size=128, calibration_data=str(cal_file),- )- mock_gptq_class.from_pretrained.assert_called_once()- mock_model.quantize.assert_called_once()- mock_model.save_quantized.assert_called_once()-- def test_export_gptq_default_output_path(self, tmp_path):- """Default GPTQ output path should be model_name + _gptq suffix."""- model_dir = tmp_path / "my_model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")-- mock_model = MagicMock()- mock_gptq_class = MagicMock()- mock_gptq_class.from_pretrained = MagicMock(return_value=mock_model)- mock_tokenizer = MagicMock()-- gptq_mod = MagicMock()- gptq_mod.AutoGPTQForCausalLM = mock_gptq_class- gptq_mod.BaseQuantizeConfig = MagicMock-- import soup_cli.commands.export as export_mod-- with mock_patch.object(- builtins, "__import__", side_effect=_mock_import(gptq_mock=gptq_mod)- ):- with mock_patch(- "transformers.AutoTokenizer.from_pretrained",- return_value=mock_tokenizer,- ):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- export_mod._export_gptq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(cal_file),- )- save_call = mock_model.save_quantized.call_args- output_path = save_call[0][0]- assert "my_model_gptq" in output_path-- def test_export_gptq_invalid_bits(self, tmp_path):- """Invalid bits value should raise ClickExit."""- model_dir = tmp_path / "model"- model_dir.mkdir()-- import soup_cli.commands.export as export_mod-- with pytest.raises(ClickExit):- export_mod._export_gptq(- model_dir, None, None, bits=3, group_size=128,- calibration_data=None,- )-- def test_export_gptq_calibration_path_traversal(self, tmp_path):- """Calibration data path should be confined to cwd."""- model_dir = tmp_path / "model"- model_dir.mkdir()-- import soup_cli.commands.export as export_mod-- with pytest.raises(ClickExit):- export_mod._export_gptq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(Path("C:/Windows/System32/drivers/etc/hosts")),- )---# ─── GPTQ Shard Name Regression (issue #338, P2) ─────────────────────────---class TestGptqStandardShardName:- """auto_gptq's save_quantized names its shard gptq_model-<bits>bit-<group>g.safetensors,- which AutoModelForCausalLM.from_pretrained does not look for."""-- def test_standardize_renames_shard_to_model_safetensors(self, tmp_path):- from soup_cli.commands.export import _standardize_gptq_shard_name-- out = tmp_path / "out"- out.mkdir()- (out / "gptq_model-4bit-128g.safetensors").write_bytes(b"weights")-- _standardize_gptq_shard_name(out, bits=4, group_size=128)-- assert (out / "model.safetensors").exists()- assert not (out / "gptq_model-4bit-128g.safetensors").exists()-- def test_standardize_does_not_overwrite_existing_standard_name(self, tmp_path):- from soup_cli.commands.export import _standardize_gptq_shard_name-- out = tmp_path / "out"- out.mkdir()- (out / "model.safetensors").write_bytes(b"already-standard")- (out / "gptq_model-4bit-128g.safetensors").write_bytes(b"weights")-- _standardize_gptq_shard_name(out, bits=4, group_size=128)-- assert (out / "model.safetensors").read_bytes() == b"already-standard"-- def test_standardize_no_op_when_shard_absent(self, tmp_path):- from soup_cli.commands.export import _standardize_gptq_shard_name-- out = tmp_path / "out"- out.mkdir()-- _standardize_gptq_shard_name(out, bits=4, group_size=128)-- assert not (out / "model.safetensors").exists()-- def test_export_gptq_end_to_end_leaves_standard_name(self, tmp_path):- """Full _export_gptq run: save_quantized's mock writes the real auto_gptq- shard name, and the standard model.safetensors must exist afterward."""- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")- out_path = tmp_path / "out"- out_path.mkdir()-- def fake_save_quantized(path):- Path(path, "gptq_model-4bit-128g.safetensors").write_bytes(b"weights")-- mock_model = MagicMock()- mock_model.save_quantized.side_effect = fake_save_quantized- mock_gptq_class = MagicMock()- mock_gptq_class.from_pretrained = MagicMock(return_value=mock_model)- mock_tokenizer = MagicMock()-- gptq_mod = MagicMock()- gptq_mod.AutoGPTQForCausalLM = mock_gptq_class- gptq_mod.BaseQuantizeConfig = MagicMock-- import soup_cli.commands.export as export_mod-- with mock_patch.object(- builtins, "__import__", side_effect=_mock_import(gptq_mock=gptq_mod)- ):- with mock_patch(- "transformers.AutoTokenizer.from_pretrained",- return_value=mock_tokenizer,- ):- with mock_patch(- "soup_cli.commands.export._validate_output_path",- return_value=out_path,- ):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- export_mod._export_gptq(- model_dir, str(out_path), None,- bits=4, group_size=128, calibration_data=str(cal_file),- )-- assert (out_path / "model.safetensors").exists()- assert not (out_path / "gptq_model-4bit-128g.safetensors").exists()---# ─── Import-Error Masking Regression (issue #338, ImportError swallowing) ──---class TestAwqGptqImportErrorSurfacesRealCause:- """except ImportError must not print a fixed 'not installed' string when the- package itself imports but a transitive import inside it fails for an- unrelated reason, which used to discard the real exception."""-- def test_gptq_transitive_import_failure_message(self, tmp_path, capsys):- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")-- real_import = builtins.__import__-- def custom_import(name, *args, **kwargs):- if name == "auto_gptq":- raise ImportError("libfoo.so: cannot open shared object file", name="libfoo")- return real_import(name, *args, **kwargs)-- import soup_cli.commands.export as export_mod-- with mock_patch.object(builtins, "__import__", side_effect=custom_import):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- with pytest.raises(ClickExit):- export_mod._export_gptq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(cal_file),- )- output = capsys.readouterr().out- assert "libfoo.so" in output- assert "not installed" not in output.lower()-- def test_awq_transitive_import_failure_message(self, tmp_path, capsys):- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")-- real_import = builtins.__import__-- def custom_import(name, *args, **kwargs):- if name == "awq":- raise ImportError("libbar.so: cannot open shared object file", name="libbar")- return real_import(name, *args, **kwargs)-- import soup_cli.commands.export as export_mod-- with mock_patch.object(builtins, "__import__", side_effect=custom_import):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- with pytest.raises(ClickExit):- export_mod._export_awq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(cal_file),- )- output = capsys.readouterr().out- assert "libbar.so" in output- assert "not installed" not in output.lower()-- def test_gptq_real_missing_package_still_shows_install_hint(self, tmp_path, capsys):- """When auto-gptq is genuinely absent (exc.name == 'auto_gptq'), the- friendly install hint must still show; this must not regress."""- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")-- real_import = builtins.__import__-- def custom_import(name, *args, **kwargs):- if name == "auto_gptq":- raise ModuleNotFoundError("No module named 'auto_gptq'", name="auto_gptq")- return real_import(name, *args, **kwargs)-- import soup_cli.commands.export as export_mod-- with mock_patch.object(builtins, "__import__", side_effect=custom_import):- with mock_patch(- "soup_cli.commands.export._validate_calibration_path",- return_value=cal_file,- ):- with pytest.raises(ClickExit):- export_mod._export_gptq(- model_dir, None, None, bits=4, group_size=128,- calibration_data=str(cal_file),- )- output = capsys.readouterr().out- assert "not installed" in output.lower()---# ─── CLI Integration Tests ───────────────────────────────────────────────---class TestAwqGptqCLIArgs:- """Test new CLI arguments are declared in export function signature."""-- def test_bits_flag_exists(self):- """Export function should have a --bits parameter."""- import inspect-- from soup_cli.commands.export import export-- sig = inspect.signature(export)- assert "bits" in sig.parameters-- def test_group_size_flag_exists(self):- """Export function should have a --group-size parameter."""- import inspect-- from soup_cli.commands.export import export-- sig = inspect.signature(export)- assert "group_size" in sig.parameters-- def test_calibration_data_flag_exists(self):- """Export function should have a --calibration-data parameter."""- import inspect-- from soup_cli.commands.export import export-- sig = inspect.signature(export)- assert "calibration_data" in sig.parameters-- def test_calibration_samples_flag_exists(self):- """Export function should have a --calibration-samples parameter."""- import inspect-- from soup_cli.commands.export import export-- sig = inspect.signature(export)- assert "calibration_samples" in sig.parameters---# ─── Security Tests ──────────────────────────────────────────────────────---class TestAwqGptqSecurity:- """Security validation for AWQ/GPTQ export."""-- def test_calibration_data_path_traversal_awq(self, tmp_path):- from typer.testing import CliRunner-- from soup_cli.cli import app-- model_dir = tmp_path / "model"- model_dir.mkdir()-- runner = CliRunner()- result = runner.invoke(- app,- [- "export", "--model", str(model_dir),- "--format", "awq",- "--calibration-data", "C:/Windows/System32/drivers/etc/hosts",- ],- )- assert result.exit_code != 0-- def test_calibration_data_path_traversal_gptq(self, tmp_path):- from typer.testing import CliRunner-- from soup_cli.cli import app-- model_dir = tmp_path / "model"- model_dir.mkdir()-- runner = CliRunner()- result = runner.invoke(- app,- [- "export", "--model", str(model_dir),- "--format", "gptq",- "--calibration-data", "C:/Windows/System32/drivers/etc/hosts",- ],- )- assert result.exit_code != 0---# ─── Calibration Data Loader Tests ────────────────────────────────────────---class TestCalibrationLoader:- """Test _load_calibration_texts function."""-- def test_load_text_field(self, tmp_path):- import json-- from soup_cli.commands.export import _load_calibration_texts-- cal_file = tmp_path / "cal.jsonl"- lines = [json.dumps({"text": f"line {i}"}) for i in range(5)]- cal_file.write_text("\n".join(lines), encoding="utf-8")-- texts = _load_calibration_texts(cal_file, max_samples=10)- assert len(texts) == 5- assert texts[0] == "line 0"-- def test_load_max_samples(self, tmp_path):- import json-- from soup_cli.commands.export import _load_calibration_texts-- cal_file = tmp_path / "cal.jsonl"- lines = [json.dumps({"text": f"line {i}"}) for i in range(100)]- cal_file.write_text("\n".join(lines), encoding="utf-8")-- texts = _load_calibration_texts(cal_file, max_samples=10)- assert len(texts) == 10-- def test_load_none_returns_empty(self):- from soup_cli.commands.export import _load_calibration_texts-- assert _load_calibration_texts(None) == []-- def test_load_skips_empty_lines(self, tmp_path):- import json-- from soup_cli.commands.export import _load_calibration_texts-- cal_file = tmp_path / "cal.jsonl"- content = json.dumps({"text": "hello"}) + "\n\n" + json.dumps({"text": "world"})- cal_file.write_text(content, encoding="utf-8")-- texts = _load_calibration_texts(cal_file, max_samples=10)- assert len(texts) == 2-- def test_load_concatenates_non_text_fields(self, tmp_path):- import json-- from soup_cli.commands.export import _load_calibration_texts-- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text(- json.dumps({"prompt": "hello", "response": "world"}),- encoding="utf-8",- )-- texts = _load_calibration_texts(cal_file, max_samples=10)- assert len(texts) == 1- assert "hello" in texts[0]- assert "world" in texts[0]---# ─── Path Validation Tests ───────────────────────────────────────────────---class TestCalibrationPathValidation:- """Test _validate_calibration_path function."""-- def test_none_returns_none(self):- from soup_cli.commands.export import _validate_calibration_path-- assert _validate_calibration_path(None) is None-- def test_nonexistent_file_raises(self):- """Nonexistent calibration file should raise ClickExit."""- from soup_cli.commands.export import _validate_calibration_path-- nope = Path.cwd() / "nonexistent_cal_data_test_xyzzy.jsonl"- with pytest.raises(ClickExit):- _validate_calibration_path(str(nope))-- def test_valid_path_returns_path(self):- """Valid path under cwd should return resolved Path."""- from soup_cli.commands.export import _validate_calibration_path-- cal_file = Path.cwd() / "test_cal_temp_xyzzy.jsonl"- try:- cal_file.write_text("{}", encoding="utf-8")- result = _validate_calibration_path(str(cal_file))- assert result is not None- assert result.name == "test_cal_temp_xyzzy.jsonl"- finally:- if cal_file.exists():- cal_file.unlink()-- def test_path_outside_cwd_raises(self):- from soup_cli.commands.export import _validate_calibration_path-- with pytest.raises(ClickExit):- _validate_calibration_path("C:/Windows/System32/drivers/etc/hosts")---# ─── Output Path Validation Tests ────────────────────────────────────────---class TestOutputPathValidation:- """Test _validate_output_path function."""-- def test_none_returns_none(self):- from soup_cli.commands.export import _validate_output_path-- assert _validate_output_path(None) is None-- def test_valid_path_returns_path(self):- """Valid path under cwd should return resolved Path."""- from soup_cli.commands.export import _validate_output_path-- out = Path.cwd() / "test_output_xyzzy"- result = _validate_output_path(str(out))- assert result is not None- assert result.name == "test_output_xyzzy"-- def test_path_outside_cwd_raises(self):- """Path outside cwd should raise ClickExit."""- from soup_cli.commands.export import _validate_output_path-- # Use a path guaranteed to be outside cwd on all platforms- outside = Path(tempfile.gettempdir()).resolve()- cwd = Path.cwd().resolve()- # Only test if temp dir is actually outside cwd- try:- outside.relative_to(cwd)- pytest.skip("tempdir is under cwd, cannot test outside path")- except ValueError:- pass- with pytest.raises(ClickExit):- _validate_output_path(str(outside / "evil_output"))-- def test_path_traversal_rejected(self, tmp_path, monkeypatch):- """Path outside cwd via relative traversal should be rejected."""- from soup_cli.commands.export import _validate_output_path-- # Set cwd to a subdirectory so ../evil is outside- sub = tmp_path / "deep" / "nested"- sub.mkdir(parents=True)- monkeypatch.chdir(sub)- with pytest.raises(ClickExit):- _validate_output_path(str(tmp_path / "evil"))---# ─── Optional Dependency Tests ────────────────────────────────────────────---class TestOptionalDeps:- """Test that optional deps are declared in pyproject.toml."""-- def _read_pyproject(self):- pyproject = Path(__file__).parent.parent / "pyproject.toml"- return pyproject.read_text(encoding="utf-8")-- def test_awq_optional_dep(self):- content = self._read_pyproject()- assert "awq" in content- assert "autoawq" in content-- def test_gptq_optional_dep(self):- content = self._read_pyproject()- assert "gptq" in content- assert "auto-gptq" in contentdiff --git a/tests/test_code_review_recurring.py b/tests/test_code_review_recurring.pyindex 69d78e77..cd97a66c 100644--- a/tests/test_code_review_recurring.py+++ b/tests/test_code_review_recurring.py@@ -30,7 +30,6 @@ def test_containment_holdouts_migrated_to_commonpath_helper():"utils/ollama.py": "is_under_cwd","migrate/common.py": "is_under_cwd","commands/serve.py": "is_under(",- "commands/export.py": "is_under_cwd","commands/generate.py": "is_under(","data/loader.py": "is_under(","eval/checkpoint_intelligence.py": "is_under(",diff --git a/tests/test_export_removed_formats.py b/tests/test_export_removed_formats.pynew file mode 100644index 00000000..7a26b765--- /dev/null+++ b/tests/test_export_removed_formats.py@@ -0,0 +1,135 @@+"""#1710 — Remove deprecated AWQ and GPTQ export and quantize formats.++Follow-up to #338 and #1690. AWQ and GPTQ export formats and extras are removed+one release after the deprecation notice. The CLI refuses both formats with a+non-zero exit code and names the formats that stay: gguf, onnx, tensorrt, bitnet, tq1_0.+"""++from __future__ import annotations++import pathlib+import re++import pytest+from typer.testing import CliRunner++import soup_cli.commands.export as export_mod+import soup_cli.commands.quantize as quantize_mod+from soup_cli.cli import app++ROOT = pathlib.Path(__file__).resolve().parents[1]+PYPROJECT = ROOT / "pyproject.toml"++_ANSI_RE = re.compile(r"\x1b\[[0-9;?]*[A-Za-z]")+_BOX_RE = re.compile(r"[\u2500-\u257f]")++REMOVED = ("awq", "gptq")+STAYING_EXPORT = ("gguf", "onnx", "tensorrt", "bitnet", "tq1_0")+VALID_QUANTIZE = ("gguf", "onnx", "tensorrt")+++def _plain(text: str) -> str:+ """ANSI- and border-stripped, whitespace-collapsed CLI output."""+ return " ".join(_BOX_RE.sub(" ", _ANSI_RE.sub("", text)).split())+++class TestExportRefusesRemovedFormats:+ @pytest.mark.parametrize("fmt", REMOVED)+ def test_export_refuses_removed_format(self, fmt: str, tmp_path: pathlib.Path) -> None:+ model_dir = tmp_path / "model"+ model_dir.mkdir()++ result = CliRunner().invoke(app, ["export", "--model", str(model_dir), "--format", fmt])++ assert result.exit_code == 1, (result.output, repr(result.exception))+ output = _plain(result.output)+ assert f"unsupported format: {fmt}" in output.lower()+ assert f"--format {fmt} was removed in v0.77." in output+ for remaining in STAYING_EXPORT:+ assert remaining in output++ @pytest.mark.parametrize("fmt", REMOVED)+ def test_export_refusal_does_not_mention_deprecation(+ self, fmt: str, tmp_path: pathlib.Path+ ) -> None:+ model_dir = tmp_path / "model"+ model_dir.mkdir()++ result = CliRunner().invoke(app, ["export", "--model", str(model_dir), "--format", fmt])++ output = _plain(result.output).lower()+ assert "deprecated" not in output++ def test_export_help_omits_removed_formats(self) -> None:+ result = CliRunner().invoke(app, ["export", "--help"])+ assert result.exit_code == 0, (result.output, repr(result.exception))+ output = _plain(result.output).lower()+ assert "awq and gptq are deprecated" not in output+ assert "--format awq" not in output+ assert "--format gptq" not in output+ assert "--bits" not in output+ assert "--group-size" not in output+ assert "--calibration-samples" not in output+++class TestQuantizeRefusesRemovedFormats:+ @pytest.mark.parametrize("fmt", REMOVED)+ def test_quantize_refuses_removed_format(self, fmt: str) -> None:+ result = CliRunner().invoke(app, ["quantize", "./out", "--to", fmt])++ assert result.exit_code == 2+ output = _plain(result.output)+ assert "--to must be one of" in output+ for valid in VALID_QUANTIZE:+ assert valid in output+ assert "deprecated" not in output.lower()++ @pytest.mark.parametrize("fmt", REMOVED)+ def test_quantize_refuses_uppercase_removed_format(self, fmt: str) -> None:+ result = CliRunner().invoke(app, ["quantize", "./out", "--to", fmt.upper()])++ assert result.exit_code == 2+ output = _plain(result.output)+ assert "--to must be one of" in output++ def test_quantize_help_omits_removed_formats(self) -> None:+ result = CliRunner().invoke(app, ["quantize", "--help"])+ assert result.exit_code == 0+ output = _plain(result.output).lower()+ assert "awq and gptq are deprecated" not in output+ assert "gptq | awq" not in output+++class TestCodebaseRemovals:+ def test_supported_formats_excludes_awq_and_gptq(self) -> None:+ for fmt in REMOVED:+ assert fmt not in export_mod.SUPPORTED_FORMATS++ def test_valid_formats_excludes_awq_and_gptq(self) -> None:+ for fmt in REMOVED:+ assert fmt not in quantize_mod.VALID_FORMATS++ def test_deprecated_helpers_and_tables_removed(self) -> None:+ assert not hasattr(export_mod, "DEPRECATED_FORMATS")+ assert not hasattr(export_mod, "REPLACEMENT_FORMATS")+ assert not hasattr(export_mod, "deprecated_format_notice")+ assert not hasattr(export_mod, "_warn_deprecated_format")+ assert not hasattr(export_mod, "_export_awq")+ assert not hasattr(export_mod, "_export_gptq")+ assert not hasattr(export_mod, "_standardize_gptq_shard_name")+ assert not hasattr(export_mod, "_validate_output_path")+ assert not hasattr(export_mod, "_validate_calibration_path")+++class TestPackagingRemovals:+ def test_pyproject_excludes_awq_and_gptq_extras(self) -> None:+ text = PYPROJECT.read_text(encoding="utf-8")+ table = re.search(r"^\[project\.optional-dependencies\]\n(.*?)(?=^\[)", text, re.M | re.S)+ assert table is not None+ code = "\n".join(+ line for line in table.group(1).splitlines() if not line.lstrip().startswith("#")+ )+ extras = re.findall(r"^([A-Za-z0-9_-]+)\s*=", code, re.M)+ for fmt in REMOVED:+ assert fmt not in extras+ assert f"auto{fmt}" not in codediff --git a/tests/test_issue1448_export_deploy_options.py b/tests/test_issue1448_export_deploy_options.pyindex 47679745..d7f471ad 100644--- a/tests/test_issue1448_export_deploy_options.py+++ b/tests/test_issue1448_export_deploy_options.py@@ -32,7 +32,7 @@ def test_torchao_in_valid_kinds():assert "torchao" in _VALID_KINDS[email protected]("fmt", ["onnx", "tensorrt", "awq", "gptq", "torchao"])[email protected]("fmt", ["onnx", "tensorrt", "torchao"])def test_export_refuses_deploy_for_unsupported_formats(tmp_path: Path, fmt: str):"""Formats Ollama cannot load must refuse --deploy with an informative error."""model_dir = tmp_path / "model"@@ -103,8 +103,6 @@ def test_export_wires_deploy_for_deployable_formats(tmp_path: Path, fmt: str):[("onnx", "soup_cli.commands.export._export_onnx", "onnx"),("tensorrt", "soup_cli.commands.export._export_tensorrt", "tensorrt"),- ("awq", "soup_cli.commands.export._export_awq", "awq"),- ("gptq", "soup_cli.commands.export._export_gptq", "gptq"),("torchao", "soup_cli.commands.export._export_torchao_cli", "torchao"),("gguf-ud", "soup_cli.commands.export._export_gguf_advanced", "gguf"),("bitnet", "soup_cli.commands.export._export_bitnet_gguf", "gguf"),diff --git a/tests/test_issue1448_real_helpers.py b/tests/test_issue1448_real_helpers.pyindex c5c05b97..0471df59 100644--- a/tests/test_issue1448_real_helpers.py+++ b/tests/test_issue1448_real_helpers.py@@ -35,31 +35,6 @@ def _module(name, **attrs):return module-def _quantizer(module_name, cls_name, saved_name):- class _Model:- def quantize(self, *args, **kwargs):- return None-- def save_quantized(self, path):- _write(Path(path) / saved_name, 3000)-- return {- module_name: _module(- module_name,- BaseQuantizeConfig=lambda **kwargs: None,- **{cls_name: types.SimpleNamespace(from_pretrained=lambda *a, **k: _Model())},- )- }---def _gptq_modules():- return _quantizer("auto_gptq", "AutoGPTQForCausalLM", "gptq_model-4bit-128g.safetensors")---def _awq_modules():- return _quantizer("awq", "AutoAWQForCausalLM", "model.safetensors")--def _onnx_modules():def main_export(model_name_or_path, output, task):_write(Path(output) / "model.onnx", 100)@@ -106,10 +81,6 @@ CASES = {[("onnx", "model.onnx"), ("onnx", "model.onnx_data")]),"tensorrt": ([], _tensorrt_modules,[("tensorrt", "rank0.engine")]),- "awq": (["--calibration-data", "calib.jsonl"], _awq_modules,- [("awq", "model.safetensors")]),- "gptq": (["--calibration-data", "calib.jsonl"], _gptq_modules,- [("gptq", "model.safetensors")]),"torchao": (["--quant-config", "q.yaml"], dict,[("torchao", "pytorch_model.bin")]),"gguf-ud": (["--gguf-flavour", "Q4_0_4_4"], dict, [("gguf", "out.gguf")]),diff --git a/tests/test_issue338_awq_gptq_deprecated.py b/tests/test_issue338_awq_gptq_deprecated.pydeleted file mode 100644index 38ebdef2..00000000--- a/tests/test_issue338_awq_gptq_deprecated.py+++ /dev/null@@ -1,197 +0,0 @@-"""#338 -- AWQ and GPTQ export are deprecated, and the commands say so.--Both upstream projects are archived and neither extra installs next to the-train extra, so the two formats go away one release after this notice. Until-then they keep working: ``soup export --format awq / gptq`` prints the notice-first and then does what it did, and ``soup quantize --to awq / gptq`` prints-it next to the command it hands the user.-"""--from __future__ import annotations--import re--import pytest-from typer.testing import CliRunner--import soup_cli.commands.export as export_mod-from soup_cli.cli import app-from soup_cli.commands.export import (- DEPRECATED_FORMATS,- REPLACEMENT_FORMATS,- SUPPORTED_FORMATS,- deprecated_format_notice,-)-from soup_cli.config.deprecation import DEPRECATED_VALUE_REJECTION_VERSION--# Rich colours per character on a colour-capable runner and wraps at the-# terminal width, drawing box borders between the fragments of a wrapped help-# line. Strip ANSI escapes and box-drawing characters, then collapse-# whitespace, before any substring match on CLI output.-_ANSI_RE = re.compile(r"\x1b\[[0-9;?]*[A-Za-z]")-_BOX_RE = re.compile(r"[\u2500-\u257f]")--DEPRECATED = ("awq", "gptq")-# The formats the decision on #338 names as the way out.-REPLACEMENTS = ("gguf", "onnx", "tensorrt", "bitnet", "tq1_0")---def _plain(text: str) -> str:- """ANSI- and border-stripped, whitespace-collapsed CLI output."""- return " ".join(_BOX_RE.sub(" ", _ANSI_RE.sub("", text)).split())---class TestTheNotice:- def test_exactly_awq_and_gptq_are_deprecated(self) -> None:- assert sorted(DEPRECATED_FORMATS) == sorted(DEPRECATED)-- def test_the_deprecated_formats_still_run(self) -> None:- """Deprecated is not removed: the formats stay selectable for one more release."""- assert set(DEPRECATED) <= set(SUPPORTED_FORMATS)-- def test_the_replacements_are_the_ones_the_decision_names(self) -> None:- assert tuple(REPLACEMENT_FORMATS) == REPLACEMENTS-- def test_every_replacement_is_a_format_that_stays(self) -> None:- assert set(REPLACEMENT_FORMATS) <= set(SUPPORTED_FORMATS)- assert not set(REPLACEMENT_FORMATS) & set(DEPRECATED_FORMATS)-- @pytest.mark.parametrize("fmt", DEPRECATED)- def test_it_names_the_format_the_removal_and_every_replacement(self, fmt: str) -> None:- notice = deprecated_format_notice(fmt)- assert notice is not None- assert f"--format {fmt} is deprecated" in notice- assert f"will be removed in Soup v{DEPRECATED_VALUE_REJECTION_VERSION}:" in notice- for replacement in REPLACEMENTS:- assert re.search(rf"\b{re.escape(replacement)}\b", notice), (replacement, notice)-- @pytest.mark.parametrize("fmt", DEPRECATED)- def test_it_does_not_send_the_user_to_the_other_deprecated_format(self, fmt: str) -> None:- other = "gptq" if fmt == "awq" else "awq"- assert other not in deprecated_format_notice(fmt).lower()-- @pytest.mark.parametrize("fmt", DEPRECATED)- def test_it_says_why(self, fmt: str) -> None:- notice = deprecated_format_notice(fmt)- assert "archived upstream" in notice- assert f"the {fmt} extra cannot be installed next to the train extra" in notice-- @pytest.mark.parametrize("fmt", sorted(set(SUPPORTED_FORMATS) - set(DEPRECATED)))- def test_a_format_that_stays_has_no_notice(self, fmt: str) -> None:- assert deprecated_format_notice(fmt) is None-- @pytest.mark.parametrize("fmt", ["", "AWQ", "awq ", "exl2", "nope"])- def test_an_unknown_spelling_has_no_notice(self, fmt: str) -> None:- """The command lower-cases nothing: ``--format AWQ`` is refused as unsupported."""- assert deprecated_format_notice(fmt) is None-- def test_the_notice_carries_no_console_markup(self) -> None:- """It is printed through Rich: a square bracket in it would be read as a style."""- for fmt in DEPRECATED:- assert "[" not in deprecated_format_notice(fmt)---class TestExportPrintsIt:- @pytest.mark.parametrize("fmt", DEPRECATED)- def test_the_notice_comes_first_and_the_export_path_still_runs(self, fmt, tmp_path) -> None:- model_dir = tmp_path / "model"- model_dir.mkdir()-- result = CliRunner().invoke(app, ["export", "--model", str(model_dir), "--format", fmt])-- output = _plain(result.output)- assert f"Deprecated: --format {fmt} is deprecated" in output, (- result.output,- repr(result.exception),- )- # What the command did before, it still does: with no calibration data- # it stops at the same requirement, with the same exit code.- requirement = f"{fmt.upper()} export requires --calibration-data"- assert requirement in output- assert output.index("Deprecated:") < output.index(requirement)- assert result.exit_code == 1-- @pytest.mark.parametrize("fmt", DEPRECATED)- def test_the_notice_leads_when_the_extra_is_missing(self, fmt, tmp_path, monkeypatch) -> None:- """Most users meet these formats through the "not installed" message."""- model_dir = tmp_path / "model"- model_dir.mkdir()- cal_file = tmp_path / "cal.jsonl"- cal_file.write_text('{"text": "sample"}\n', encoding="utf-8")- monkeypatch.chdir(tmp_path)-- result = CliRunner().invoke(- app,- [- "export", "--model", str(model_dir), "--format", fmt,- "--calibration-data", str(cal_file),- ],- )-- output = _plain(result.output)- assert result.exit_code != 0- assert output.startswith(f"Deprecated: --format {fmt} is deprecated"), result.output-- @pytest.mark.parametrize("fmt", DEPRECATED)- def test_the_notice_is_printed_once(self, fmt, tmp_path) -> None:- model_dir = tmp_path / "model"- model_dir.mkdir()-- result = CliRunner().invoke(app, ["export", "--model", str(model_dir), "--format", fmt])-- assert _plain(result.output).count("is deprecated") == 1-- def test_a_format_that_stays_prints_no_notice(self, tmp_path, monkeypatch) -> None:- model_dir = tmp_path / "model"- model_dir.mkdir()- calls = []- monkeypatch.setattr(export_mod, "_export_onnx", lambda *args, **kwargs: calls.append(args))-- result = CliRunner().invoke(app, ["export", "--model", str(model_dir), "--format", "onnx"])-- assert result.exit_code == 0, (result.output, repr(result.exception))- assert len(calls) == 1- assert "deprecated" not in _plain(result.output).lower()-- def test_the_help_marks_both_formats(self) -> None:- result = CliRunner().invoke(app, ["export", "--help"])-- assert result.exit_code == 0, (result.output, repr(result.exception))- output = _plain(result.output)- assert "awq and gptq are deprecated" in output- # The release the help promises is the one the warnings promise.- assert f"removed in Soup v{DEPRECATED_VALUE_REJECTION_VERSION}" in output, output---class TestQuantizePrintsIt:- @pytest.mark.parametrize("fmt", DEPRECATED)- def test_it_still_prints_the_command_and_adds_the_notice(self, fmt: str) -> None:- result = CliRunner().invoke(app, ["quantize", "./out", "--to", fmt])-- output = _plain(result.output)- assert result.exit_code == 0, (result.output, repr(result.exception))- assert f"soup export --model ./out --format {fmt} --bits 4" in output- assert f"Deprecated: --format {fmt} is deprecated" in output-- @pytest.mark.parametrize("fmt", DEPRECATED)- def test_an_upper_case_target_gets_the_notice_too(self, fmt: str) -> None:- """``soup quantize`` lower-cases ``--to``, so the notice follows the canonical name."""- result = CliRunner().invoke(app, ["quantize", "./out", "--to", fmt.upper()])-- assert result.exit_code == 0, (result.output, repr(result.exception))- assert f"Deprecated: --format {fmt} is deprecated" in _plain(result.output)-- @pytest.mark.parametrize("fmt", ["gguf", "onnx", "tensorrt"])- def test_a_target_that_stays_prints_no_notice(self, fmt: str) -> None:- result = CliRunner().invoke(app, ["quantize", "./out", "--to", fmt])-- assert result.exit_code == 0, (result.output, repr(result.exception))- assert "deprecated" not in _plain(result.output).lower()-- def test_the_help_marks_both_targets(self) -> None:- result = CliRunner().invoke(app, ["quantize", "--help"])-- assert result.exit_code == 0, (result.output, repr(result.exception))- output = _plain(result.output)- assert "awq and gptq are deprecated" in output- assert f"removed in Soup v{DEPRECATED_VALUE_REJECTION_VERSION}" in output, outputdiff --git a/tests/test_onnx_tensorrt_export.py b/tests/test_onnx_tensorrt_export.pyindex 6349cee5..86532819 100644--- a/tests/test_onnx_tensorrt_export.py+++ b/tests/test_onnx_tensorrt_export.py@@ -24,8 +24,8 @@ class TestExportFormats:assert "tensorrt" in SUPPORTED_FORMATSdef test_format_count(self):- """v0.53.1 — 7 prior formats + torchao + gguf-ud = 9."""- assert len(SUPPORTED_FORMATS) == 9+ """v0.77 — 9 prior formats - awq - gptq = 7."""+ assert len(SUPPORTED_FORMATS) == 7assert "bitnet" in SUPPORTED_FORMATSassert "tq1_0" in SUPPORTED_FORMATSassert "torchao" in SUPPORTED_FORMATSdiff --git a/tests/test_v0404_part_a.py b/tests/test_v0404_part_a.pyindex 362df77f..8a6c3436 100644--- a/tests/test_v0404_part_a.py+++ b/tests/test_v0404_part_a.py@@ -226,7 +226,7 @@ class TestExportHelperSignatures:assert params["trust_remote_code"].default is False@pytest.mark.parametrize(- "fn_name", ["_export_onnx", "_export_tensorrt", "_export_awq", "_export_gptq"],+ "fn_name", ["_export_onnx", "_export_tensorrt"],)def test_export_helper_signature(self, fn_name: str):import inspect