-
Notifications
You must be signed in to change notification settings - Fork 204
[OMNIML-2852] [2/n] Add Core Sparse Attention Infrastructure #527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #527 +/- ##
==========================================
+ Coverage 74.64% 74.95% +0.31%
==========================================
Files 183 192 +9
Lines 18542 18939 +397
==========================================
+ Hits 13840 14196 +356
- Misses 4702 4743 +41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
54bfe2c to
0ce1376
Compare
Signed-off-by: Kai Xu <kaix@nvidia.com>
Signed-off-by: Kai Xu <kaix@nvidia.com>
fc9d285 to
5d027e0
Compare
|
Hi @kaix-nv could you further split this code change? This PR has 3000+ lines of code change and many file moves |
|
|
||
|
|
||
| # Create registry for sparse attention modules | ||
| SparseAttentionRegistry = _DMRegistryCls("SparseAttention", SparseAttentionModule) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a single registry for all Sparsity algorithms and modes and then use top-level mts.sparsify(model, mode=...) so all algorithms (e.g. weight or attention sparsify) are invoked by single shared API instead of separate API per algorithm?
| run_example_command(cmd_parts, "llm_sparsity/attention_sparsity") | ||
|
|
||
|
|
||
| @minimum_gpu(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for 1-gpu marker. All tests are run on 1 or more gpus only
| import modelopt.torch.sparsity.attention_sparsity as sparse_attn | ||
|
|
||
| # Skip all tests if GPU is not available | ||
| pytestmark = pytest.mark.skipif(not torch.cuda.is_available(), reason="GPU not available") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests inside tests/gpu dont need a gpu check. Its assumed it is run only on gpu enabled machines.
Same applies to all test files
| hidden_size=512, | ||
| intermediate_size=1024, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need such large hidden and intermediate size? Can we use 32/64 instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests seem unnecessary
What does this PR do?
Type of change: ?
New feature
Overview: ?
This PR provides a sparse attention support in ModelOpt for applying attention sparsity through skip softmax method, enabling inference speedups for LLMs.
Key Features:
Design doc
Usage
Testing
Unit Test
ALL PASSED.
Accuracy
Benchmark: MMLU
Model: Qwen/Qwen3-4B
Cmd: python mmlu.py --model_name causal --model_path Qwen/Qwen3-4B --sparse_cfg SKIP_SOFTMAX_DEFAULT
Before your PR is "Ready for review"
Additional Information