Skip to content

feat(mesh): UMBP share groups 2/2 — cache_aware counts prefixes a DP rank copies in from its share group - #3620

Open
wanzhenchn wants to merge 26 commits into
zwan/mesh-umbp-share-lanesfrom
zwan/mesh-umbp-share-groups
Open

wanzhenchn wants to merge 26 commits into
zwan/mesh-umbp-share-lanesfrom
zwan/mesh-umbp-share-groups

Conversation

@wanzhenchn

@wanzhenchn wanzhenchn commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

UMBP share groups 2/2 (M8a): cache_aware counts what a DP rank will copy in from the device pools of its UMBP share group, whether its pool shares all of its blocks or only part of them (share_ratio below 1) · design §3.4.3 ATOM × UMBP, §3.3.7 scoring, M8a (LLM-Booster #711) · stacked on #3946, which carries what this PR had below the routing: ATOM's two reports, and the router's kv_pool discovery, GPU_SHARED tier, shared lanes, index walk and share groups. Split as the review asks, in two rather than the three announced first; review #3946 first, the diff here is against its branch. The branch is not force-pushed: one merge commit (5253a94, whose tree is the second commit's) brings the two commits in, and a second (8c0896e) follows #3946 to 26cc0bd, so the Commits tab also lists the branch's earlier history while Files changed is these two commits · 23 files, +1037 −302, about 640 of the added lines tests · two commits: ea180db gives the one tier main has, the Mooncake Store, the shape the review of 1a83eb4 asks for, one TieredHit per worker, one TierWeights in the policy's config and one effective_cached, and changes no routing decision (+717 −277); aaeb8e6 adds the share tier as a field, a weight and a term, with --kv-share-weight (+404 −109); each commit is under 1,000 changed lines and reads on its own, and the first can become a PR of its own between #3946 and this one if that is preferred · only with --kv-events, and only for ranks that report a kv_pool, as ATOM's umbp_pool ranks do with #3946; at --kv-share-weight 0 routing is that of the base

flowchart LR
  subgraph NODE["One node: ATOM DP ranks on umbp_pool (#3482)"]
    direction TB
    E0["rank 0 engine, HBM pool:<br/>private part + UMBP part (share_ratio)"]
    E1["rank 1 engine, HBM pool:<br/>private part + UMBP part (share_ratio)"]
    U[("UMBP server, L1 pool service (mori #1045):<br/>the UMBP parts of a group,<br/>on a node-local unix socket")]
    E0 <-->|"publish, reclaim"| U
    E1 -.->|"Fetch: copy in the prefix it misses"| U
  end
  subgraph MESH["ATOMesh router: share groups and index in #3946, the score in this PR"]
    direction TB
    SG["share groups:<br/>node · address · group, fetch on"]
    IX["KV event index, per rank:<br/>GPU lane, every block it holds;<br/>shared lane, its GPU_SHARED blocks<br/>(the GPU lane at share_ratio 1)"]
    WK["one walk per partition:<br/>D = its GPU lane<br/>G = its GPU lane ∪ its group's shared lanes"]
    ST["Mooncake Store lookup (#3344):<br/>C = what it will report cached"]
    SC{"D + s × (G − D) + w × (C − G)<br/>above cache_threshold?"}
    SG --> WK
    IX --> WK
    WK --> SC
    ST --> SC
  end
  E0 -->|"GET /kv_event_sources: kv_pool"| SG
  E0 -->|"ZMQ KV events: GPU and GPU_SHARED"| IX
  SC -->|"kv_shared where G > D,<br/>else kv_affinity or the tree"| E1
Loading

Purpose

Dependencies

As of 11-27, against what this PR was opened for on 11-20 at 05:31 UTC:

Head Since Here
#3946, the base of this PR 26cc0bd, merged in at 8c0896e new on 11-27: the reports and the router's events, index and monitoring that were this PR's until the split this PR's diff is two commits on it; main at af573f0 comes in through it
#3344, the base until 11-27 squash-merged on 11-27 as bb5d270, from f900792 main merged in twice on 11-23 and again on 11-25, at 13d1d28, which has #3482; its own changes those of 159d249 in main. Until the split this branch merged main in at 1a83eb4 and 6ed88f6; since the split its content is two commits on #3946, brought in by one merge commit (5253a94) whose tree is theirs
#3482, umbp_pool merged on 11-25 as 8e99ca9, from ee86b3a rebased on main three times on 11-23, its own changes the same but a test's stub; asked to land in slices or record a waiver, it stays one PR (31 files, 3979 lines), the split waived on 11-24; changes requested again on 11-24 at 57fcc7c, seven asks, all addressed in ee86b3a (rebased on main, one new commit), none in what the router reads; the asks above are follow-ups once it lands in this branch through the base; the first report is here, the other two are its follow-ups
mori #1045, L1 pool service merged as 4651022 rebased on 11-20 at 06:19: adopts the engine's KV memory, fetches into slots the caller holds, copies on the destination's own stream, and waits, bounded, for held slots to settle; clang-format on 11-21; on 11-23 two switches: UMBP_L1_KEEP_COPIES=N has eviction take a copy that N newer copies in the group back up before any of the newest N, and UMBP_L1_GATHER_COPY issues a fetch's copies through the HBM copy engine; later on 11-23 rebased on main, its changes the same, then both made the default, UMBP_L1_KEEP_COPIES=1, either off at =0; on 11-24 its L1 pool test registered for CI, then squash-merged the router's inputs are unchanged; fewer partial fetches bring a copy-in closer to the hit s assumes. Under UMBP_L1_KEEP_COPIES, now on by default, a fetch's source gives up its copy first, unless its engine uses it again, so the copy left is the one the fetch brought in, which the router sees only through ask 2
mori feat/umbp-l1-tiers (#995) b97136e unchanged, not a PR DRAM and SSD below the pools, later

Changes

Links are at aaeb8e6. Discovery, the shared tier, the shared lane, the index walk, the monitor's share groups and ATOM's two reports are in #3946.

Tests

At aaeb8e6, on #3946 at 2c9ad4d, ci profile, on a shared host at a load of 300 to 500. atom/mesh at this head is byte for byte that of e2e0b8d. The head, 8c0896e, merges #3946 at 26cc0bd (two commits of tests and an assertion, none in a file this PR changes): there cargo test --lib --features atom-engine gives 1468 passed, 9 ignored, kv_events_test 6 passed, cargo fmt --check and cargo check --features ext-proc --tests are clean, and with debug assertions on the kv_index, kv_events, policy and kv_tiers tests give 164 passed, 6 ignored.

Check Result
cargo test --lib --features atom-engine 1467 passed, 9 ignored; 1464 at the first commit, 1460 on #3946
cargo test --test routing_tests 80 passed in 4 of 7 runs. In the other three, one or two tests could not start a mock worker (AddrInUse), a different test each time: test_2p2d_chat_completions; test_pd_mode_round_robin and test_regular_models_endpoint; test_2p2d_streaming. The tests pick a free port and bind it later, and the suite's own parallel tests can collide: #3946 shows the same in 3 runs of 9 at 26cc0bd with no other test run on the host, and none in three runs with --test-threads=1. CI runs this suite in run_atomesh_test_harness, where it can fail the same way (it did once on #3946 at 26cc0bd). The first commit passed its one run
api_tests kv_events_test 6 passed, the test unmodified, at --kv-storage-weight 1.0, 0.5 and 0.0; also at the first commit
cargo fmt --check clean, at both commits
cargo check --features ext-proc --tests clean, at both commits
cargo clippy --all-targets --features atom-engine the 86 warnings main has, none added or removed, at both commits; in the changed files only items_after_test_module in cliargs.rs
#3946's nine Python test files at this head 599 passed, 49 skipped; this PR changes no Python
The mocker's test_atomesh_harness, token parity, vendor_ext_proc.py --check, anything on a GPU not run again; the harness passed (8) at e2e0b8d, the same atom/mesh

New tests:

  • Monitor (monitor.rs#L1170-L1304): the two tests of feat(mesh): UMBP share groups 1/2 — ATOM's reports and the router's events, index and monitoring #3946, which assert what a rank will hold, now assert each rank's TieredHit. With whole pools, at a share weight of 0 no rank's hit has shared tokens, and at 0.9 the rank holding nothing of its group's 8 tokens will copy in 8. With a part shared, the peer of a rank at share_ratio 0.5 will copy in 4 tokens, not 8.

  • Policy (cache_aware.rs#L1086-L1178): of 100 tokens, w1's device cache holds 60, and w2's 20 with 80 in its group.

    --kv-share-weight Selected Branch Match rate Estimate
    0.9 w2 kv_shared 0.74 0.8
    0.5 w1 kv_affinity 0.6 0.6

    A best match of at most cache_threshold is left to the tree. Since e2e0b8d the store cases run through StorageSources against a mock admin service, which gets one request a selection and none at weight 0; with both tiers, at 0.9 and 0.5, a worker with 20 tokens on its device, 40 to copy in and 30 to load scores 0.71 as kv_shared with an estimate of 0.9.

  • Weight (validation.rs#L473-L489): below 0, above 1 or NaN fails validation.

  • Flags to policies (cliargs.rs#L868-L922, policies/registry.rs#L678-L716): the two weights on the command line are the TierWeights of the default, by-name and P/D policies of the AppContext built from it.

  • Score (kv_tiers.rs#L65-L138): effective_cached equals the earlier hand-written formula bit for bit, over 9 hits and 7 weight pairs, the defaults among them.

  • Tiers (policies/tiers.rs#L155-L298): a weight of 0 sends no request to the store and counts no lookup, and the index is passed the weights; decode workers and workers the index does not know are not asked.

On MI355X, 11-25, DeepSeek-V4.1-Flash P/D on one node: two prefill workers of two DP ranks each (-tp 2 --enable-dp-attention --enable-expert-parallel) and one decode worker of four, the prefill on multi of the Mooncake P/D connector and umbp_pool at share_ratio 1, one UMBP server for both workers, InferenceX agentic traces, 300 s after the recipe's warmup. The four prefill ranks reported one kv_pool and the router put them in one share group.

Run Requests Placed on a rank that holds the prefix / that copies it in / on a miss Router's estimate of cached tokens Engines' cached_tokens Pools
c64, mori 4651022 497 325 / 126 / 46 38,233,600 38,042,240 (estimate +0.50%) 52% full, nothing evicted
c256, mori 94c7f60 1,942 placed, 1,936 completed and the 6 in flight when the window closed cancelled 718 / 1,065 / 159 142,802,176 143,012,608 (estimate −0.15%) full, 304 GiB evicted over the run, 84 to 100% of it spare copies

Both runs ended without a failed request, a failed P/D transfer or a rank leaving the exact state; at c256 the four ranks dropped 42 events as unknown_parent while they stored 2.2 million blocks. What these runs do not cover:

  • The policy. They ran a test branch whose prefill policy is agentic (#3406) with this PR's share groups (shared_tokens at the time) and --kv-share-weight wired into its cost, not cache_aware: the share groups, the index and ATOM's two reports are feat(mesh): UMBP share groups 1/2 — ATOM's reports and the router's events, index and monitoring #3946's, the kv_shared branch of cache_aware has run in unit tests only.
  • The event's tokens. The test branch packs a BlockStored's tokens with numpy; here they are listed, as hash_blocks lists them.
  • share_ratio below 1, which waits for the third report, and --kv-share-weight 0 and UMBP_L1_KEEP_COPIES=0 as controls.
  • An image. The nightly images of 11-22 and 11-24 (06:50) have neither mori's L1 pool service nor its mori_umbp_l1 client; the runs added both, built from mori's source, to the 11-22 image.

Against the recipe's router (load only) on the same node and build, c64: TTFT mean 2.52 s to 2.26 s and P50 2.36 s to 1.82 s, P90 4.23 s to 4.16 s, P99 6.67 s to 9.48 s, about 490 requests an arm, one run each; the ranks copied 326 prefixes in the window under the recipe's router and 121 under this one.

Not in this PR

🤖 Generated with Claude Code

#3344's changes since 52ba967 (the #3367 head it last merged), applied on main 17edc61 so that #3344 is the bottom of its stack: the sampled Mooncake Store lookup, cache_aware's tiered match rate behind --kv-storage-weight, and the chunk-key vectors both sides assert.
With ATOM's umbp_pool connector (#3482), the DP ranks of one node whose
pools are in one group of one UMBP server copy the prefix they miss from
each other's pools before they compute it, and count the copies as
device hits. DP-aware routing picks the rank itself, so the router has to
see that sharing in what the ranks publish.

- /kv_event_sources may carry each rank's `kv_pool` (backend, address,
  group, share_ratio, fetch). Ranks on one node with the same address and
  group form a share group, only while share_ratio is 1 and fetch is on,
  so a block any rank of the group holds is one every rank can have.
- The prefix index walks a group's lanes once: a block counts while any
  of them holds it (`find_shared`, `match_groups`).
- cache_aware's KV branch scores the copies at --kv-share-weight (0.9 by
  default; 0 ignores share groups), counts them in the estimate, and
  labels such decisions kv_shared.
…and document the store lookups

The end-to-end KV events test ran at --kv-storage-weight 1 against a store
that held every key, so the store alone cleared cache_threshold and the
device assertions passed with a broken index or encoding. Its store is now
tainted and holds nothing.

The deadline's docs now say that past it a lookup has no answer at all, and
docs/metrics.md and the README describe the lookups' metrics, results and
/kv_storage/sources fields.
…wan/mesh-umbp-share-groups

# Conflicts:
#	atom/mesh/docs/metrics.md
…re at weight 0

A store with a pool per NIC holds, evicts and taints each rank's chunks in the
pool that rank writes to, so rank 0's keys alone counted chunks ATOM will not
load. Such a store is now asked for every rank's keys, rank by rank, and holds
the shortest run, as ATOM's lookup takes it; a store of one pool is still asked
for rank 0's alone. At --kv-storage-weight 0, cache_aware no longer takes the
store path at all.

The tests now fail when the store wiring breaks: the e2e test untaints the store
at the end and expects it to place a request the tree has on the other worker,
and runs again at weight 0, where no chunk key is asked; a monitor test covers a
decode worker and one the index does not know; the reader test asks for the
reader with the least on its device.
…nks share one

- `shared_tokens` returns None where no worker's engine can copy anything
  in, and `cache_aware` then borrows the device hits instead of a copy.
- `KvEventMonitor` counts the subscriptions of ranks in a share group and
  returns at once below two, without walking the subscriptions. At the
  default `--kv-share-weight` and with no rank reporting a `kv_pool`, a
  request does no new work.
- The monitor test follows a rank again and detaches one, and checks the
  count and that no rank copies anything in without another of its group.
Its 64 requests share the test's one thread with the pool's answers, and on a
loaded machine they took longer than the 500 ms the other lookup tests allow.
…wan/mesh-umbp-share-groups

# Conflicts:
#	atom/mesh/src/policies/cache_aware.rs
…it does not ask

The kv_events e2e runs at weights 1, 0.5 and 0 against a store that answers
after 50 ms, past the 3 ms default deadline, and checks that a prompt whose
device hit is all the engine would take of it asks no store. The monitor test
adds a reader whose own device hit leaves too little to load, a CLI test maps
--kv-storage-weight and --kv-storage-deadline-ms, and the Python key test
checks rank 1's keys as the Rust one does.

The weight reaches the monitor at any value, and the docs say how pools and
ranks lower the chunk cap and that a retried request asks again.
Hand the weight over unconditionally: at 0 the monitor already ignores
share groups. A test now fails when the weight is hardcoded on its way
from the flag to the monitor, or left out of the RouterConfig. Say that
shared_tokens is None while share groups are ignored.
…wan/mesh-umbp-share-groups

# Conflicts:
#	atom/mesh/src/policies/cache_aware.rs
ATOM's umbp_pool can put only share_ratio of a rank's blocks in the UMBP
pool and keep the rest private; the other ranks of its group can copy in
only the shared part. Such a rank now joins its share group with a second
lane in its partition: the blocks it reports under the GPU_SHARED medium,
named by hash and placed by its own GPU chain, gone once the rank lets go
of them or is reset. A rank's copy-in walk takes its own lane and the
lanes its group shares: the GPU lane of a rank that shares all its blocks,
the GPU_SHARED lane of one that keeps some private. /kv_events/sources
shows the second lane's blocks as shared_blocks.
…kup-main

# Conflicts:
#	atom/mesh/src/app_context.rs
#	atom/mesh/src/cliargs.rs
#	atom/mesh/src/config/validation.rs
wanzhenchn and others added 4 commits November 25, 2026 10:33
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Brings in main at 13d1d28, with the umbp_pool connector (#3482) whose pool this branch has ATOM report.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hare groups

`/kv_event_sources` carries `kv_pool` for the ranks of a server that runs the
`umbp_pool` connector (#3482): the backend, the UMBP server's address, the
share group, the share ratio and whether the rank fetches. The group is the one
each rank's pool attaches to: the setting, or what the pools derive from the
model and KV format when it is empty, so engines started alike on one server
report one group. Found inside `multi` as the Store's report is.

The router makes its share groups of these: the ranks of one node that report
one address and group, with `fetch` on, are scored by what their group holds,
at `--kv-share-weight`. No server reported a pool until now, so no rank was in
a share group and the routing was that of the base.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A rank on the `umbp_pool` connector copies the prefix it misses from the pools
of its share group and then hits it like a local one, but the copy published
nothing: `BlockStored` went out only for blocks a rank computed, loaded from a
store or received over P/D. A consumer of the events (the Atomesh router) took
the rank to hold none of them, and dropped the blocks the rank computed after
them, whose parent it had never seen stored there. With `UMBP_L1_KEEP_COPIES`
the source gives its copy up first, so the prefix then left the router's index
altogether.

A pool now says which of the hashes a finished background copy was asked for
it indexed (`poll_fetches`), and the block manager reports each run of them as
one `BlockStored`, as `hash_blocks` reports a forward's (`poll_shared_fetches`,
which the scheduler polls in place of the pool). An in-line fetch reports its
leading run alike. This is the second of the three reports #3620 asks of ATOM.

On MI355X, DeepSeek-V4.1-Flash P/D with two prefill workers of two DP ranks
and one decode worker on one node, the four prefill ranks one share group
(mori 46510220 and 94c7f60f): over a 300 s window the router's estimate of
the cached tokens was 38,233,600 against the 38,042,240 the engines reported
(+0.50%, 497 requests, c64, no eviction), and 142,802,176 against 143,012,608
(-0.15%, 1,942 requests, c256, the four pools full and 304 GiB evicted over
the run). Those runs were of a test branch whose router policy and event
token encoding differ from this branch's (`agentic` on #3406 with the share
tier, tokens packed by numpy); the pool, the block manager's report and the
router's share groups are the ones here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Base automatically changed from zwan/mesh-kvev-m5-lookup to main November 27, 2026 05:42
#3344 went into main as one squashed commit (bb5d270), which this branch
carried as its own history. The merge keeps main's tree and this branch's
changes over #3344's head (f900792). One hand resolution, in
Scheduler.schedule: main wraps _schedule() in a try/finally that clears the
decode block reservation, this branch polls the shared pool's fetches through
BlockManager.poll_shared_fetches() first.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@jgong5 jgong5 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST CHANGES @ 1a83eb4: 1 blocking.

This adds the second tier the way #3344 added the first. It puts shared_tokens and share_weight on PrefixMatchProvider, keeps the weight in a OnceLock on the monitor, adds a router-wide flag, and adds one more hand-written term to cache_aware's score. A third tier, such as LMCache's CPU tier, would repeat all four, and agentic (#3406) needs each tier wired in separately.

Fix before this lands: the provider returns facts per worker, e.g. TieredHit { device, shared, stored }. The weights live in the policy's config as one TierWeights, next to cache_threshold. One effective_cached(hit, &weights) scores for both cache_aware and agentic, so a new tier is one field. The monitor then holds neither weights nor the store handle, and the policy calls StorageSources::cached_tokens itself.

Watch next: the other #3344 follow-ups and their diagrams are in this comment on #3344.

wanzhenchn and others added 2 commits November 27, 2026 07:12
…e weight flags

#3620's review asks for the weights of the tiers below a worker's device
cache to live in the policy's config, as one TierWeights next to
cache_threshold, instead of in the KV event monitor. This adds the
config: CacheAwareConfig.tier_weights is a TierWeights { shared, stored }.

--kv-share-weight and --kv-storage-weight stay as they are, flags and
RouterConfig fields, so the command line and saved configs are unchanged.
RouterConfig::kv_tier_weights() makes the TierWeights of the two,
PolicyRegistry::for_router keeps it, and every cache-aware policy the
registry creates takes it in its config: the default policy, one a
worker's `policy` label asks for by name, and the prefill and decode
policies, which the PD routers now create through the registry
(create_policy). PolicyFactory's two functions keep their signatures and
use the default weights; the registry calls two new ones that take a
router's.

Nothing reads the field yet: the monitor still holds its copies of the
weights and cache_aware still scores with those. The next commit moves
the score over and takes them out of the monitor.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split before review

This PR is +1146/-96 and has not been reviewed yet; our rule for never-reviewed PRs is ≤ ~1000 changed lines per PR so a review converges in one or two rounds. It splits naturally by concern:

  1. Event source and monitoring: kv_events/monitor.rs, kv_events/source.rs and the index/partition support (kv_index/partition.rs, kv_index/index.rs) that record which prefixes a DP rank copies in from its UMBP share group, with their tests.
  2. Use in routing: the policies/cache_aware.rs scoring change that consumes those counts, with its tests and docs.
  3. The Python-side test additions (tests/test_umbp_pool_connector.py, tests/test_umbp_l1_pool.py) go with whichever part they exercise.

Each part should build and pass on its own (part 2 stacked on part 1 is fine; say so in its description).

…red by effective_cached

The rest of #3620's review, which is also the first two design follow-ups
of #3344: a tier no longer adds methods to the index trait, a weight on
the monitor and a hand-written term to cache_aware's score.

- PrefixMatchProvider answers with facts: tiered_hits(tokens, workers,
  weights) returns a TieredHit { device, shared, stored } per worker, each
  tier the tokens past those of the tiers before it. match_workers,
  shared_tokens, cached_tokens and the two weight getters leave the trait.
- effective_cached(hit, &weights) is the one score: device + weights.shared
  x shared + weights.stored x stored, the terms cache_aware added up by
  hand, in the same order. cache_aware holds it, over the prompt's tokens,
  against cache_threshold; hit.cached() is its estimate and hit.shared > 0
  its kv_shared branch.
- The weights are the tier_weights of the policy's config, from the
  previous commit. KvEventMonitor holds neither them nor the store handle:
  share_pools, read_stores and their two OnceLocks are gone, and it no
  longer imports StorageSources or WorkerType.
- The policy asks the stores itself. policies::KvTiers, which the registry
  hands every cache-aware policy in place of the index, has the index
  answer and then calls StorageSources::cached_tokens for the workers that
  are not decode workers, at what each one's device cache will hold once
  the copies are in, as the monitor did.

A tier whose weight is 0 is not asked, as before: the index is passed the
weights with each call and leaves share groups out of its walk at 0, and no
request goes to a store at 0.

TieredHit, effective_cached and KvTiers are pub(crate), for the agentic
policy (#3406) to score with; TierWeights is pub, as CacheAwareConfig is.
Another tier is a field of TieredHit and of TierWeights, its term in
effective_cached, and the place its tokens come from.

Tests: effective_cached against the hand-written score, bit for bit, over
hits and weights; cache_aware's decisions at the same selections, match
rates and estimates as before, the store tier now through StorageSources
and a mock admin service; a weight of 0 sends no request to a store and
leaves the share groups out; the store's readers, moved from the monitor's
tests; the store asked at what the device will hold after the copies.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some changes needed..

e2e run of cache_aware kv_shared branch, and a --kv-share-weight 0 control on the same traces?

ci Run non-GPU unit tests (Pre Checkin) failed — not sure yet (low): The provided log .valar/ci/job_140337885899.log is empty (0 bytes), so the failure cannot be attributed. The same job passes on main and 8 other recent runs; this PR adds Python tests (tests/test_umbp_l1_pool.py, tests/test_umbp_pool_connector.py, tests/entrypoints/test_api_server_helpers.py) that this job runs.

(log file .valar/ci/job_140337885899.log is empty — 0 bytes)
next: Fetch the job log from the run page and rerun the job; if it reproduces, run the three touched test files locally to tell a PR bug from an infra failure. https://github.com/ROCm/ATOM/actions/runs/45948268735/job/140337885899

Comment thread atom/mesh/src/policies/cache_aware.rs Resolved
Comment thread atom/model_engine/block_manager.py Resolved
@wanzhenchn

Copy link
Copy Markdown
Contributor Author

Done in a189371 and e2e0b8d.

  • PrefixMatchProvider has one fact method, tiered_hits(tokens, workers, &weights), returning a TieredHit { device, shared, stored } per worker. Each tier is the tokens past the tiers before it; stored is None when the store did not answer.
  • The weights are one TierWeights { shared, stored } in CacheAwareConfig, next to cache_threshold. --kv-share-weight and --kv-storage-weight keep their names and defaults; PolicyRegistry::for_router puts them in the config of every cache-aware policy it creates.
  • effective_cached(hit, &weights) in kv_tiers.rs is the only score, pub(crate) for agentic (feat(mesh): agentic routing policy on the KV event index #3406).
  • KvEventMonitor holds neither weights nor the store handle; policies::KvTiers asks the index, then calls StorageSources::cached_tokens itself.
  • One difference from the sketch: tiered_hits takes the policy's weights, so that at --kv-share-weight 0 the index still leaves share groups out of its walk.
  • No flag, endpoint, metric or branch changed. Of the feat(mesh): KV events 5/5 — tiered scoring: cache_aware weighs Mooncake Store hits #3344 follow-ups, 1 and 2 are this change; 3 and 4 are not in it.

@wanzhenchn

Copy link
Copy Markdown
Contributor Author

Splitting. The PR was +1146 −96 when this was written; the tier refactor asked for in the review of 1a83eb4 (e2e0b8d) took it to +1973 −352, so it goes three ways, each under 1000 changed lines and each building and passing on its own:

  1. ATOM's reports (Python): kv_pool in /kv_event_sources and BlockStored for the blocks a fetch brings in, with their tests. Independent of the router.
  2. Events, index and monitoring (router), stacked on 1: GPU_SHARED events, the shared lane, the share groups, with their tests. No change to routing.
  3. Use in routing (router), stacked on 2: the tiers and the cache_aware score that reads them, --kv-share-weight, docs and tests. This PR keeps that part, so the comments above stay with the code they are about.

The two new PR numbers follow here once they are up.

@wanzhenchn

Copy link
Copy Markdown
Contributor Author

On the other two points of the review of 09:54 UTC:

wanzhenchn and others added 2 commits November 27, 2026 11:14
…red by effective_cached at the policy's TierWeights

The review of #3620, which is also the first two design follow-ups of #3344:
a tier below a worker's device cache is no longer methods on the index trait,
a weight on the KV event monitor and a hand-written term in cache_aware's
score. This commit gives the one tier `main` has, the Mooncake Store, that
shape, and changes no routing decision. The share tier comes in the next
commit, as a field, a weight and a term.

- PrefixMatchProvider answers with facts: tiered_hits(tokens, workers) returns
  a TieredHit { device, stored } per worker, each tier the tokens past those
  of the tiers before it. match_workers, cached_tokens and store_weight leave
  the trait, and async_trait with them.
- effective_cached(hit, &weights) is the one score: device + weights.stored x
  stored, the terms cache_aware added up by hand, in the same order.
  cache_aware holds it, over the prompt's tokens, against cache_threshold, and
  hit.cached() is its estimate.
- The weights are the policy's: CacheAwareConfig.tier_weights is a TierWeights
  { stored }, next to cache_threshold. --kv-storage-weight stays as it is,
  flag and RouterConfig field, so the command line and saved configs are
  unchanged. RouterConfig::kv_tier_weights() makes the TierWeights of it,
  PolicyRegistry::for_router keeps it, and every cache-aware policy the
  registry creates takes it in its config: the default policy, one a worker's
  `policy` label asks for by name, and the prefill and decode policies, which
  the PD routers now create through the registry (create_policy).
  PolicyFactory's two functions keep their signatures and use the default
  weights; the registry calls two new ones that take a router's.
- The policy asks the stores itself. policies::KvTiers, which the registry
  hands every cache-aware policy in place of the index, has the index answer
  and then calls StorageSources::cached_tokens for the workers that are not
  decode workers, as the monitor did. KvEventMonitor holds neither the weight
  nor the store handle: read_stores and its OnceLock are gone, and it no
  longer imports StorageSources or WorkerType.

A tier whose weight is 0 is not asked, as before: no request goes to a store
at --kv-storage-weight 0.

TieredHit, effective_cached and KvTiers are pub(crate), for the agentic policy
(#3406) to score with; TierWeights is pub, as CacheAwareConfig is. Another
tier is a field of TieredHit and of TierWeights, its term in effective_cached,
and the place its tokens come from.

Tests: effective_cached against the hand-written score, bit for bit, over
hits and weights; cache_aware's store decisions at the selections, match
rates and estimates they had, the store now a StorageSources against a mock
admin service, which gets one request a selection and none at weight 0; the
store's readers, moved from the monitor's tests; the weight on the command
line and in a router's config in the config of the default, by-name and PD
policies.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
cache_aware now counts what a rank's engine will copy in from the device
pools of its UMBP share group, which the router follows since the PR this
one is stacked on. The share tier is a field of TieredHit, a weight in
TierWeights and a term in effective_cached, between the device cache and
the store:

    match_rate = (D + s x (G - D) + w x (C - G)) / N

D is the rank's own device hit, G the leading tokens it holds or its group
shares (TieredHit.shared is G - D), C what its engine will report cached,
store loads included, s --kv-share-weight and w --kv-storage-weight.

- --kv-share-weight, from 0 to 1 and 0.9 by default: the flag, the
  RouterConfig field (0.9 where a saved config has none), its validation,
  and TierWeights.shared, which RouterConfig::kv_tier_weights() fills. Below
  1, the rank that holds the prefix stays first on a tie in depth; 0 ignores
  share groups.
- The index is passed the policy's weights: tiered_hits(tokens, workers,
  &weights) fills `shared` from KvEventMonitor::shared_tokens, which is no
  longer dead code, and leaves the share groups out of its walk at a weight
  of 0. shared_tokens returns at once while fewer than two followed ranks
  are in a share group.
- The stores are asked at TieredHit::on_device(), what the device cache will
  hold once the copies are in, and cached() counts all three tiers, as the
  engine reports the copies cached.
- A decision that counts copies is labelled kv_shared.
- Docs: the kv_affinity and kv_shared rows and what a kv_shared estimate
  counts in docs/metrics.md, and the cache_aware row of the README.

At --kv-share-weight 0, and for ranks that report no kv_pool, routing is
that of the commit before.

Tests: effective_cached against the hand-written three-term score, bit for
bit; of 100 tokens, a worker with 20 on its device and 80 in its group is
selected as kv_shared at 0.9 (match rate 0.74, estimate 0.8) and not at
0.5; both tiers in one match rate, the store asked past the copies; the
monitor's hits at weights 0 and 0.9, and those of a rank that shares part
of its pool; the index asked at the policy's weights; --kv-share-weight
below 0, above 1 or NaN fails validation; the two weights on the command
line in the config of the default, by-name and PD policies, and their
defaults alike however a config is made.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The PR is split as its review asks. #3946 (zwan/mesh-umbp-share-lanes) carries
ATOM's two reports and the router's events, index and monitoring. This branch
keeps the use in routing as two commits on it:

- ea180db: the Mooncake Store tier in the shape the review of 1a83eb4 asks
  for (TieredHit, TierWeights, effective_cached); no routing decision changes.
- aaeb8e6: the share tier as a field, a weight and a term, with
  --kv-share-weight.

The tree is aaeb8e6's. It is this branch's head e2e0b8d merged with main at
af573f0, plus cb0d75c (_record_fetched reports through
record_remote_store, a review fix now in #3946). atom/mesh is unchanged from
e2e0b8d. A merge commit rather than a rewritten history: the branch is not
force-pushed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@wanzhenchn
wanzhenchn changed the base branch from main to zwan/mesh-umbp-share-lanes November 27, 2026 12:23
@wanzhenchn wanzhenchn changed the title feat(mesh): count prefixes a DP rank copies in from its UMBP share group feat(mesh): UMBP share groups 2/2 — cache_aware counts prefixes a DP rank copies in from its share group Nov 27, 2026
@wanzhenchn

Copy link
Copy Markdown
Contributor Author

The split is up, in two parts as the review of 08:31 UTC lays out, not the three I announced above:

  1. feat(mesh): UMBP share groups 1/2 — ATOM's reports and the router's events, index and monitoring #3946, event source and monitoring. ATOM's two reports (Python, with their tests) and the router's kv_pool discovery, GPU_SHARED tier, shared lane, index walk and share groups. On main, 17 files, +959 −72. It builds and passes on its own, and no request is routed differently: the policies read the index as they do on main.
  2. This PR, use in routing, stacked on feat(mesh): UMBP share groups 1/2 — ATOM's reports and the router's events, index and monitoring #3946. Its base is feat(mesh): UMBP share groups 1/2 — ATOM's reports and the router's events, index and monitoring #3946's branch, so Files changed is this part alone: 23 files, +1037 −302.

Two things about this PR as it stands:

  • Size. It is over the 1,000-line guide because it carries two changes. ea180db is the tier refactor asked for in the review of 1a83eb4: it reshapes the Store tier main already has and changes no routing decision (+717 −277). aaeb8e6 is the share tier itself (+404 −109). Each reads on its own. If three PRs are preferred, the first commit becomes a PR between feat(mesh): UMBP share groups 1/2 — ATOM's reports and the router's events, index and monitoring #3946 and this one without a code change: say so and I will do it.
  • History. The branch is not force-pushed. One merge commit (5253a94) brings the two commits in with their tree, so the Commits tab still lists the branch's earlier history. atom/mesh at this head is byte for byte what it was at e2e0b8d.

The fix for _record_fetched (it now reports through record_remote_store) is cb0d75c, in #3946. The e2e of kv_shared with a --kv-share-weight 0 control is still owed, as in the comment of 10:20 UTC.

@wanzhenchn
wanzhenchn added this pull request to stack #3947 November 27, 2026 13:03
#3946, which this PR is stacked on, gained two commits from its review: a
test of the shared tier's removal and clear, decoded and through the
partition's writer, and the documented and debug-asserted rule that the
lanes `match_groups` is given for a group are in one partition. Neither
touches a line this PR changes, so the merge has no conflict and this PR's
diff against #3946 stays the use in routing alone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@wanzhenchn wanzhenchn added the ci:mesh Mesh-only PRs: pass the Accuracy checks on the ATOMesh CI label Nov 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

ci:mesh Mesh-only PRs: pass the Accuracy checks on the ATOMesh CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants