-
Notifications
You must be signed in to change notification settings - Fork 56
msa: GPT-6 #946
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
Merged
Merged
msa: GPT-6 #946
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d3062ef
minimax msa.
sayakpaul 188f598
msa: add freshness mapping entry, declare vendored quack license
sayakpaul 69466f7
flaking my way through
sayakpaul ae00bbf
licensing fix
sayakpaul fb6834d
Merge branch 'main' into minimax-msa
sayakpaul 5f57cbf
Merge branch 'main' into minimax-msa
sayakpaul 60bb756
Merge branch 'main' into minimax-msa
sayakpaul 1a2e034
Merge branch 'main' into minimax-msa
sayakpaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| --- | ||
| library_name: kernels | ||
| {% if license %}license: {{ license }} | ||
| {% endif %}--- | ||
|
|
||
| This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. | ||
|
|
||
| ## How to use | ||
| {% if functions %} | ||
|
|
||
| ```python | ||
| # make sure `kernels` is installed: `pip install -U kernels` | ||
| from kernels import get_kernel | ||
|
|
||
| kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) | ||
| {{ functions[0] }} = kernel_module.{{ functions[0] }} | ||
|
|
||
| {{ functions[0] }}(...) | ||
| ``` | ||
| {% else %} | ||
|
|
||
| Usage example not available. | ||
| {% endif %} | ||
|
|
||
| ## Available functions | ||
| {% if functions %} | ||
| {% for func in functions %} | ||
| - `{{ func }}` | ||
| {% endfor %} | ||
| {% else %} | ||
|
|
||
| Function list not available. | ||
| {% endif %} | ||
| {% if layers %} | ||
|
|
||
| ## Available layers | ||
| {% for layer in layers %} | ||
| - `{{ layer }}` | ||
| {% endfor %} | ||
| {% endif %} | ||
|
|
||
| ## Benchmarks | ||
| {% if has_benchmark %} | ||
|
|
||
| Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. | ||
| {% else %} | ||
|
|
||
| No benchmark available yet. | ||
| {% endif %} | ||
| {% if upstream %} | ||
|
|
||
| ## Source code | ||
|
|
||
| Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. | ||
| {% endif %} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| --- | ||
| license: mit | ||
| tags: | ||
| - kernel | ||
| --- | ||
|
|
||
| ## MSA — MiniMax Sparse Attention (SM100) | ||
|
|
||
| CuTe-DSL sparse attention kernels from [MiniMax MSA](https://github.com/MiniMax-AI/MSA) | ||
| (`python/fmha_sm100/cute`), packaged as a Hub kernel. | ||
|
|
||
| The package provides: | ||
|
|
||
| - `sparse_atten_func` — block-sparse prefill attention. | ||
| - `sparse_atten_nvfp4_kv_func` — block-sparse prefill with NVFP4 K/V. | ||
| - `sparse_decode_atten_func` / `SparseDecodePagedAttentionWrapper` — block-sparse | ||
| paged FP8 decode. | ||
| - `fp4_indexer_block_scores` — FP4 block-score indexer (top-k selection is | ||
| caller-owned). | ||
| - `build_k2q_csr` / `SparseK2qCsrBuilderSm100` — q2k indices → CSR + schedule | ||
| construction. | ||
| - NVFP4 quantization helpers (`quantize_bf16_to_nvfp4_128x4`, ...). | ||
|
|
||
| The host-side helper kernels (the k2q CSR builder and the paged decode | ||
| split-KV scheduler) are precompiled Torch ops. The attention kernels are | ||
| CuTe DSL Python and are compiled at runtime through `nvidia-cutlass-dsl`. | ||
|
|
||
| Only NVIDIA SM100 (Blackwell) GPUs are supported. | ||
|
|
||
| Note: the dense FMHA stack of upstream MSA (`fmha_sm100`'s `csrc/` runtime-JIT | ||
| kernels) is not part of this package; it relies on runtime `nvcc` compilation, | ||
| which Hub kernels do not support. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```python | ||
| import torch | ||
| from kernels import get_kernel | ||
|
|
||
| msa = get_kernel("kernels-community/msa") | ||
|
|
||
| out = msa.sparse_atten_func(...) | ||
| ``` | ||
|
|
||
| See the [upstream documentation](https://github.com/MiniMax-AI/MSA) for the | ||
| full API and benchmarks. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| [general] | ||
| name = "msa" | ||
| backends = ["cuda"] | ||
| # MSA itself is MIT; the vendored quack modules | ||
| # (torch-ext/msa/quack) are Apache-2.0. The Hub only accepts a single | ||
| # license identifier in model card metadata, so use "other". | ||
| license = "other" | ||
| python-depends = ["tvm-ffi"] | ||
| upstream = "https://github.com/MiniMax-AI/MSA" | ||
| version = 0 | ||
|
|
||
| [general.hub] | ||
| repo-id = "kernels-community/msa" | ||
|
|
||
| [general.cuda] | ||
| minver = "12.8" | ||
| python-depends = ["nvidia-cutlass-dsl"] | ||
|
|
||
| [torch] | ||
| src = [ | ||
| "torch-ext/torch_binding.cpp", | ||
| "torch-ext/torch_binding.h", | ||
| ] | ||
|
|
||
| # Host-side helper kernels (CSR builder and decode scheduler). The | ||
| # attention kernels themselves are CuTe DSL Python and are compiled at | ||
| # runtime through nvidia-cutlass-dsl; only SM100 is supported. | ||
| [kernel.msa] | ||
| backend = "cuda" | ||
| cuda-capabilities = ["10.0"] | ||
| depends = ["torch"] | ||
| include = ["torch-ext"] | ||
| src = [ | ||
| "csrc/build_k2q_csr.cu", | ||
| "csrc/build_decode_schedule.cu", | ||
| ] | ||
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Also doesn't work on later Blackwell? (12.0, etc.)
Uh oh!
There was an error while loading. Please reload this page.
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.
I kept it because the repository explicitly states it and also the compiler flags have
-arch=sm_100everywhere in upstream.