Commit b0580a3
committed
feat: Aumann-Shapley sensitivity scoring method for auto_quantize
Adds method='aumann_shapley': label-free sensitivity scoring via Aumann-Shapley
path-integral damage attributions (KL divergence against the model's own
unquantized outputs, or the fixed_quantization_config baseline when supplied),
with a measured-corner coverage calibration so every allocation carries a
predicted_damage quote in calibration units with recorded validity, anchored
to reproduce the measured corner. Scores all candidate formats in one
reference forward, one corner forward, and one fwd+bwd per (format, path
node) per batch using the same local-replay mechanism as the gradient method;
a KL loss requires path integration because its gradient is exactly zero at
the unquantized point. This is an efficient implementation of the estimator in
https://arxiv.org/abs/2607.12266, validated empirically against it;
implementation details are documented in the module docstring.
Method-specific settings ride in a new optional auto_quantize(method_options=)
dict, validated against each searcher's declared method_options_keys so core
inputs cannot be overridden: num_path_nodes, damage_link, a deterministic
grid-approximate DP solver alternative to the LP, and max_predicted_damage
(minimize weight cost subject to predicted damage <= bound, conservatively
rounded and mutually exclusive with an effective_bits constraint). Internal
format tables are keyed by QuantRecipe.checkpoint_signature so identical
custom formats under different auto-generated names resolve to one format; a
scoring signature in the search state rejects checkpoint resumes that would
change what stored scores mean while allowing solver-only re-solves.
The hardcoded method dispatch becomes a registry (AUTO_QUANTIZE_SEARCHERS) so
methods register themselves; gradient/kl_div behavior is unchanged (existing
suite passes as-is). Vocab-sharded (Megatron-TP) losses raise
NotImplementedError pending an autograd-correct vocab-parallel log-softmax.
Tests: method parametrizations extended in test_autoquant.py (21 new cases);
test_autoquant_shapley.py pins config parity with the standard builder
(dict-for-dict), the path-integral completeness diagnostic, corner anchoring
under incomplete attributions, damage-bound certification, solver optimality
contracts against brute force, custom-format identity, heterogeneous-ladder
flagging, exact-zero and tiny-attribution inversion behavior,
scoring-signature resume guards, and method-option validation.
Signed-off-by: Joshua Hill <joshua.hill@baseten.co>1 parent 96b4aac commit b0580a3
9 files changed
Lines changed: 2015 additions & 32 deletions
File tree
- examples/hf_ptq
- modelopt
- recipe
- torch/quantization
- tests/unit/torch/quantization
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
385 | | - | |
| 385 | + | |
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
453 | | - | |
| 453 | + | |
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
498 | | - | |
| 498 | + | |
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
| |||
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
510 | | - | |
| 510 | + | |
| 511 | + | |
511 | 512 | | |
512 | 513 | | |
513 | 514 | | |
| |||
1574 | 1575 | | |
1575 | 1576 | | |
1576 | 1577 | | |
1577 | | - | |
| 1578 | + | |
1578 | 1579 | | |
1579 | 1580 | | |
1580 | 1581 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
261 | 263 | | |
262 | 264 | | |
263 | 265 | | |
| |||
0 commit comments