Add Aumann-Shapley sensitivity scoring method to auto_quantize - #2183
Draft
joshua-hill wants to merge 2 commits into
Draft
Add Aumann-Shapley sensitivity scoring method to auto_quantize#2183joshua-hill wants to merge 2 commits into
joshua-hill wants to merge 2 commits into
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
joshua-hill
force-pushed
the
feat/aumann-shapley-autoquant
branch
4 times, most recently
from
August 13, 2026 03:34
6cc1c8f to
4576f44
Compare
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>
TRT-LLM fuses the MLA low-rank input projections (DeepSeek/GLM lineage) into a single fused_qkv_a_proj_with_mqa GEMM, so auto_quantize must assign both shards one shared quantization format; without this rule any scoring method can emit checkpoints the runtime cannot fuse. Signed-off-by: Joshua Hill <joshua.hill@baseten.co>
joshua-hill
force-pushed
the
feat/aumann-shapley-autoquant
branch
from
August 13, 2026 13:38
4576f44 to
cb43158
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Type of change: new feature
Adds
method="aumann_shapley"tomtq.auto_quantize: label-free sensitivity scoring viaAumann-Shapley path-integral damage attributions, so every allocation carries a
predicted_damagequote in calibration-KL units (nats) rather than only an unitless score.Damage is measured as KL divergence against the model's own reference outputs — the reference
keeps any fixed or forced-single-format groups quantized, so scores are incremental KL relative
to the resolved baseline (
{"type": "unquantized"}when nothing is pinned). At each midpointnode
t = (k + 1/2) / num_path_nodesof the joint quantization path, every scored modulepropagates
y + t * (Q(y) - y)using detached local-replay differences, and one backward passaccumulates
<dL/dy, Q(y) - y>per (group, format). The path integral is required because a KLloss has
dKL = 0exactly at the unquantized point — that is precisely why the existinggradientmethod must square its Taylor term into a Fisher proxy and therefore needs labels,while this method does not.
A measured aggressive corner anchors a coverage link
damage = c * (1 - exp(-sum(b))); afixed-point inversion turns attributions into per-group log-headroom written into
candidate_stats["scores"], so the standard solve is the coverage-optimal allocation. Solverscores are projected onto the monotone compression ladder so quotes stay conservative. The quote
is an internal-model estimate, not a bound on realized deployment KL.
Cost per batch is one reference forward, one corner forward, and one forward+backward per
(candidate format, path node) — independent of how many configurations the solver later
considers.
Supporting changes:
auto_quantize(method_options=...)argument (optional), validated against eachsearcher's declared
method_options_keysso core inputs cannot be overridden. Supported keys:num_path_nodes,damage_link,solver(lpexact /dpdeterministic grid-approximate),and
max_predicted_damage(minimize weight cost subject to a damage bound; mutually exclusivewith an
effective_bitsconstraint).AUTO_QUANTIZE_SEARCHERSinmodelopt.torch.quantization.algorithms) instead of hardcoded dispatch; methods registerthemselves.
gradient/kl_divbehavior is unchanged.QuantRecipe.checkpoint_signature, so identical customformats 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 still
allowing solver-only re-solves.
q_a_proj/kv_a_proj_with_mqaprojections inauto_quantize.TRT-LLM fuses these low-rank input projections (DeepSeek / GLM lineage) into a single
fused_qkv_a_proj_with_mqaGEMM, so both shards must be assigned one shared format; withoutthis rule any scoring method can emit checkpoints the runtime cannot fuse.
An efficient implementation of the estimator in https://arxiv.org/abs/2607.12266
(overview,
thread), validated empirically
against it; implementation details are documented in the module docstring.
Vocab-sharded (Megatron-TP) losses raise
NotImplementedErrorpending an autograd-correctvocab-parallel log-softmax.
Usage
Bound the predicted damage instead of the bit budget (mutually exclusive with
effective_bits):Also selectable from
examples/hf_ptq/hf_ptq.pyvia--auto_quantize_method aumann_shapley, andfrom an AutoQuantize recipe via
auto_quantize_method: aumann_shapley.Testing
tests/unit/torch/quantization/test_autoquant_shapley.py(new): config parity with the standardbuilder (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.
tests/unit/torch/quantization/test_autoquant.py: method parametrizations extended (21 newcases); the existing
gradient/kl_divcases pass unmodified, confirming no behavior changefor the current methods.
Before your PR is "Ready for review"
Make sure you read and follow Contributor guidelines and your commits are signed (
git commit -s -S).Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded
trust_remote_code=True,torch.load(..., weights_only=False),pickle, etc.).CONTRIBUTING.md: ✅Additional Information
Draft — opened for early feedback on the method-registry and
method_optionsplumbing beforefinal review. Rebased onto
main.🤖 Generated with Claude Code