Skip to content

[DRAFT] Allocate host staging per transfer instead of fixed slots - #722

Draft
yinlin09 wants to merge 2 commits into
mainfrom
yinlin/dynamic-host-staging
Draft

[DRAFT] Allocate host staging per transfer instead of fixed slots#722
yinlin09 wants to merge 2 commits into
mainfrom
yinlin/dynamic-host-staging

Conversation

@yinlin09

@yinlin09 yinlin09 commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

What

Allocates host staging per transfer instead of carving the pool into fixed
slots, behind TPU_RAIDEN_DYNAMIC_HOST_STAGING=1.

Today the staging pool is pre-partitioned into num_slots slots of
max_blocks blocks, and a transfer borrows a whole slot however few pages it
needs:

  • slot size derives from the configured context length, so short requests idle
    most of their slot;
  • the slot count is a hard cap on concurrent transfers, on both the consumer
    (StartRead) and the producer serving a pull (StartPushInternal);
  • a producer that cannot get a slot marked the send done without
    transferring
    , leaving the consumer to burn its full timeout before failing.

How

Under the flag, both paths allocate exactly the pages they stage from the
existing host block manager (locked against LRU eviction for the transfer's
lifetime) and hand them back on completion, timeout, or error through the same
release helpers that returned fixed slots. The copy plans already address host
blocks explicitly, so nothing downstream changes and nothing changes on the
wire.

Exhaustion behaviour changes in both modes: the producer now waits for staging
to free (bounded by the transfer deadline) instead of fabricating completion,
and a request that can never fit is reported as a transfer failure with a
reason.

Off by default; the fixed-slot layout is untouched without the flag. The
reshard/pool-plan paths are unchanged.

Status — draft

Both wheel legs build green through ci/build_wheel.sh (jax and torch; the
torch wheel's three ABI extensions each carry the new code path). On-TPU
validation is in progress: a prefill/decode pair serving with the flag on, at
concurrency above what the fixed-slot layout could seat. Known follow-up:

  • fragmentation under sustained mixed-size load reduces copy coalescing; needs
    a throughput comparison against the slot path at equal concurrency.

Host staging was carved into fixed slots of max_blocks pages each, and a
read borrowed a whole slot however few pages it needed. Sizing the slot for
the longest request a server accepts therefore left most of every slot idle
on a short one, and capped concurrent transfers at the slot count rather
than at what the pool could actually hold.

Under TPU_RAIDEN_DYNAMIC_HOST_STAGING=1 a read instead allocates exactly the
pages it stages and hands them back on completion, so the same pool seats
transfers in proportion to their size. The copy plan already addressed host
blocks explicitly, so nothing downstream changes.

Off by default. The producer push path and the pool-plan receive path still
use fixed slots.
The producer side of a served pull borrowed a fixed staging slot per
transfer, so the slot count capped concurrent serves, and an exhausted pool
marked the send done without transferring anything -- the consumer then
waited out its full timeout before failing.

Under demand staging the serve allocates exactly the pages it stages, and
either mode now waits for staging to free (bounded by the transfer
deadline) instead of fabricating completion. A request that can never fit,
or one still unseated at the deadline, is reported as a transfer failure so
the consumer aborts promptly with a reason.

Completion, ack, and error paths hand demand-staged blocks back through the
same release helper that returned fixed slots.
@yinlin09
yinlin09 force-pushed the yinlin/dynamic-host-staging branch from 16da7c6 to 613b38b Compare August 19, 2026 22:48
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.

1 participant