Skip to content

[6/n] Replace skip-softmax calibration formula#1541

Draft
kaix-nv wants to merge 1 commit into
mainfrom
kaix/skip_softmax_calib_formula
Draft

[6/n] Replace skip-softmax calibration formula#1541
kaix-nv wants to merge 1 commit into
mainfrom
kaix/skip_softmax_calib_formula

Conversation

@kaix-nv
Copy link
Copy Markdown
Contributor

@kaix-nv kaix-nv commented May 25, 2026

What does this PR do?

Type of change: ?
Replace the old calibration formula from t = a * exp(b * S) / L to t = 1 - exp(-a * (S / (1 - S))^b / seq_k^c. The old calibration breaks at short context. We can clamp at runtime or add 1 - exp(-...) wrapper around t because 1 − exp(−c/L^α) \in (0, 1)  strictly, so we don't need to hardcode where to cutoff.

Usage

Testing

The calibration curve are shown below.

calibration_qwen3_30b_a3b calibration_qwen3_8b calibration_llama_3_1_8b

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.).

  • Is this change backward compatible?: ✅ / ❌ / N/A
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: ✅ / ❌ / N/A
  • Did you write any new necessary tests?: ✅ / ❌ / N/A
  • Did you update Changelog?: ✅ / ❌ / N/A
  • Did you get Claude approval on this PR?: ✅ / ❌ / N/A

Additional Information

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 25, 2026

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7e90e3b7-0d52-46cd-991a-70324a66a933

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kaix/skip_softmax_calib_formula

Comment @coderabbitai help to get the list of available commands and usage tips.

…1 - S))^b / L^c)

Signed-off-by: Kai Xu <kaix@nvidia.com>
@kaix-nv kaix-nv force-pushed the kaix/skip_softmax_calib_formula branch from 14d4b63 to a42daf0 Compare May 25, 2026 01:47
@github-actions
Copy link
Copy Markdown
Contributor

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://NVIDIA.github.io/Model-Optimizer/pr-preview/pr-1541/

Built to branch gh-pages at 2026-05-25 01:50 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

❌ Patch coverage is 84.26966% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.80%. Comparing base (16a0130) to head (a42daf0).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../torch/sparsity/attention_sparsity/plugins/vllm.py 0.00% 5 Missing ⚠️
...kernels/sparsity/attention/ltx_triton_attention.py 50.00% 3 Missing ⚠️
.../attention_sparsity/methods/triton_skip_softmax.py 66.66% 3 Missing ⚠️
...s/sparsity/attention/diffusers_triton_attention.py 33.33% 2 Missing ⚠️
...rsity/attention_sparsity/calibration/calibrator.py 97.82% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1541      +/-   ##
==========================================
- Coverage   76.81%   76.80%   -0.02%     
==========================================
  Files         476      476              
  Lines       51891    51905      +14     
==========================================
+ Hits        39860    39864       +4     
- Misses      12031    12041      +10     
Flag Coverage Δ
unit 52.71% <84.26%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kaix-nv kaix-nv changed the title Replace skip-softmax calibration with threshold = 1 - exp(-a * (S / (1 - S))^b / L^c) [6/n] Replace skip-softmax calibration with threshold = 1 - exp(-a * (S / (1 - S))^b / L^c) May 25, 2026
@kaix-nv kaix-nv changed the title [6/n] Replace skip-softmax calibration with threshold = 1 - exp(-a * (S / (1 - S))^b / L^c) [6/n] Replace skip-softmax calibration formula May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant