-
Notifications
You must be signed in to change notification settings - Fork 267
perf(ds4): batch exact prefill through width-4 vector kernels #666
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6965,7 +6965,17 @@ bool deepseek4_step_layer_range( | |||||||||||||||||||||
| // each sub-forward then writes at most one window and, if present, its | ||||||||||||||||||||||
| // boundary is the final token. This preserves the same pool/rotate order | ||||||||||||||||||||||
| // as sequential execution while retaining safe batched prefixes. | ||||||||||||||||||||||
| const int first_chunk = deepseek4_safe_compressor_batch_tokens(w, kv_start, n_tokens); | ||||||||||||||||||||||
| const bool exact_prefill_band = | ||||||||||||||||||||||
| cache.prefill_mode == PrefillAttentionMode::Exact && | ||||||||||||||||||||||
| allow_decode_graph_reuse && !fused_verify_candidate; | ||||||||||||||||||||||
| const int first_chunk = std::min( | ||||||||||||||||||||||
| deepseek4_safe_compressor_batch_tokens(w, kv_start, n_tokens), | ||||||||||||||||||||||
| exact_prefill_band ? 4 : n_tokens); | ||||||||||||||||||||||
| const bool exact_multi_token_band = | ||||||||||||||||||||||
| exact_prefill_band && n_tokens > 1 && n_tokens <= 4; | ||||||||||||||||||||||
| ScopedCudaGraphOverrides exact_mmvq_scope( | ||||||||||||||||||||||
| /*disable_graphs=*/false, | ||||||||||||||||||||||
| /*mmvq_max_ncols=*/exact_multi_token_band ? 4 : 0); | ||||||||||||||||||||||
| if (first_chunk > 0 && first_chunk < n_tokens && | ||||||||||||||||||||||
|
Comment on lines
+6976
to
6979
Contributor
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. P2: When (Based on your team's feedback about respecting MMVQ dispatch overrides.) Prompt for AI agents
Suggested change
|
||||||||||||||||||||||
| !fused_verify_candidate && !heterogeneous_sparse_prefill && | ||||||||||||||||||||||
| !standard_layer_major_prefill) { | ||||||||||||||||||||||
|
|
@@ -6989,8 +6999,10 @@ bool deepseek4_step_layer_range( | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| for (int off = 0; off < n_tokens;) { | ||||||||||||||||||||||
| const int chunk = deepseek4_safe_compressor_batch_tokens( | ||||||||||||||||||||||
| w, kv_start + off, n_tokens - off); | ||||||||||||||||||||||
| const int remaining = n_tokens - off; | ||||||||||||||||||||||
| const int chunk = std::min( | ||||||||||||||||||||||
| deepseek4_safe_compressor_batch_tokens(w, kv_start + off, remaining), | ||||||||||||||||||||||
| exact_prefill_band ? 4 : remaining); | ||||||||||||||||||||||
| std::vector<float> chunk_hc; | ||||||||||||||||||||||
| std::vector<float> chunk_out; | ||||||||||||||||||||||
| std::vector<float> chunk_capture; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
P2: When the DS4 fused MMQ-pair path is skipped because ncols<=override, the fallback only lands on the quantized matrix-vector path if the grouped MMVQ batch ceiling (get_mmvq_mmid_max_batch) is >= ncols for the qtype. For an ids/grouped DS4 feed-forward, ncols is src1->ne[2], but the override ceiling is designed for plain mul_mat's src1->ne[1]; the two limits are not the same constant. If a qtype's mmid MMVQ ceiling is below ncols, this gate silently drops the fused path and the node falls back to the slower unfused MMQ/dequant path instead of the intended MMVQ win.
Prompt for AI agents