Skip to content

[Kernel] Add per-layer LF-to-PF KV transfer for LayerSplit HiCache - #37231

Draft
dblate wants to merge 1 commit into
sgl-project:mainfrom
dblate:glm52-cp-kernel
Draft

dblate wants to merge 1 commit into
sgl-project:mainfrom
dblate:glm52-cp-kernel

Conversation

@dblate

@dblate dblate commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Motivation

Enable layer-sharded MLA/DSA HiCache write-back for page-first host storage when the JIT path cannot handle the per-item size. This covers the GLM-5.2 LayerSplit CP path without changing cache quantization behavior.

Modifications

  • Add CUDA, MUSA, and ROCm registration for a per-layer LF-to-PF transfer operator.
  • Expose the operator through the Python kvcacheio bindings.
  • Add BF16/FP16 round-trip coverage for the new transfer path.

Accuracy Tests

  • H20, CUDA 12.9: test_kvcacheio.py -k page_first_roundtrip -> 2 passed.
  • The test covers BF16 and FP16 round trips through the new operator.

Speed Tests and Profiling

H20 microbenchmark, 8192 items, 656 bytes/item, 100 iterations:

LF-to-PF per-layer: 0.2747 ms, 19.56 GB/s
LF-to-LF per-layer: 0.1892 ms, 28.40 GB/s

LF-to-PF is a layout-transforming fallback, so this is a directional kernel comparison rather than an end-to-end serving throughput result.

Checklist

  • Format code with pre-commit.
  • Add unit tests according to the contribution guide.
  • Update documentation according to the contribution guide.
  • Provide GPU accuracy and directional benchmark results.
  • Follow the SGLang code style guidance.

CI States

Latest PR Test (Base): ❌ Run #33379044561
Latest PR Test (Extra): ❌ Run #33379044418
Latest PR Test (AMD ROCm 7.2): ❌ Run #33379044517

@dblate

dblate commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

/tag-and-rerun-ci

@dblate

dblate commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

补充 NVIDIA GPU 验证:在 H20(CUDA 12.9)开发空间运行 test_kvcacheio.py -k page_first_roundtrip,结果为 2 passed。核心 LF-to-PF kernel round-trip 通过。

当前 CI 仍未开始真实测试,原因是缺少上游要求的 run-ci 标签;请维护者按贡献指南执行 /tag-and-rerun-ci

@dblate

dblate commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

H20 microbenchmark (CUDA 12.9, 8192 items, 656 bytes/item, 100 iterations):

LF-to-PF per-layer: 0.2747 ms, 19.56 GB/s
LF-to-LF per-layer: 0.1892 ms, 28.40 GB/s

The LF-to-PF path is a layout-transforming fallback, so this is a directional kernel comparison rather than an end-to-end serving throughput result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant