The L1-L4 Hierarchy
All model operators live undertasks/baseline/ at four abstraction levels:
- L1 — Single-kernel ops (e.g.
rms_norm,silu_and_mul,rotary_emb,linear) - L2 — Multi-op blocks (e.g.
LlamaAttention,LlamaMLP,MixtralMoE,QKVParallelLinear) - L3 — Decoder layers (e.g.
LlamaDecoderLayer,MixtralDecoderLayer) - L4 — Full models (e.g.
LlamaForCausalLM,MixtralForCausalLM)
Interface Mirroring
Every module’s__init__ and forward signatures are designed to mirror the corresponding vLLM module. This makes it easy to port optimizations between the two codebases and ensures candidate kernels can be validated against a well-known reference.
All parallel linear layers return
(output, bias) tuples to match vLLM. LlamaAttention stores rotary_emb as an __init__ parameter (not a forward argument), matching vLLM’s design where each LlamaAttention owns its rotary embedding.