아까 extend/decode에 대한 설명이 미비했던 것 같아서 덧붙이자면, 일부가 이미 prefilling되어 있을 때 prefill하는 phase를 “EXTEND”, decoding을 “DECODE”로 나타낸 것으로 보입니다.

system prompt 같은 게 이미 KV cache가 계산되어 있고 user prompt는 kv cache가 없을 때 쓰이는 게 EXTEND라고 보시면 됩니다.

#1422: Enable torch.compile for triton backend

#1442: Fix torch compile for deepseek-v2

(최신 커밋에서) torch.compile이 sglang에서 어떻게 동작하는지 알아보기

python/sglang/srt/layers의 구조입니다

python/sglang/srt/layers의 구조입니다

위 중 torch native backend, flashinfer backend + triton backend 정도만 보면 될 것 같습니다. 아래 주석이 flashinfer_backend.py에도 달려 있습니다.

Support different attention backends.
Now there are two backends: FlashInfer and Triton.
FlashInfer is faster and Triton is easier to customize.
Each backend supports two operators: extend (i.e. prefill with cached prefix) and decode.

triton에 대한 실제 attention ops 구현체는 triton_ops 폴더에 들어있는 것으로 보입니다.

AttentionBackend