agentleFS
melissa-pereira-deelmelissa-pereira-deel/tiny-model-lab/.claude/skills/quantization-strategy/SKILL.md

quantization-strategy

Skill0 starsChanged 56 days agoMITView on GitHub

Decide between post-training quantization and quantization-aware training, pick a bit width, and compress a model to fit a size budget without silently destroying accuracy. Use when a model is over its size budget, when targeting sub-8-bit weights, or before any export to a browser or embedded target.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If over budget, try PTQ int8 first.

    line 27

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Quantization strategy

Quantization is storing weights at lower precision. Think of it as choosing how many decimal places to keep: at some point the number is still useful, and a little past that it is not.

The decision

Bit widthMethodExpect
int8Post-training (PTQ)Usually near-lossless. Try this first, it takes minutes.
int6QAT strongly preferredWorkable with training-time simulation. gpu-lexer ships int6 — through a hand-written WGSL forward pass, not an exporter.
int4 and belowQAT requiredPTQ degrades badly here. Budget for retraining.

Below 8 bits, check your export path has the width before you train for it. int8 is the one width everything supports. Sub-8-bit is a property of the target, not of the model: WGSL takes whatever you compile into it, Core ML palettizes down to 1 bit, and an ONNX graph has int8 and int4 but nothing at 6. Discovering this after a QAT run is an expensive way to read a table.

PTQ quantizes an already-trained model. Cheap, immediate, and the right first attempt.

QAT simulates quantization during training, so the model learns weights that survive it. It uses a straight-through estimator to keep gradients flowing through the non-differentiable rounding step. Costs a retrain, holds up at 4 bits and below.

Order of operations

  1. Measure the exported artifact size. Not parameters — bytes on disk, summing directories for .mlpackage or split ONNX.
  2. If over budget, try PTQ int8 first.
  3. Still over: QAT at the next width down.
  4. Still over: reduce width or depth, then prune.
  5. Re-run the baseline gate after every step. Compression that breaks accuracy is not a win, and it is easy to miss because the size number moves in the direction you wanted.

The trap

Quantization failures are quiet. The model loads, runs, produces plausible output, and is worse in a way no exception surfaces. Always compare the quantized model against the full-precision one on the same held-out set and report the disagreement rate as a number.

There is no universal threshold for that number, and this repo does not invent one. What counts as acceptable depends on what the disagreements are — a lexer that mislabels a comment costs a wrong colour, a classifier gating an irreversible action costs more. State the tolerance you chose for this task alongside the rate, so the next person is arguing with a decision rather than guessing at one. It is deliberately not a gate: the harness would have to keep the full-precision model around to check it, and the number that matters is a judgement about the product, not arithmetic about the model.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.