Repository navigation
Use symmetric per-query windows for CUDA DFlash attention (#25644) - #25644
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25644
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ⏳ No Failures, 11 PendingAs of commit 5b7ea76 with merge base d0a9d13 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@psiddh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D133915608. |
Gasoonjia
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
This PR needs a
|
) Summary: DFlash's sliding attention mask now uses strict per-query distance, `abs(query_position - key_position) < window`. The CUDA sequence export still selected the older shared-context/whole-block mode, and cell-cache draft masks used the same old assumption. This produced numerically different attention from the model. Add an explicit trailing `symmetric_window` option to the CUDA kernel and thread it through sequence manifests and lowering. CUDA DFlash export selects it, while ordinary one-sided windows and the documented legacy `context_window` mode retain their defaults and behavior. Apply the same strict per-query mask to cell-cache draft rows, preserving causal, warmup, ownership, placement and rewind behavior. Keep the production model mask unchanged. Original comparisons retain their tolerances and use the mode selected by production export; extend coverage for exact boundaries, block sizes at least the window, ring wraps, graph replay, dynamic lengths and lowered KV execution. Existing compiled CUDA sequence artifacts must be re-exported to select the new mode; cell-layout consumers need the updated native runtime. Reviewed By: Gasoonjia Differential Revision: D133915608
9f72879 to
3cd566c
Compare
) Summary: DFlash's sliding attention mask now uses strict per-query distance, `abs(query_position - key_position) < window`. The CUDA sequence export still selected the older shared-context/whole-block mode, and cell-cache draft masks used the same old assumption. This produced numerically different attention from the model. Add an explicit trailing `symmetric_window` option to the CUDA kernel and thread it through sequence manifests and lowering. CUDA DFlash export selects it, while ordinary one-sided windows and the documented legacy `context_window` mode retain their defaults and behavior. Apply the same strict per-query mask to cell-cache draft rows, preserving causal, warmup, ownership, placement and rewind behavior. Keep the production model mask unchanged. Original comparisons retain their tolerances and use the mode selected by production export; extend coverage for exact boundaries, block sizes at least the window, ring wraps, graph replay, dynamic lengths and lowered KV execution. Existing compiled CUDA sequence artifacts must be re-exported to select the new mode; cell-layout consumers need the updated native runtime. Reviewed By: Gasoonjia Differential Revision: D133915608
3cd566c to
5b7ea76
Compare
Summary:
DFlash's sliding attention mask now uses strict per-query distance,
abs(query_position - key_position) < window. The CUDA sequence export still selected the older shared-context/whole-block mode, and cell-cache draft masks used the same old assumption. This produced numerically different attention from the model.Add an explicit trailing
symmetric_windowoption to the CUDA kernel and thread it through sequence manifests and lowering. CUDA DFlash export selects it, while ordinary one-sided windows and the documented legacycontext_windowmode retain their defaults and behavior. Apply the same strict per-query mask to cell-cache draft rows, preserving causal, warmup, ownership, placement and rewind behavior.Keep the production model mask unchanged. Original comparisons retain their tolerances and use the mode selected by production export; extend coverage for exact boundaries, block sizes at least the window, ring wraps, graph replay, dynamic lengths and lowered KV execution. Existing compiled CUDA sequence artifacts must be re-exported to select the new mode; cell-layout consumers need the updated native runtime.
Reviewed By: Gasoonjia
Differential Revision: D133915608