Skip to content

[Fix] hicache: preserve NVFP4 payload and scales across host transfers - #46452

Open
LingZ315 wants to merge 5 commits into
sgl-project:mainfrom
LingZ315:lz/fix-nvfp4-hicache-layout-20261026
Open

LingZ315 wants to merge 5 commits into
sgl-project:mainfrom
LingZ315:lz/fix-nvfp4-hicache-layout-20261026

Conversation

@LingZ315

@LingZ315 LingZ315 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

NVFP4 host-cache transfers must preserve packed K/V bytes together with their persistent scale buffers. Generic token-scale MHA descriptors and logical-head-width staging do not represent this layout correctly. This is the independent transport companion to the workspace fix in #43356.

Modifications

  • Add an explicit NVFP4 buffer descriptor and host-pool dispatch, using byte-width geometry for packed payload transfers.
  • Back up and restore page-granular scale buffers with target/draft layer order preserved, and include persistent scales in host allocation accounting.
  • Support aligned whole-page L2 transfers with the kernel backend and page_first layout. Reject invalid descriptors, partial transfers, native-only scale layouts and unsupported relocation/L3 layouts. Token indices retain canonical order within each page.

Descriptors also carry optional native-layout scales when present; this branch has CPU coverage. Native-only configurations remain explicitly unsupported.

Accuracy Tests

Independent validation of this 6-file patch, based on a99c7d050fae:

  • 26 registered CPU tests passed for descriptors, allocation, transfer selection and rejection checks.
  • 96 GPU byte comparisons passed for page sizes 16/32/64 with permuted source, host and reload pages.
  • 32 additional comparisons passed for a 65-page transfer crossing the 64-page staging capacity.

The GPU cases use two target and two draft layers on RTX 5090/SM120, comparing packed K/V plus token-linear K/V scales. Native scale buffers are disabled/rejected in these GPU cases. They establish byte preservation; native-scale GPU transport, SM100 and RTX PRO 6000 were not validated.

python -m pytest -q \
  test/registered/unit/mem_cache/test_nvfp4_host_buffer_info.py \
  test/registered/unit/mem_cache/test_nvfp4_mha_pool_host_unit.py

The combined workspace + HiCache candidate, using Qwen3.8-27B ModelOpt NVFP4 on TP2 RTX 5090, additionally passed 8 L2 Graph/eager request pairs. Its finite 24-item quality comparison scored 19/24 for both NVFP4 and FP8 with zero new errors. These combined results are separate from this patch's standalone transport tests and do not establish standalone end-to-end quality or the full reasoning/tool/vision/needle suite.

Speed Tests and Profiling

No standalone host-transfer throughput claim is made. The complete five-point ABBA and memory/capacity measurements are reported in the companion core PR, with HiCache enabled for both paths.

For that combined candidate, NVFP4/FP8 paired request-throughput ratios were 1.0573/1.0110/0.8809/0.9012/0.8832 for shared 25K C1/C4/C16, shared 50K C4 and unique 25K C4 respectively. At an equal 196608-token pool, ready-state known KV/scales/workspace storage was 31.99% lower and PyTorch allocated memory 4.97% lower per rank. Separately measured automatic token-pool capacity was 782,592 vs 565,568 (+38.37%). These service and capacity results are not attributed to the HiCache transport patch alone; the core's launch optimization does not change this patch.

Checklist

The repository-pinned pre-commit stage passed on all six changed files. This result is retained for the byte-identical HiCache patch; it was not rerun for the core launch optimization.


CI States

Latest PR Test (Base): ❌ Run #40303270330
Latest PR Test (Extra): ❌ Run #40303269892
Latest PR Test (AMD ROCm 10): ❌ Run #40303270258

Use explicit packed buffer descriptors and byte-width host staging.
Keep target/draft local layer order and reject unsupported layouts.
@LingZ315

Copy link
Copy Markdown
Contributor Author

@merrymercy this PR is now ready for review. Could you please run /tag-and-rerun-ci extra for the current head (c4d3b3666cc0) to enable Base + Extra CI?

This branch now includes upstream main 5ef99013ac3e. The refresh also fixes forwarding of the new host_token_capacity argument into the NVFP4 host pool. Four new CPU regression cases cover default/explicit capacity with and without native scales, checking actual payload and scale allocation sizes. Local CPU validation passed: 30 tests for this PR, and 443 tests + 207 subtests combined with #43356. The repository-pinned pre-commit checks also passed.

The earlier GPU/model and benchmark results in the PR descriptions apply to the documented a99c7d0-based validation snapshot; they have not been rerun on these new heads. If GitHub requires approval for fork workflows, could you approve those as well?

detain added a commit to detain/sglang that referenced this pull request Oct 29, 2026
…mily + S-EXT1 + riders + S-RACE + LLGUARD/ENVREG), S-EXT1 and S-RACE items CLOSED, entry-256's raw-env deviation and LL-vs-PCIe-IPC collision warning both marked CLOSED with the BOOT_DELTA (h') needle in landing terms, sgl-project#35617 left as the sole FAM-A7 survivor, sgl-project#44732 re-pointed to the operator's merge-sgl-project#5 answer, and the KV-ROUTE DECISION RECORD added (HOLD NVFP4-KV until armed PCIe-IPC is measured post-merge; preferred-if-ever sequence merge -> sgl-project#43356-delta -> sgl-project#46452 NOT sgl-project#43240 -> optional sgl-project#43471 -> fork BUILD-A QSA FP4 reads (template sgl-project#38724) -> BUILD-B L3 scale sidecar -> one GPU window; sgl-project#46141 template, sgl-project#44462 NEXT, MXFP4 declined, entry-247 re-sync watch-string modelopt_e4m3_k32)
detain added a commit to detain/sglang that referenced this pull request Oct 30, 2026
… C closure -- the post-merge port queue is now decided

ARRIVAL SCAN (git log 12dc623..2a6c204 --grep) + LIVE gh STATE +
head-sha comparison for EVERY deferred item. Verdicts:
  RELEASED-BY-MERGE: sgl-project#42689 (@ 7a632cf in-range -- the SECTION-B
    cherry is now redundant; behavior note rides the restart).
  CLOSED (C-items whose PRs arrived and whose integration this stack
    performed): C1 (the dedicated merge week WAS merge sgl-project#5; all eight
    precursor PRs in-range), C2 (sgl-project#44993/sgl-project#44994 -- B5), C3 (sgl-project#45232/
    sgl-project#45236/sgl-project#45334 -- B2), C4 (sgl-project#45238/sgl-project#45241/sgl-project#45242 -- B3), C5 (sgl-project#44912/
    sgl-project#44913 -- arrived; entry-230 canary re-planted as its guard),
    C9 (sgl-project#39727 -- verified OPT-IN, no purge; BOOT_DELTA anti-needle),
    C0a (arrival shas already recorded at entry 310 -- Section C now
    carries NO open code-integration items: C6/C10 retain only their
    explicitly-named docs/boot-measurement remainders, re-stated).
  STILL-OPEN: sgl-project#44342 (head unchanged; auto-merge comfort LOST to
    #46970x), sgl-project#46153/sgl-project#37106/sgl-project#32479/sgl-project#45391 (gh CONFLICTING -- stale
    bases, rebase before any port), sgl-project#41624/sgl-project#42525/sgl-project#42660/sgl-project#44462/sgl-project#35617
    (open, heads unchanged), sgl-project#46191/sgl-project#39845-class (watch-list, none in
    range).
  HOLD STANDS (operator decision, binding): sgl-project#43356/sgl-project#46452/sgl-project#43240/
    sgl-project#43471 KV route -- step-1 'MERGE sgl-project#5 lands first' is NOW MET; the
    sequence may be re-visited ONLY with the post-merge PCIe-IPC
    measurement at an operator sitting. sgl-project#44732: the 'one purge if done
    WITH the merge' premise LAPSED when merge sgl-project#5 completed without it
    -- later execution costs the SAME single purge once; no penalty,
    no haste. Recorded for the operator, not decided by B6.

This branch has not been deployed

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

Labels

blackwell SM100/SM120 hicache Hierarchical Caching for SGLang memory-pool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant