Repository navigation
Conversation
Signed-off-by: Asim Kadav <19524+asimkadav@users.noreply.github.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (8)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughAdds an experimental search for softmax-equivalent linear output-head shifts. The search independently quantizes each candidate, measures validation KL against the original head, and returns the candidate with the lowest KL. Documentation, a synthetic example, and CPU and CUDA tests accompany the implementation. ChangesOutput-Head Search
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Caller
participant search_head
participant ModelOpt
participant head_kl
Caller->>search_head: Head, fit states, validation states, and quantization config
loop Each coefficient
search_head->>ModelOpt: Calibrate an independent candidate with fit states
search_head->>head_kl: Measure candidate KL on validation states
head_kl-->>search_head: Validation KL
end
search_head-->>Caller: Selected candidate, coefficient, and KL curve
Merge Risk: ⚪ Minimal · up to No actionable issue is established for this opt-in feature. Mergeability remains subject to normal validation of its supported configurations. 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 5 files. (3 skipped: 3 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 OSV Scanner (2.6.0)experimental/softmax_reparameterization/requirements.txtOSV Scanner exited with code 128 without a usable report Comment |
Signed-off-by: Asim Kadav <19524+asimkadav@users.noreply.github.com>
What does this PR do?
Type of change: new feature (experimental).
Low-bit quantization can assign different prediction errors to functionally equivalent output heads. This adds a head-only implementation of Softmax Reparameterization for Output-Head Quantization: subtract a scalar multiple of the vocabulary-row mean, independently fit the same ModelOpt quantizer for each candidate, and select by forward KL to the original head on disjoint validation states.
The implementation supports plain linear-softmax heads and weight-only
max/gptqcalibration. It preserves the original head and tied embeddings, returns the full validation curve, and retains the selected calibrated artifact without refitting. Zero is required in the candidate grid, guaranteeing no worse measured validation KL than the unshifted candidate; held-out improvements are not guaranteed.This is an opt-in experimental addition. It changes no default quantization configs or LM-head exclusions. Nonlinear logit paths, grouped search, full-model adapters, packed export, and serving benchmarks are outside this PR. The paper's reported results should not be interpreted as ModelOpt measurements.
Usage
States are final hidden vectors shaped
[tokens, hidden_width]; the caller enforces disjoint articles across fitting, validation, and test. The returned one-layer Sequential supports ModelOpt save/restore. A runnable synthetic example is included.Testing
python -m pytest -o addopts='' tests/unit/torch/quantization/test_softmax_reparameterization.py -q— 3 passed.python -m pytest -o addopts='' tests/unit/torch/quantization/test_softmax_reparameterization.py tests/gpu/torch/quantization/test_softmax_reparameterization_cuda.py -q).Before your PR is "Ready for review"
Additional Information
Paper: https://arxiv.org/abs/2609.31291
CPU and H100 validation completed. Maintainer feedback on the experimental API is welcome. Packed deployment support is not claimed. NVIDIA-hosted CI requires maintainer authorization for this fork PR.
Summary by CodeRabbit
New Features
Documentation
Tests