lnn-quant-training

Builds, diagnoses, and validates Linger quantization-aware training and ONNX export workflows.

Updated Aug 7, 2026
One-click install
npx skills add https://github.com/LISTENAI/lnn_skills --skill lnn-quant-training-listenai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lnn-quant-training
Source: https://github.com/LISTENAI/lnn_skills/tree/main/lnn-quant-training
Command: npx skills add https://github.com/LISTENAI/lnn_skills --skill lnn-quant-training-listenai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, numpy, onnx, pyyaml, and includes scripts (resource) and references (resource) components.

What problem does it solve? Converting a PyTorch float model into a deployable quantized model with the Linger 3.x toolchain involves many failure points: misconfigured YAML, uninitialized MOM/TQT quantizers, accuracy drops, and broken ONNX exports. This Skill turns quantization-aware training into a closed-loop engineering process with acceptance criteria, diagnostics, and validation gates. ## Core Features & Use Cases - End-to-end QAT workflow: Guides float baseline setup, constrain training, MOM/TQT quantization initialization, QAT fine-tuning, and linger.onnx.export with strict checkpoint and optimizer rebuild rules. - Accuracy recovery and mixed precision: Diagnoses float-to-constrained-to-QAT error stages, locates sensitive layers, and applies YAML part-based mixed precision or const_module/quant_module overrides. - Executable inspection tools: Ships scripts to generate validated QAT YAML configs, audit quantizer state in checkpoints, compare float vs quantized outputs, and inspect Linger custom-domain ONNX graphs. - Use Case: A model's 8-bit QAT accuracy misses its target. Use this Skill to audit the checkpoint for uninitialized quantizers, run a stage-level mixed-precision sweep, and re-export with ONNX attribute validation before Thinker packaging. ## Quick Start Use the lnn-quant-training skill to convert my PyTorch float model into an 8-bit Linger QAT model, recover any accuracy loss, and validate the exported ONNX graph.

Frequently Asked Questions about lnn-quant-training

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a PyTorch float model to a Linger QAT model?

Train or load a float baseline, optionally run linger.trace_layers for Conv-BN fusion, call linger.constrain for short fine-tuning, then linger.init to insert quantizers. Rebuild the optimizer after each structural change and fine-tune from roughly 0.1x the float learning rate.

How do I fix accuracy loss after quantization-aware training?

First identify whether the drop occurs at float-to-constrained, constrained-to-QAT, or export/runtime stages. Then try lower QAT learning rates, clamp value sweeps, stage-level mixed precision to locate sensitive layers, and distillation from a frozen float teacher, changing one variable per experiment.

What is the difference between MOM and TQT quantizers in Linger?

MOM updates running_data statistics through training forward passes and computes power-of-two scales, while TQT uses a learnable learning_data parameter requiring optimizer inclusion and single-batch calibration. TQT training requires the NATIVE or CUDA_GS backend since CUDA does not return learning_data gradients.

Can I run Linger-exported ONNX models with ONNX Runtime?

No, Linger ONNX graphs contain custom-domain quant ops that standard ONNX Runtime cannot execute. Validate with the ONNX checker and quant attribute audit, then use Thinker's tpacker and tvalidator for packaging and runtime consistency checks.

How do I configure mixed precision quantization in Linger YAML?

Define partN sections with module names from model.named_modules(), each containing complete quant_info and clamp_info fields since omitted fields fall back to built-in defaults. Parts match by exact name or subtree prefix with first-match priority, and the generate_qat_config.py script expands parts automatically.

Why does my QAT checkpoint fail to load or show invalid scales?

Check missing_keys and unexpected_keys instead of using strict=False, and verify fusion order and config match training. Scales equal to one, non-positive, or non-finite indicate uninitialized MOM quantizers or missing calibration, which the inspect_quant_checkpoint.py script reports.