Skip to content

[HiSparse] Allow backing the host KV pool with hugetlbfs - #58852

Draft
LucasWilkinson wants to merge 1 commit into
vllm-project:mainfrom
LucasWilkinson:hisparse-hugetlbfs-host-pool
Draft

LucasWilkinson wants to merge 1 commit into
vllm-project:mainfrom
LucasWilkinson:hisparse-hugetlbfs-host-pool

Conversation

@LucasWilkinson

@LucasWilkinson LucasWilkinson commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Large HiSparse host pools (384–480 GiB) are pinned twice on 4 KiB pages: by cudaHostRegister and by NIXL/RDMA registration. In the shared TP pool, every rank also registers the whole pool. At 450 GiB that's about 118M pages per pass, and we've seen it wedge K8s nodes during startup.

This PR adds an opt-in host_pool_dir key on HiSparseConnector. When it's set, the host pool is a file-backed mmap in that directory, typically a hugetlbfs mount. With 1 GiB pages, 450 GiB becomes 450 pages, so pinning and MR translation tables become trivial.

{"kv_connector": "HiSparseConnector", "kv_role": "kv_both",
 "kv_connector_extra_config": {"host_pool_gib": 384, "host_pool_dir": "/dev/hugepages-1Gi"}}

On K8s: emptyDir: {medium: HugePages-1Gi} plus resources.limits.hugepages-1Gi: <pool size>. The node must reserve 1 GiB huge pages.

Changes:

  • SharedOffloadRegion gets a shm_dir argument, defaulting to /dev/shm, so existing behavior doesn't change. The mapping is rounded to the filesystem page size (statvfs().f_bsize); callers still see exactly total_size_bytes. On hugetlbfs the tmpfs free-space check is skipped, because hugetlbfs statfs reports 0 free without a size= limit. mmap reserves the huge pages instead, and an ENOMEM is turned into a clear error. A hugetlbfs region always uses one backing file, because huge-page files can't be stitched together at arbitrary offsets the way num_segments does.
  • HiSparse shared pool (TP>1, mp): passes shm_dir through. Each rank's prefault shard is rounded to the huge page size, so ranks don't fault the same huge page. It skips the psutil RAM check, because reserved huge pages don't count toward MemAvailable.
  • HiSparse private pool: when host_pool_dir is set, allocates an unlinked, pre-faulted file mapping in that directory instead of torch.empty.

Not a duplicate: #45693 (draft, needs rebase) adds hugetlbfs support to the OffloadingConnector TieringOffloadingSpec. This PR targets the HiSparse host pool, which that PR doesn't touch. The two overlap only in SharedOffloadRegion, and the change there is kept minimal so they can be reconciled.

Status: mockup / draft. Not yet validated on a real hugetlbfs mount (see test plan).

Test Plan / Results

  • pytest tests/v1/kv_offload/cpu tests/v1/worker/test_utils.py: 238 passed, 1 skipped.
  • pytest tests/v1/core/test_kv_cache_planning.py tests/v1/core/test_kv_cache_utils.py -k "hisparse or host_pool": 14 passed.
  • New unit tests:
    • Region mapping is rounded to a 2 MiB page size while exposing only the logical size, and the free-space check is skipped.
    • The private file-backed pool leaves no file behind and is registered at its exact size.
    • Shared-pool kwargs are covered with and without host_pool_dir.
  • GPU check (H200): an 8 GiB file-backed private pool registered with cudaHostRegister in 3.6 s, and a D2H copy ran at 54 GB/s with correct data. This used tmpfs-backed files, because the dev box has no reserved huge pages and no root.
  • TODO: repeat the check on a hugetlbfs mount with 1 GiB pages at 384+ GiB with NIXL enabled.

AI assistance (Claude Code) was used to write this change; it will be reviewed end-to-end before being marked ready.

🤖 Generated with Claude Code

@mergify

mergify Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Documentation preview: https://vllm--58852.org.readthedocs.build/en/58852/

@mergify

mergify Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @LucasWilkinson.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Oct 15, 2026
@LucasWilkinson
LucasWilkinson force-pushed the hisparse-hugetlbfs-host-pool branch from 5d51604 to 09582e0 Compare October 15, 2026 14:44
@mergify mergify Bot removed the needs-rebase label Oct 15, 2026
@mergify

mergify Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @LucasWilkinson.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

Add a host_pool_dir option on HiSparseConnector. When set, both the shared
TP pool and private per-rank pools are file-backed mmaps in that directory,
so a hugetlbfs mount (e.g. a K8s HugePages-1Gi emptyDir) cuts the number of
pages cudaHostRegister and NIXL/RDMA registration must pin by up to 262144x.

SharedOffloadRegion gains a shm_dir argument, rounds the mapping to the
filesystem page size, and skips the tmpfs free-space check on hugetlbfs,
where mmap reserves the huge pages and fails with ENOMEM instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
@LucasWilkinson
LucasWilkinson force-pushed the hisparse-hugetlbfs-host-pool branch from 09582e0 to f49c7a5 Compare October 25, 2026 22:55
@mergify mergify Bot removed the needs-rebase label Oct 25, 2026
Etelis pushed a commit to Etelis/vllm that referenced this pull request Oct 27, 2026
Add host_pool_dir for shared and private file-backed HiSparse pools.

Based on vllm-project#58852.

Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
Etelis added a commit to Etelis/vllm that referenced this pull request Oct 27, 2026
Build on the host_pool_dir interface from vllm-project#58852. Request transparent huge pages before population, align shared prefault shards, and retain RAM and capacity checks for ordinary file-backed pools.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
Etelis added a commit to Etelis/vllm that referenced this pull request Oct 27, 2026
Build on the host_pool_dir interface from vllm-project#58852. Request transparent huge pages before population, align shared prefault shards, and retain RAM and capacity checks for ordinary file-backed pools.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
@mergify

mergify Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @LucasWilkinson.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added needs-rebase nixl NIXL KV connector / multi-tiered KV offloading (KVCR) labels Oct 27, 2026

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

documentation Improvements or additions to documentation hisparse Related to HiSparse needs-rebase nixl NIXL KV connector / multi-tiered KV offloading (KVCR)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants