Preface¶
In the DSH workflow for model inference deployment, quantization is often a necessary step: using PTQ to compress a checkpoint to tiers like INT4, and then validating throughput on servers like vLLM. The common practice is to directly run llmcompressor or AutoAWQ recipes, observing how much perplexity drops and how much stress testing speeds up—but “looking good on paper” does not mean “the measurement is valid”: a source model with truncated or anomalous weights might output a uniform distribution, resulting in perplexity identical bit-for-bit to the baseline, leading to a false sign-off of “zero precision loss.” inference-quantization is a DSH workflow plugin released by maintainer xiciyang, positioned as the “proof layer” beyond quantization: leakage-free calibration splits, independent accuracy and performance gates, bounded auto-degradation, hash-chain auditing, and rollback; it defaults to using llmcompressor for AWQ + INT4 within a container, and the real-machine path requires GPU, Docker, and a verified quantization image.
What is this¶
In one sentence: given a checkpoint, accuracy tolerance, and performance targets, it runs PTQ and signs off only after passing dual gates, or returns a clear failure code.
- Plugin Name:
xiciyang/inference-quantization(npm package@xiciyang/inference-quantization, version 0.1.0) - Maintainer: xiciyang
- Category: Workflow (Community Directory SkillHub Plugin Page)
- Source Code: GitHub — xiciyang/inference-quantization
- Runtime: Node built-in modules, zero additional npm dependencies; Engine requirements Node
>=20.11.0, DSH>=0.2.0 <0.3.0; License MIT
If you only need the quantization script itself, the README explicitly states this plugin is not suitable—it does not replace llmcompressor recipes but focuses on gates, degradation, auditing, and rollback surrounding quantization.
Core Features¶
End-to-End Flow¶
Below is the approximate sequence when a quantize run succeeds (consistent with the README flowchart):
- Source model content hash baseline + structural pre-check (confirming it is a complete model, not just a “file that can be opened”)
- Dataset preparation: De-leak by content sha256; the intersection of the calibration set and test set must be empty, with no manual override.
- Method selection: Default AWQ + INT4, performing PTQ via llmcompressor inside a container; the source directory is mounted as read-only.
- Accuracy gate: Compare perplexity degradation on the same test set; thresholds must be passed by the caller or come from
gates.yaml, with no default thresholds inside the plugin. - Performance gate: After accuracy passes, invoke
inference-servingvia MCP to start a real endpoint and measure throughput. - Dual-gate decision: Whether numerical targets are met, and whether the measurement is valid (see below).
- Result: If passed, write to the quantization matrix and mark as verified; if failed, attempt degradation along the chain, or rollback.
Two Lines of Defense Independent of “Numbers”¶
| Defense Line | Question Answered | Failure Code |
|---|---|---|
| Source Model Structural Pre-check | Is the content a complete model (truncation, entire blocks zeroed, layer count mismatch, missing shards, etc.) | E_SOURCE_MODEL_INVALID |
| Measurement Validity Gate | Is this measurement valid (uniform output, no discriminative power, independent of input, unhealthy weights, score not evaluated, etc.) | E_MEASUREMENT_INVALID |
Neither can be degraded: switching quantization tiers won’t solve them, and the process will abort directly. status=verified requires that numerical targets are met, the decision is “sign”, and measurement validity holds simultaneously.
Accuracy, Performance, and Other Hard Gates¶
- De-leak:
E_CALIB_LEAKAGE_DETECTED; the criterion is an empty intersection of content sha256, with independent host-side re-verification of the container’s conclusion. - Source Model Read-Only: Content hash the source directory before and after quantization; if changed,
E_SOURCE_MODEL_MODIFIED. - Thresholds: If
--max-accuracy-drop-pctis not passed andgates.yamlis not configured →E_THRESHOLD_NOT_PROVIDED. - Serving: Depends on
inference-serving(MCP); if not found, reportsE_SERVING_UNAVAILABLE. - Image: If the image is missing or unverified →
E_METHOD_UNAVAILABLE; it will not silently “pass”.
Bounded Degradation¶
Chain: awq-w4a16(L1) → int8-w8a8(L2) → fp8-dynamic(L3) → w8a16(L4) → QAT Plan(L5) → Rollback. Maximum 5 levels; Level 5 only produces a QAT plan (E_QAT_REQUIRES_APPROVAL) and does not execute training. Each run writes a hash-chain audit trail.
MCP and Accepting Existing Checkpoints¶
Tools registered on the DSH side include inference_quantization_quantize, validate, get_report, list, rollback, qat_plan, etc. validate (available since 2026-09-29) reuses the same gate semantics as quantize for existing quantized outputs, without re-quantizing or writing to the quantization matrix; records are placed in <runDir>/validate-existing/<id>.json.
Installation and Enablement¶
The official README provides two ways to add this to DSH:
dsh plugin --profile <name> add github:xiciyang/inference-quantization
Installing from a local package built from the repository (README notes it is not yet published to npm, so npm install -g is currently unavailable):
git clone https://github.com/xiciyang/inference-quantization.git
cd inference-quantization && npm pack
dsh plugin --profile <name> add ./xiciyang-inference-quantization-0.1.0.tgz
As a DSH plugin example: dsh plugin --profile web add <tgz>, effective after restart.
The lookup order for inference-serving is: options.servingPath → ~/.ai-infra/config/serving-path.txt → sibling ../inference-serving → node_modules/.
Typical Usage¶
First perform an environment self-check, then verify the quantization image, and finally initiate quantization on the model directory and view the matrix and report:
inference-quantization doctor
inference-quantization image verify --build
inference-quantization quantize /path/to/models/<model> \
--max-accuracy-drop-pct 5 --min-perf-gain-pct 20
inference-quantization list --json
inference-quantization report <runId>
Common subcommands also include: dataset prepare|verify|list, rollback <selector>, qat (plan only), audit-verify, contract. Exit codes: 0 success, 1 business failure, 2 usage error, 3 confirmation required.
The first run generates an empty template at ~/.ai-infra/config/gates.yaml; if max_accuracy_drop_pct / min_perf_gain_pct are null, they must be explicitly passed via CLI. DSH inline config can set fields like root, quantImage, outputRoot, servingPath, maxDegradeSteps; unknown keys or type errors will fail during loading.
Use Cases and Notes¶
Suitable for: Teams that need to bind “Quantization + Accuracy Proof + Real-machine Performance Proof + Auditing” into a single rollback-capable pipeline within the DSH / MCP workflow, and can accept the prerequisites of GPU, Docker, and inference-serving.
Not suitable for: Scenarios where you only want to locally try AWQ recipes and don’t care about leakage splits, gates, or auditing—using llmcompressor directly is lighter.
Security and Permissions: The plugin runs with the current DSH process permissions; manifest.yaml grades whitelisted capabilities (e.g., quantize involves model:read, gpu:write, disk:write, etc.). Please read the source code and MIT license before installation, and confirm that the image source and network policies comply with your environment. The community directory SkillHub is an independent site and has no official affiliation with DeepSeek / High-Flyer.
Conclusion¶
inference-quantization wraps PTQ in a provable process: leakage-free calibration, independent accuracy and performance gates, measurement validity checks, bounded degradation, and hash-chain auditing. For trials or command details, you can refer to the SkillHub Directory Page and the GitHub Repository README.