Fix cross-WG race condition in gdn_conv_fused conv_state shift#356
Open
qiuxin2012 wants to merge 2 commits intointel:mainfrom
Open
Fix cross-WG race condition in gdn_conv_fused conv_state shift#356qiuxin2012 wants to merge 2 commits intointel:mainfrom
qiuxin2012 wants to merge 2 commits intointel:mainfrom
Conversation
When N*HV > 32, WGs span multiple scheduling waves. The hv==0 WG's Phase 3 conv_state shift could complete before later-scheduled WGs read the original conv_state in Phase 1, corrupting their conv1d results and producing wrong ssm_state. Split into two paths: - N*HV <= 32: single kernel with inline shift (all WGs co-scheduled) - N*HV > 32: separate shift kernel after main kernel completes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three fixes for the sequential-layout GDN kernel: 1. Cross-WG race on conv_state: Phase 3 shifted conv_state without hv==0 guard and re-read from memory (could get corrupted data). Now uses register-cached values + N*HV<=32 inline / separate kernel. 2. Hardcoded conv_state dim 2048: only correct for HV=8. Replaced with dynamic dim = 2*H*K + HV*V. 3. Added double_v mode (HV>8): v-threads handle 128 elements each, enabling HV=16 support (e.g. num_v_heads_global=64 with TP=4). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When N*HV > 32, WGs span multiple scheduling waves. The hv==0 WG's Phase 3 conv_state shift could complete before later-scheduled WGs read the original conv_state in Phase 1, corrupting their conv1d results and producing wrong ssm_state.
Split into two paths: