Implement context parallelism (RingAttention) as `KVCache`
- Dominant language
- Python
- Stars
- 18
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
LARGER PROJECT
Currently, all `KVCache` implementations store buffers and run computation on a single device. RingAttention distributes memory and compute across several devices. Our `KVCache` abstraction allows for that to be implemented fairly easily.
**Describe the solution you'd like**
To the user, this should look like a normal KV cache, just with a much larger length:
* Different to RingAttention: Any KV cache type supported on the devices (but same type on each)
* Allows for much larger cache length
* RingAttention also parallelizes over the query axis. So this speeds up processing of large chunks
Should be doable with `isend`, `irecv`: https://docs.pytorch.org/tutorials/intermediate/dist_tuto.html#our-own-ring-allreduce
Approach:
* Copy KV buffers to CPU and transfer them from there. Sync point at the end of the computation
* Each rank computes part along query axis
* At the end: all_reduce to spread the results
Note: We cannot couple this with DDP, to obtain a larger batch size. RingAttention parallelizes over the query axis as well, but the batch size also scales the KV cache buffers. We can get away with larger chunks here, though.
Contributor guide
Assessment
This issue has not been assessed yet.