Megatron-LM icon indicating copy to clipboard operation
Megatron-LM copied to clipboard

[Inference] Optimize MLA latent KV-cache append with Triton

Open chengcuiping opened this issue 4 months ago • 0 comments

Summary

The dynamic inference path uses a fused Triton append kernel for the standard KV-cache layout, but the cache_mla_latent=True path currently falls back to PyTorch indexed assignment when writing compressed MLA latents.

This issue proposes adding a dedicated Triton append kernel for the MLA latent cache write path.

Scope

  • Preserve the existing MLA latent cache layout.
  • Preserve the current block allocator and block table semantics.
  • Preserve the PyTorch fallback when Triton is unavailable.
  • Do not change attention dispatch, FlashInfer integration, block-size guards, or KV-cache dtype.
  • Add numerical parity tests and an append-only benchmark.

This is independent of PRs #4918, #4919, and #4920, which address MLA block-size validation, attention dispatch, and functional coverage respectively.

chengcuiping avatar Jul 15 '26 03:07 chengcuiping