-
Notifications
You must be signed in to change notification settings - Fork 108
dsa: remove block_table_convert_triton in dsa #658
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -1012,12 +1012,15 @@ def sparse_attn_indexer( | |
| # dummy runner | ||
| return weights | ||
| num_decode_tokens = context.batch_size if not context.is_prefill else 0 | ||
| ori_block_size = get_current_atom_config().kv_cache_block_size | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename to runner_block_size? |
||
| kv_cache = kv_cache.view(-1, ori_block_size, kv_cache.shape[-1]) | ||
| indexer_k_quant_and_cache( | ||
| k, | ||
| kv_cache, | ||
| slot_mapping, | ||
| quant_block_size, | ||
| scale_fmt, | ||
| preshuffle=True, | ||
| ) | ||
| if context.is_prefill: | ||
| if attn_metadata.max_seqlen_k <= topk_indices_buffer.shape[1]: | ||
|
|
@@ -1049,6 +1052,7 @@ def sparse_attn_indexer( | |
| if prefill_metadata.has_cached | ||
| else prefill_metadata.cu_seqlens_q | ||
| ), | ||
| preshuffle=True, | ||
| ) | ||
| cu_seqlen_ks = prefill_metadata.cu_seqlen_ks | ||
| cu_seqlen_ke = prefill_metadata.cu_seqlen_ke | ||
|
|
@@ -1100,6 +1104,8 @@ def sparse_attn_indexer( | |
| decode_metadata.context_lens, | ||
| attn_metadata.block_tables, | ||
| max_model_len, | ||
| KVBlockSize=kv_cache.shape[1], | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use runner_block_size instead of shape.. to avoid access torch stuff |
||
| Preshuffle=True, | ||
| ) | ||
| num_rows = logits.shape[0] | ||
| assert topk_tokens == 2048, "top_k_per_row assumes size 2048" | ||
|
|
@@ -1192,7 +1198,7 @@ def __init__( | |
| self.weights_proj = ReplicatedLinear( | ||
| hidden_size, | ||
| self.n_head, | ||
| quant_config=quant_config, | ||
| quant_config=None, | ||
|
junhaha666 marked this conversation as resolved.
|
||
| prefix=f"{prefix}.weights_proj", | ||
| ) | ||
| self.softmax_scale = self.head_dim**-0.5 | ||
|
|
||
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.
In sparse prefill,
CommonAttentionBuilder.prepare_prefill()will passblock_tables_convertedwhenhas_cached=True, andAttentionMetaData.__init__overridesattn_metadata.block_tableswith that converted (per-token) table. After this PR, downstream DSA code paths (e.g.triton_convert_req_index_to_global_index_dsa_prefillusingPAGE_SIZE) assumeattn_metadata.block_tablescontains raw per-page physical block IDs; leaving the converted table here will miscompute indices (effectively applying the page math twice). Consider always resettingattn_metadata.block_tablesto the rawvar["block_tables"]for the sparse MLA/DSA path (even when it’s already set), and ensureblock_tables_converteddoes not override it for this backend.