You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEAT][kernels]: implement Prefix-Shared Fused Attention for GRPO LogProb computation #65
component: alignmentTasks involving RL loss functions such as DPO and GRPO, and mathematical alignment logiccomponent: kernelsTasks involving the development of CUDA and Triton underlying operatorspriority: highSevere congestion issues require the highest priority for resolution.type: performancePerformance optimization tasks aimed at increasing throughput and reducing latency etc.
In GRPO and PPO pipelines, the log probability computation phase often involves processing batches where multiple generated responses ($G$) share the exact same prompt prefix.
Standard SDPA backends (like CuDNN or native FlashAttention) treat these as independent sequences, resulting in redundant global memory reads for the prompt's KV cache. This creates a severe Memory-Bound bottleneck for Long Context RL tasks.
Proposed Solution
We need to implement a highly optimized, hardware-aware Prefix-Shared Fused Attention kernel. By leveraging manual asynchronous pipelines and shared memory swizzling, we can load the shared prompt KV tiles into SRAM once and broadcast them across the $G$ queries in the registers.
We will base this implementation on a 5-stage evolutionary pipeline design, specifically targeting the efficiency of the v5 architecture:
Shared Memory Swizzling: Implement XOR-based swizzling to eliminate bank conflicts during ldmatrix.x4 instructions.
Asynchronous Pipelining: Utilize cp.async for global-to-shared data movement.
Asymmetric Buffering: Implement double buffering for K tiles (BLOCK_KV * 2) and single buffering for V tiles to maximize SRAM utilization without stalling the MMA compute.
Grouped Query MMA: Route the $G$ queries corresponding to the same prompt through the register files while the shared KV remains resident in SRAM.
Target Performance
Aiming for > 90% Hardware SOL on A100/Hopper architectures for high-group-size ($G \ge 64$) GRPO logprob forward passes.
component: alignmentTasks involving RL loss functions such as DPO and GRPO, and mathematical alignment logiccomponent: kernelsTasks involving the development of CUDA and Triton underlying operatorspriority: highSevere congestion issues require the highest priority for resolution.type: performancePerformance optimization tasks aimed at increasing throughput and reducing latency etc.
Activity