Implement Sliding Window Attention with a Ring-Buffer KV Cache

Implement the autoregressive decoding of Sliding Window Attention with a KV cache (the original task was in C++; here it is simplified to single-head, token-by-token decoding).

Given head dimensi...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: