Skip to content

Add comprehensive NVFP4 KVCache technical documentation and upstream PR/issue analysis#2

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-nvfp4-kvcache-support
Draft

Add comprehensive NVFP4 KVCache technical documentation and upstream PR/issue analysis#2
Copilot wants to merge 4 commits intomainfrom
copilot/add-nvfp4-kvcache-support

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 9, 2026

Motivation

NVFP4 KVCache implementation details were scattered across source code, upstream PRs, issues, and documentation. No single reference existed covering design rationale, implementation architecture, and development history.

Modifications

Documentation Created

NVFP4_KVCACHE_DESIGN_SUMMARY.md (20KB) - Technical reference:

  • E2M1 quantization format: 4-bit FP with block-based microscaling (16 elements/block, 8-bit scale factors)
  • KVFP4QuantizeUtil implementation: batched_quantize/batched_dequantize with @torch.compile
  • Memory pool integration for MLA and MHA token pools
  • Backend compatibility matrix: MLA (FlashInfer, FlashMLA, Cutlass, TRTLLM, FA4) and MHA (FA4, Triton, Torch Native, TRTLLM)
  • Memory savings: ~3.56× vs BF16 (4.5 effective bits/value including scale overhead)
  • Accuracy benchmarks: Large models (200B+) show minimal degradation on simple tasks, more pronounced on complex reasoning

NVFP4_KVCACHE_PRS_AND_ISSUES.md (18KB) - Upstream analysis:

NVFP4_SUMMARY_README.md (4.4KB) - Navigation guide with quick links to implementation files and key takeaways.

Technical Details Documented

# Quantization: [B, M, N] → [B, M, N/2] packed + [B, M*N/16] scale factors
# E2M1 values: [0, 0.5, 1, 1.5, 2, 3, 4, 6]
cache_k_fp4, scale_factors = KVFP4QuantizeUtil.batched_quantize(cache_k)
cache_k_dequant = KVFP4QuantizeUtil.batched_dequantize(cache_k_fp4, scale_factors)

Sources: kvfp4_tensor.py, memory_pool.py, attention backends, upstream PRs sgl-project#10078/sgl-project#12612, existing docs.

Accuracy Tests

N/A - Documentation only.

Benchmarking and Profiling

N/A - Documentation only.

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 9, 2026 01:01
Co-authored-by: yiliu30 <106061964+yiliu30@users.noreply.github.com>
Co-authored-by: yiliu30 <106061964+yiliu30@users.noreply.github.com>
Copilot AI changed the title [WIP] Add NVFP4 KVCache support to sglang Add comprehensive NVFP4 KVCache design and implementation summary Feb 9, 2026
Copilot AI requested a review from yiliu30 February 9, 2026 01:03
Co-authored-by: yiliu30 <106061964+yiliu30@users.noreply.github.com>
Copilot AI changed the title Add comprehensive NVFP4 KVCache design and implementation summary Add comprehensive NVFP4 KVCache technical documentation and upstream PR/issue analysis Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants