Repository navigation
feat(engine): image embedding transport over Mooncake - #3411
Conversation
valar-cop
left a comment
There was a problem hiding this comment.
some changes needed..
any real Mooncake run? transfer_sync_read signature and register_memory are only exercised by the fake engine
ci green.
Addresses the review of #3417: - Each decision names the PR of the stack that implements it (#3410, #3407, #3411-#3413, #3408, #3409, #3414-#3416); the Acceptance table names the PR that adds each check. - No reference outside ROCm/ATOM remains: the requirement, the measurements and the rules decisions rest on are stated in place. - D4/D5 follow #3410: decode clears `is_multimodal` when P kept the media; only the non-streaming single branch returns `cache_seed`. - D6 names the scheduler's actual refusal of a media-less local prefill. - D3 and A3 describe the route-log `match_ratio` check. - D11 says why matched rails do not apply; D12 states E's word handling as implemented, the 503 on a full pool, and the open gap: P's TP ranks do not agree on a read of E's embeddings. D13 notes `image_grid_thw` is dropped with the pixels once leased. - Harness facts follow #3416's defaults (g07, g08, g24 and HCA maps). - The CLAUDE.md row marks the guide as the design of its PR stack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hed rails Review of #3411: - ec_transfer_params carries the rows' dtype; P returns None and encodes itself when it would read them as another dtype. - _place syncs only after giving up victims, and _sync waits on the current stream instead of the whole device. - _open_engine warns that ATOM_MOONCAKE_MATCHED_RAILS is not honoured here. - The module docstring states the one-thread-at-a-time contract. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Round 2 pushed 3d82781. All four inline threads answered; the stack above is restacked by merge. Real Mooncake: two E/P/D MMStar runs on 2026-11-13, before this round, read every image request's embeddings over RDMA. This round does not touch the
Evidence
HCA byte counters over the MiniMax run: E sent 17,256,577,856 bytes and P received exactly 17,256,577,856 bytes; Kimi 56,700,810,816 both ways. New tests: |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hed rails Review of #3411: - ec_transfer_params carries the rows' dtype; P returns None and encodes itself when it would read them as another dtype. - _place syncs only after giving up victims, and _sync waits on the current stream instead of the whole device. - _open_engine warns that ATOM_MOONCAKE_MATCHED_RAILS is not honoured here. - The module docstring states the one-thread-at-a-time contract. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8ce9470 to
40f6af3
Compare
valar-cop
left a comment
There was a problem hiding this comment.
LGTM
ci Run non-GPU unit tests (Pre Checkin) failed — not sure yet (low): The captured job log is 0 bytes, so the failing step and message cannot be read; nothing in the PR's own files is exercised differently from main (the new tests are self-contained CPU tests that pass against the fake engine). Same job is green 7/7 on main and unstable on other recent runs, which is consistent with infra but cannot be proven from an empty log.
log file .valar/ci/job_139660175191.log is empty (0 bytes)
next: Re-run the Pre Checkin unit-test job and attach the log; if it reproduces, check whether it is the pre-existing test_mxfp4_apply_hands_the_shared_output_to_fused_experts failure the author cites from #2713 (unrelated to this diff). https://github.com/ROCm/ATOM/actions/runs/45745425155/job/139660175191
jgong5
left a comment
There was a problem hiding this comment.
The main ask for this PR: put the E→P embedding transfer behind its own interface instead of building it into the Mooncake KV connector.
Right now the coupling goes beyond the transport:
ec_transport.pylives underkv_transfer/disaggregation/mooncake/and calls the KV connector's private helpers (mc._select_ib_devices,mc._configure_mooncake_transport,mc._MOONCAKE_AVAILABLE). A refactor of the KV connector can silently break image serving. The HCA selection is also only half shared:kv_transfer_config["ib_device"]andib_enable_alternate_hcaapply to KV but not here.ec_transfer_paramsis Mooncake-shaped (session, rawaddress,generation), and #3412 and #3409 carry it through the public request schema and ATOMesh. It has no field naming the transport, so a second backend means changing the format.- #3412's
ModelRunnerconstructsEcReaderdirectly, so E/P/D requires Mooncake even on a deployment that runs MoRI for KV.
For comparison, vLLM keeps this as a separate ECConnector (vllm/distributed/ec_transfer/, scheduler + worker roles). Its Mooncake EC connector is one backend and imports nothing from kv_transfer. SGLang picks the backend with --encoder-transfer-backend (ZMQ by default, or Mooncake).
What I'd like to see, kept small (no plugin framework needed):
- A minimal interface: E side
put(key, rows) -> handleand P sideget(handle, key, dtype) -> Tensor | None. The handle is opaque to ATOMesh and the API and carries a"transport"field. - Mooncake as one implementation of it, moved out of the KV connector package. Whatever it shares with the KV connector (HCA selection) becomes a public helper, not private access.
ModelRunnerreaches the reader through that interface, and a failure to construct it falls back to the vision tower, the same as a failed read does today.
Related, and the reason the abstraction matters in practice: the read currently runs synchronously inside P's forward step (the embed_multimodal_batch callback), and that is the whole argument in #3417 (D11) for needing RDMA over an HTTP pull. vLLM loads before the forward (scheduler-side update_state_after_alloc / build_connector_meta, then worker start_load_caches, which only takes data that has already arrived). If P fetched while scheduling the request, a non-RDMA backend would become viable, and Mooncake would be an optimization rather than a requirement. Fine as a follow-up, but please record it in #3417.
Smaller items:
EcReader.readreads whateversession/address/lengththe request supplies, and checks only the word against agenerationfrom the same request.generation: 0against zeroed registered memory passes. Please at least rejectgeneration == 0; the handle also shouldn't be trusted from a client that bypasses ATOMesh (#3412).atom/utils/envs.pyno longer applies to current main; it needs a rebase before the stack lands.
|
ci triage for 2c980fe:
|
Review: keep the E->P embedding transfer out of the Mooncake KV connector. - atom/ec_transfer/base.py: EcWriter.put(key, rows) -> handle and EcReader.get(handle, key, dtype) -> rows | None, with create_writer / create_reader by transport name. A handle carries "transport", "key", "rows" and "dtype"; a backend's own fields sit under its name. - atom/ec_transfer/mooncake.py: the former kv_transfer/.../ec_transport.py (EcPool -> MooncakeEcWriter, EcReader -> MooncakeEcReader). It imports nothing from kv_transfer. The reader takes the server's kv_transfer_config ib_device / ib_enable_alternate_hca / ib_hca_count as the KV connector does. - atom/utils/mooncake_hca.py: HCA selection and the TCP override, public and shared by the KV connector and the EC backend. - get() rejects generation <= 0 and returns None on a malformed handle instead of raising inside P's forward. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up on top of #3411's interface. - ModelRunner builds the reader for a handle's "transport" through create_reader on first use, passing this server's kv_transfer_config. A reader that cannot start (unknown transport, Mooncake missing, engine or memory failure) is recorded as None and the ranks run the vision tower, the same as a failed read; P on MoRI KV no longer needs Mooncake. - The encoder-only server stores through create_writer("mooncake"); the API catches EcStoreFull. - --accept-ec-transfer-params: P takes a chat request's ec_transfer_params only when started with it, and drops them otherwise (warning once). Only a router that runs E and strips client-sent params (ATOMesh) should face a P started with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jgong5
left a comment
There was a problem hiding this comment.
REQUEST CHANGES @ 7324e04: 2 blocking, both inline (reader stream sync, word placement).
Checked: the writer and reader read protocol, and handle_matches rejecting a malformed handle without raising.
Accepted with reservation: reuse by the ATOM_EC_LEASE_S lease alone; an ack word is suggested inline.
Watch next: a log line and a counter for each silent None, so a fallback shows up as more than latency.
| ) | ||
| return None | ||
| ptr = self._buf.data_ptr() | ||
| ret = self._engine.transfer_sync_read( |
There was a problem hiding this comment.
The reader never syncs its stream before the NIC writes _buf. A queued torch.zeros fill (here or on growth) or the previous request's .clone() can run after the RDMA lands: a silent None, or zeroed or foreign rows that still pass the word check. Call _sync(self._buf) before the first transfer_sync_read, as the writer does.
There was a problem hiding this comment.
Fixed in 457165f. get calls _sync(self._buf) before the first transfer_sync_read, after any growth, so the zero fill and the previous read's clone finish before the NIC writes. test_reader_syncs_its_buffer_before_the_nic_writes_it checks the order.
| self._lease_s = envs.ATOM_EC_LEASE_S | ||
| self._clock = clock | ||
| self._entries: deque[_Entry] = deque() | ||
| # Random start: a word left inside another entry's rows never matches. |
There was a problem hiding this comment.
The word check is probabilistic, not "never". When a later entry starts before this one, this word becomes that entry's bf16 rows; a match is about 2^-48 and data dependent. Keep the words in a separate slot table holding (generation, offset, length), so rows never overwrite a word and the handle stays bound to its rows.
There was a problem hiding this comment.
Fixed in 457165f. E's region is now a slot table, then the pool; each slot holds (generation, address, length, ack) and rows never overlap it. The handle carries the slot address, and P takes the rows only if all three values match. Slots run out like space: evicted oldest-first past the lease, else EcStoreFull.
| self._buf = torch.zeros(size_bytes, dtype=torch.uint8, device=device) | ||
| self._engine, self.session = _open_engine(self._buf.device, protocol) | ||
| _register(self._engine, self._buf) | ||
| self._lease_s = envs.ATOM_EC_LEASE_S |
There was a problem hiding this comment.
Reuse depends only on this lease, so a P queue past 60 s silently wastes E's encode and runs the tower, and fallbacks add load. Have P's rank 0 write the generation into a per-entry ack word after group_agree; reclaim acked entries at once and keep the lease as a long backstop.
There was a problem hiding this comment.
Not in this round. The slot's fourth field, ack, is written 0 and reserved for exactly this: P's rank 0 writes the generation after group_agree, and E reclaims at once with the lease as a backstop. The design doc in #3417 records it as the follow-up.
| if ret != 0: | ||
| logger.warning("Image embedding read from %s failed (ret=%d)", session, ret) | ||
| return None | ||
| if self._buf[:_WORD].view(torch.int64).item() != generation: |
There was a problem hiding this comment.
A generation mismatch returns None without a log, as a key mismatch in handle_matches does. The 2-of-4-rank fallback in the #3412 GPU run left no trace for this reason. Log which check failed and count fallbacks.
There was a problem hiding this comment.
Fixed in 457165f. Every None now logs its reason and the running counts per reason (MooncakeEcReader.fallbacks). handle_matches became handle_mismatch, which returns the reason, so a key or dtype mismatch is logged too.
|
Round 3 pushed 7324e04. The E->P transfer now sits behind A handle names its transport; Per review point
Evidence
|
Review round 4 on #3411. - Each entry's generation, address and length live in a slot table at the front of E's registered region, never inside the pool, so a later entry's rows cannot land on them. The handle carries the slot's address; P reads the rows, then the slot, and takes the rows only if all three match. Slots run out like space does: evicted oldest-first past the lease, else EcStoreFull. A fourth field, ack, is written 0 and reserved for P to acknowledge a read. - The reader synchronizes its buffer's stream before the NIC writes into it, so a queued zero fill or the previous read's clone cannot land after. - Every read that returns None logs its reason and the running counts per reason (MooncakeEcReader.fallbacks). handle_matches becomes handle_mismatch, which returns the reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D12 follows #3411's round 4: each entry's generation, address and length sit in a slot table apart from the rows; P syncs before the NIC writes and compares all three; every None is logged and counted by reason. Records reclaiming on a P ack in the slot's reserved field as the follow-up, and the D13 handle gains the slot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
valar-cop
left a comment
There was a problem hiding this comment.
LGTM
ci Run non-GPU unit tests (Pre Checkin) failed — main is already broken the same way (medium): The captured log is 0 bytes so the failing step cannot be read, but the same job fails on main in the same window (2026-11-27T01:35 and 01:57 failures), and the author reports the only local CPU failure is the pre-existing test_mxfp4_apply_hands_the_shared_output_to_fused_experts from #2713. Likely baseline, not this diff.
log file .valar/ci/job_140265699215.log is empty (0 bytes)
same job on main: ['2026-11-27T01:57 failure', '2026-11-27T01:35 failure', '2026-11-27T01:12 success', ...]
next: Re-run the Pre Checkin job once main is green, or attach this run's log; if it reproduces, confirm it is the pre-existing mxfp4 test rather than a new failure in tests/test_ec_transfer.py. https://github.com/ROCm/ATOM/actions/runs/45925486699/job/140265699215
|
Round 4 pushed 457165f; the stack above is restacked by merge, and main is merged in at 03e1b9a. Both blocking items are fixed: the reader syncs before the NIC writes, and generations live in a slot table apart from the rows. Fallbacks are logged and counted by reason. The ack word is reserved in the slot and recorded as a follow-up in #3417. Evidence
|
main's #3884 picks the HCA on the GPU's PCIe switch from its PCI address (nic.rail_rdma_device) instead of rdma<HIP index>. The HCA helpers live in atom/utils/mooncake_hca.py on this branch, so the merge moves that change there: auto_select_ib_device(gpu_bdf), numbered_ib_device for the alternate-HCA scan, and select_ib_devices / ib_device_filter take the GPU's PCI address. The connector and the EC backend both pass gpu_pci_bdf of their GPU; the tests #3884 added or changed patch mooncake_hca. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jgong5
left a comment
There was a problem hiding this comment.
REQUEST CHANGES @ d580a12: one blocking item (slot count); the rest of rounds 3 and 4 checks out.
Checked and fine:
- The transfer sits behind
atom/ec_transfer(EcWriter.put/EcReader.get). The handle names its transport and keeps backend fields under the backend's name, and HCA selection is a public helper that honourskv_transfer_configlike KV does. - Both earlier blocking items are fixed: the reader syncs before the NIC writes, and the slot table makes the read check deterministic (rows never overlap a slot; generation, address and length must all match).
- Fallbacks are logged and counted by reason; malformed handles and
generation <= 0are rejected without raising. - The ack word and scheduling-time fetch are recorded as follow-ups in #3417.
Blocking:
- Slot count caps E's rate.
DEFAULT_SLOTS = 4096(atom/ec_transfer/mooncake.py), and #3412'screate_writer("mooncake", pool_bytes, device)doesn't override it. With reuse gated on the 60 s lease, an E sustains at most ~68 puts/s beforeEcStoreFullsends requests back to PD. That's below E's own throughput for single-image requests (~8.5 ms per image per #3417), so E stops absorbing encode exactly when it's needed most. Please derive the slot count from the pool size (1M slots is only 32 MB) or make it configurable, with a test that a pool's slots don't run out before its bytes do at a typical entry size.
Should fix, here or in the next PR:
kv_transferdependency is back via the main merge (a0b2768).atom/ec_transfer/mooncake.pyimportsgpu_pci_bdfandatom/utils/mooncake_hca.pyimportsrail_rdma_device, both fromatom.kv_transfer.offload.mooncake_store.nic, soutilsnow depends onkv_transfer. Both are PCI/sysfs helpers; please move them intoatom/utils. If it goes to a follow-up PR, link it here.
…utils Review round 5 on #3411. - Slot count: one slot per 64 KiB of E's region (default_slots), so a 1 GiB region holds 16384 entries, ~273 puts/s past a 60 s lease, and an image-sized entry (hundreds of KiB) runs out of space before slots. The table is carved from size_bytes, so the registration stays exactly the region E sized (whole GiB), as Mooncake's slice alignment needs. - gpu_pci_bdf and rail_rdma_device move from kv_transfer/offload/mooncake_store/nic.py to atom/utils/pci_topology.py. nic.py, mooncake_hca, the P/D connector and the EC backend import them from there, so neither atom.utils nor atom.ec_transfer imports atom.kv_transfer; a test checks it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Round 5 pushed 2c980fe; the stack above is restacked by merge. Slot count: one slot per 64 KiB of E's region (
Evidence
|
jgong5
left a comment
There was a problem hiding this comment.
Approving @ 2c980fe. Both items from the last review are fixed:
- Slot count now follows the region (
default_slots: one per 64 KiB), carved fromsize_bytesso the registration stays the whole-GiB region. Image-sized entries run out of space before slots, andtest_space_runs_out_before_slots_at_image_sized_entrieschecks it. gpu_pci_bdf/rail_rdma_devicemoved toatom/utils/pci_topology.pyunchanged; neitheratom.utilsnoratom.ec_transferimportsatom.kv_transfer, with a test guarding it.
Ran test_ec_transfer.py plus every test touching the moved helpers (Store offload, IB device selection, PD/PP): 792 passed, 8 skipped.
…eddings (#3412) * feat(mesh): key routing by image identity and log one routing decision per selection Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(engine): multimodal PD through the chat path Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(engine): image embedding transport over Mooncake Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(engine): encoder-only openai_server; prefill reads E's image embeddings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * up-m1: move the vendored proto manifest out of the routing change (#136) fix(mesh): drop the vendored proto manifest from up-m1 atom/mesh/proto/manifest.json fixes tests/proto_vendor_tests.rs, not image routing, so it leaves this branch for its own upstream fix(mesh) change on the fork's up-manifest branch (one commit on origin/main, the file byte-identical to 5356d07's). Closes #131. * mesh: log the request's media count on Selected worker; one media predicate, one digested chat (#137) mesh: log the request's media count on Selected worker; one media predicate, one digested chat The sampled `Selected worker` route trace event (and `No worker selected`) now carries `media_count`, set once at ingress, so every policy logs the real count; the per-selection `routing decision` debug line and `routing_key_hash` are gone. Chat media detection is one helper, `media_parts`, shared by the count and `with_media_digests`. `AtomAdapter::can_chunk_request` takes ingress's `carries_media` (through `BackendAdapter::prepare_pair`) instead of rescanning the JSON. The digested chat is built once and shared by routing metadata and tokenization. Image routing keys are HTTP chat only: the gRPC descriptor keeps `carries_media: false` and `media_count: 0`. Closes #132. * mesh: test that chat tokens differ by image URL, and run #3407's tests in CI (#140) mesh: test that chat tokens differ by image URL, and run #3407's tests in CI A new ingress test runs chats that differ only in an image URL through IngressRouting's token path with Qwen2-VL's real chat template and asserts different tokens, and identical tokens for the same URL. The KV-events step of atomesh-mocker-benchmark.yaml now also filters on `core::placement` and `observability::route_trace`, so upstream CI runs every test the image routing change adds. Closes #133. * up-m1: key ATOM media chats by all their media at the routing prefix (#144) mesh: key ATOM media chats by all their media at the routing prefix ATOM's engine seeds a media request's whole block-hash chain from all its media, so chats that share text but differ in images share no KV block. Under `--backend atom`, the routing copy of a media chat now also carries one digest of all its media, in order, at the front of the routing text and of the templated prompt, so prefix_hash and cache_aware separate such chats even when the image sits past the prefix window. In-place digests stay; vLLM and SGLang routing is unchanged, and the forwarded body is untouched. Also: /generate's media_count counts the items nested image_data holds ([] and [[],[]] count 0), a PD-router test for an image_url chat through ingress, and docstrings that say what each backend gets. Closes #143. * up-m1: say which blocks each backend keys by a prompt's media (#146) mesh: say which blocks each backend keys by a prompt's media The docstrings of ParsedInference::media_count and CacheAwarePolicy::routed said every engine keys a whole prompt by its media. That holds for ATOM only; vLLM and SGLang key the blocks from the media part on. Both now say what each backend keys. Prose only. Closes #145. * PD image decode: MRoPE delta reaches decode positions, cache_seed gate, handoff key checks (#155) fix(engine): image PD decode positions, cache_seed gate, handoff key checks Answers valarLip's review on #3410: - A decode leg's mrope_position_delta reaches the batch (ScheduledBatch.mrope_position_deltas keeps a seq without mrope_positions whose delta is nonzero), so MRoPE models decode at the right positions. - A decode leg skips its media only when kv_transfer_params carries cache_seed; otherwise the media is preprocessed as before. - cache_seed and mrope_position_delta in kv_transfer_params must be ints, else 400 before enqueue (check_media_handoff). - Preemption reads Sequence.media_on_prefill_instance. - generate_async_multimodal reads kv_transfer_params_output directly. MiniMax-M3.1-Flash full MMStar through 1P1D scores 0.7305 against 0.7070 for the single instance at this head, 0 failed requests. Closes #147. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(engine): image PD decode positions, cache_seed gate, handoff key checks Answers the review on #3410: - A decode leg's mrope_position_delta reaches the batch (ScheduledBatch.mrope_position_deltas keeps a seq without mrope_positions whose delta is nonzero), so MRoPE models decode at the right positions. - A decode leg skips its media only when kv_transfer_params carries cache_seed; otherwise the media is preprocessed as before. - cache_seed and mrope_position_delta in kv_transfer_params must be ints, else 400 before enqueue (check_media_handoff). - Preemption reads Sequence.media_on_prefill_instance. - generate_async_multimodal reads kv_transfer_params_output directly. MiniMax-M3.1-Flash full MMStar through 1P1D scores 0.7305 against 0.7070 for the single instance at this commit, 0 failed requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style(tests): sort imports in test_pd_prompt_token_ids.py Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mesh: one media_count, prepare_pair unchanged, media count on the route trace, routing_tests in CI (#177) mesh: simplify the media plumbing behind image routing keys One field, media_count, with a carries_media() method on InferenceMetadata and RequestDescriptor. prepare_pair keeps its signature; prepare_pair_with_media defaults to it and only the ATOM adapter overrides it. The planner sets media_count once on the task-local route trace, so the trace functions keep their signatures. The routing copy of a chat maps its messages instead of cloning the request, media_parts yields (kind, url), and a routed chat counts its media once. Test literals end in ..Default::default(). CI: the KV-events filter no longer repeats core::placement, and the routing_tests target now runs. Closes #165. * up-m1: key the ATOM front digest by the chat up to its last media, plus detail (#178) mesh: key the ATOM front digest by the chat up to its last media ATOM's cache_seed hashes each image's token position and its decoded pixels, not only its URL. Under --backend atom the front digest now covers the chat with media digested in place, up to and including the last media part, plus whether each image's detail is "low" (the only setting that changes pixels). Different text before the same image, or [a,b] vs [a,c], now get different keys; a later turn over the same images keeps its key. vLLM and SGLang keys are unchanged. The docs say what stays unmatched: DeepSeek-V4.1's per-token types, and an image that changes behind an unchanged URL. Closes #166. * mesh-only: route to ATOM workers with --backend atom, and document it (#176) mesh: launch_atomesh passes --backend atom; tokenizers survive served aliases launch_atomesh (mesh-only) now passes --backend atom unless the command line names a backend, so regular ATOM deployments get the ATOM routing keys. With an OpenAI-compatible backend, discovery labels the /v1/models card's id served_model_name and a non-empty root model_path: an aliased ATOM worker (no root) loads its tokenizer from --tokenizer-path / --model-path instead of fetching the alias, while a vLLM worker's load path still beats the router-wide path. served_model_name is the last tokenizer fallback. The README and the --backend help say ATOM workers need --backend atom and how discovery then names the model. Closes #168. Closes #175. * mesh: test that the ATOM media relay needs prefill's handoff (#179) mesh: an ATOM media relay needs prefill's handoff, and says so A media chat takes the response relay because decode needs prefill's expanded prompt ids and cache_seed, which ATOM's prefill hands off once #3410 lands. execute_atom_relay now treats a null kv_transfer_params, which ATOM's prefill answers when it hands nothing off, like a missing one: 502 prefill_missing_kv_transfer_params instead of a 500 from enrich_decode_kv. The PD test's mock prefill answers an image chat as #3410's does, and covers the null and absent cases. Closes #167. * tests: drop the duplicate conftest import the up-e1 sync merge left Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * up-e1: no local prefill of a media-dropped image decode leg; handoff keys checked on every endpoint (#181) A chat decode leg whose prefill kept the image is no longer prefilled locally (no KV connector, an offload resume, a moriio requeue, a tier load declined after allocation): the scheduler finishes it as unschedulable. `leaves_media_on_prefill` in `sequence.py` marks such a leg, and only it reads `cache_seed` and `mrope_position_delta`. Both keys are range-checked as a 400 on chat, completions, `/v1/messages`, `/v1/responses` and the standalone service when `kv_transfer_params` is set. The decode-position arithmetic moves to `token_layout/decode.py` (`mrope_decode_positions`). `docs/api_image_input.md` describes the chat image P/D contract, including that an offload-tier D refuses image decode legs. Closes #180. * ci(mesh): keep the launch test out of the stdlib-only glob; run routing_tests serially tests/entrypoints/test_atomesh_launch.py matched the Atomesh Benchmark step `unittest discover -p "test_atomesh_*.py"`, which has no pytest; it is renamed test_mesh_only_launch.py and still runs in the CPU suite. The routing_tests step ran its server-spawning tests in parallel, and test_power_of_two_prefers_less_loaded, which times 30 concurrent requests against a slow worker, failed under that load. The step now runs them one at a time, as the local gate does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(mesh): skip the runner-only power-of-two load test instead of serializing routing_tests test_power_of_two_prefers_less_loaded still failed on the GitHub-hosted runner with the routing tests run one at a time, and passes with CI's own command on MI355X hosts, so serializing fixed nothing. Run the routing tests in parallel again and skip that one test in this step until its cause is known. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Media-dropped leg test: main's connector interface and its early-load way in The test's SimpleNamespace connectors lacked the scheduler capability defaults main added (lookup_pending, supports_early_load); build them on the shared KVConnectorSchedulerBase stub instead. Add main's early tier load as a way in: the leg resumes from it and is refused there too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(mesh): pin the prepare pool in the power-of-two load test; run it in CI again test_power_of_two_prefers_less_loaded sends 30 concurrent requests and expects at least 25 to succeed, but the router's default preparation pool scales with the host's CPUs: on a 4-CPU runner it is 2 threads and 20 queue slots, so exactly 8 requests got 503 prepare_queue_full. Reproduced on pit2-p03-g24 under --cpus=4 (10 of 12 runs failed, always 22/30). The test now fixes its pool at 2 threads and 64 slots, and the routing tests run in CI without the skip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * up-e1: no per-request cost on the text path; prompt-bounded MRoPE delta; DSpark and RapidServe refuse a media-dropped leg - Sequence: media_on_prefill_instance is a class default, set only when a request carries kv_transfer_params; the scheduler's refusals and the HTTP and standalone handoff checks run only for a request with params. - The engine intake refuses a handed-off mrope_position_delta outside [1 - prompt length, 0], refuses a media-dropped leg on RapidServe (whose prefill never reaches Scheduler.schedule), and tells the model's request validator about it: DeepSeek-V4.1 refuses DSpark on it. - mrope_decode_positions is decode_positions plus the repeated deltas. - The offload-tier D text is gone; the refusal's ways in are tested as they arise: a failed receive is new, the tier cases run on an offload-only instance. - A fresh image leg waits for its remote KV; stale test and proto text fixed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_transport: carry dtype, sync only the writing stream, warn on matched rails Review of #3411: - ec_transfer_params carries the rows' dtype; P returns None and encodes itself when it would read them as another dtype. - _place syncs only after giving up victims, and _sync waits on the current stream instead of the whole device. - _open_engine warns that ATOM_MOONCAKE_MATCHED_RAILS is not honoured here. - The module docstring states the one-thread-at-a-time contract. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(engine): P's ranks take E's image embeddings only when every read succeeded Each P rank read E's rows and fell back to its own vision tower alone, so one request could run on E's rows on some ranks and on the local tower's on others. E's rows and a rank's own need not be bit-identical, so the ranks' activations could diverge. `ModelRunner.read_image_embeddings` now passes its verdict through `group_agree` on the forward's TP group, then its PCP group (as `agree_kv_budget` does), and every rank runs its tower when any read failed. Every rank reaches the call for the same request at the same point of the step, so the collective lines up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(engine): encoder-only skips MiniMax LM names, grows P's reader, refuses engine routes - VisionEncoder also skips `model.language_model.`: skipping matches checkpoint names before MiniMax-M3's weights_mapping renames them. - EcReader starts at the first request's rows and grows, at least doubling, up to max_model_len rows; a failed grow falls back to the tower. A max_model_len buffer was 12 GiB per prefill rank at MiniMax-M3's 1M context, allocated past the KV cache's share. - Under --encoder-only every route but chat, /v1/models, /health and /metrics answers 400 instead of a 500 from the absent engine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(mesh): the fake runner takes main's launch_mesh keywords #3698 launches the router with a token bridge in place of the standalone service; mesh-only passes the server config alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(engine): image embedding transport over Mooncake Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_transport: carry dtype, sync only the writing stream, warn on matched rails Review of #3411: - ec_transfer_params carries the rows' dtype; P returns None and encodes itself when it would read them as another dtype. - _place syncs only after giving up victims, and _sync waits on the current stream instead of the whole device. - _open_engine warns that ATOM_MOONCAKE_MATCHED_RAILS is not honoured here. - The module docstring states the one-thread-at-a-time contract. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_transfer: own interface, Mooncake as one backend Review: keep the E->P embedding transfer out of the Mooncake KV connector. - atom/ec_transfer/base.py: EcWriter.put(key, rows) -> handle and EcReader.get(handle, key, dtype) -> rows | None, with create_writer / create_reader by transport name. A handle carries "transport", "key", "rows" and "dtype"; a backend's own fields sit under its name. - atom/ec_transfer/mooncake.py: the former kv_transfer/.../ec_transport.py (EcPool -> MooncakeEcWriter, EcReader -> MooncakeEcReader). It imports nothing from kv_transfer. The reader takes the server's kv_transfer_config ib_device / ib_enable_alternate_hca / ib_hca_count as the KV connector does. - atom/utils/mooncake_hca.py: HCA selection and the TCP override, public and shared by the KV connector and the EC backend. - get() rejects generation <= 0 and returns None on a malformed handle instead of raising inside P's forward. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * E/P/D: reach image embeddings through atom.ec_transfer Review follow-up on top of #3411's interface. - ModelRunner builds the reader for a handle's "transport" through create_reader on first use, passing this server's kv_transfer_config. A reader that cannot start (unknown transport, Mooncake missing, engine or memory failure) is recorded as None and the ranks run the vision tower, the same as a failed read; P on MoRI KV no longer needs Mooncake. - The encoder-only server stores through create_writer("mooncake"); the API catches EcStoreFull. - --accept-ec-transfer-params: P takes a chat request's ec_transfer_params only when started with it, and drops them otherwise (warning once). Only a router that runs E and strips client-sent params (ATOMesh) should face a P started with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_transfer/mooncake: slot table, reader sync, logged fallbacks Review round 4 on #3411. - Each entry's generation, address and length live in a slot table at the front of E's registered region, never inside the pool, so a later entry's rows cannot land on them. The handle carries the slot's address; P reads the rows, then the slot, and takes the rows only if all three match. Slots run out like space does: evicted oldest-first past the lease, else EcStoreFull. A fourth field, ack, is written 0 and reserved for P to acknowledge a read. - The reader synchronizes its buffer's stream before the NIC writes into it, so a queued zero fill or the previous read's clone cannot land after. - Every read that returns None logs its reason and the running counts per reason (MooncakeEcReader.fallbacks). handle_matches becomes handle_mismatch, which returns the reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * encoder-only: builders on the model class, MiniMax-M3 only Review on #3412 (jgong5): - The vision modules come from the model class's encoder_only_modules, found through support_model_arch_dict, instead of a table of MiniMax-M3 and Kimi-K3 builders in atom/model_engine. - Kimi-K3 is dropped: no test or GPU run covered it, and its packed_modules_mapping is set per instance while VisionEncoder takes the class attribute. --encoder-only refuses it. - The ATOM Project Contributors header line on encoder_only.py and its test. - A test that the reader syncs a grown buffer before the NIC writes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * encoder-only: Kimi-K3 through its model class KimiK3ForConditionalGeneration.encoder_only_modules builds vision_tower and mm_projector with kimi_k3_vl.build_vision_modules; the vision_config check moves into _vision_config, shared with __init__. Checked on one MI355X with Kimi-K3.1-Pro: the --encoder-only server answers three image requests (192, 414 and 256 rows) and refuses a text one, and its rows equal, bit for bit, those of the vision modules loaded with load_state_dict(strict=True) straight from the checkpoint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_transfer/mooncake: slots follow the region; PCI topology moves to utils Review round 5 on #3411. - Slot count: one slot per 64 KiB of E's region (default_slots), so a 1 GiB region holds 16384 entries, ~273 puts/s past a 60 s lease, and an image-sized entry (hundreds of KiB) runs out of space before slots. The table is carved from size_bytes, so the registration stays exactly the region E sized (whole GiB), as Mooncake's slice alignment needs. - gpu_pci_bdf and rail_rdma_device move from kv_transfer/offload/mooncake_store/nic.py to atom/utils/pci_topology.py. nic.py, mooncake_hca, the P/D connector and the EC backend import them from there, so neither atom.utils nor atom.ec_transfer imports atom.kv_transfer; a test checks it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
#3411 moved the HCA helpers into atom/utils/mooncake_hca.py; the child still called the removed mc._configure_mooncake_transport and died before BOUND. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ready for review. PR 3 of 8 in stack #3768: #3410 → #3407 → this PR → #3412 → #3408 → #3409 → #3415 → #3417. Stacked on #3407; this PR's diff is its own change only.
Why
This series brings image chat to ATOMesh for MiniMax-M3.1 and Kimi-K3.1, up to E/P/D; #3417 is its design. Before this PR, an encoder server that had just encoded a request's images had no way to hand the rows to a prefill rank.
What changed
sequenceDiagram participant E as MooncakeEcWriter on E (new) participant P as MooncakeEcReader on P (new) E->>E: evict entries past ATOM_EC_LEASE_S, oldest first, zero their slots E->>E: write rows, then their slot (generation, address, length) E-->>P: handle naming the transport, through the request P->>P: sync the buffer's stream P->>E: Mooncake read of the rows, then the slot P->>P: slot differs, handle malformed or read failed: None, loggedatom/ec_transfer/base.py):EcWriter.put(key, rows)returns a handle naming its transport;EcReader.get(handle, key, dtype)returns rows or None.atom/ec_transfer/mooncake.py): P takes rows only if their slot matches the handle, and logs every None by reason.ATOM_EC_LEASE_S(60 s), elseEcStoreFull.atom/utils(mooncake_hca.py,pci_topology.py); nothing here importskv_transfer.Review focus
ackfield is reserved for P's acknowledgement.Testing
P reads E's rows until their space or slot is reused; a racing read, an old generation, generation 0 or a malformed handle gives None. HCAs are configured, PCIe-local or none on TCP.
e2 @ 2c980fe: tests touching Mooncake, the Store offload,
ec_transferorpci_topology, 2536 passed locally.Follow-ups
Evidence
Real Mooncake, E/P/D MMStar on 2026-11-13, before the interface and slot table: MiniMax-M3.1 and Kimi-K3.1, 1500 image requests each, 0 read fallbacks.
In
tests/test_ec_transfer.py, over a fake Mooncake TransferEngine:test_slots_follow_the_region_size,test_whole_region_is_registered_with_derived_slots,test_space_runs_out_before_slots_at_image_sized_entries,test_a_region_too_small_for_its_slots_is_refused.test_p_reads_stored_rows_until_lease_expires_and_slot_is_reused,test_read_racing_a_slot_reuse_sees_a_given_up_slot,test_full_pool_raises_and_keeps_entries_inside_their_lease,test_space_is_reused_oldest_first,test_running_out_of_slots_evicts_only_past_the_lease,test_put_into_free_space_syncs_once.test_slot_holds_generation_address_length_and_a_zero_ack,test_rows_equal_to_an_old_generation_never_revive_its_handle,test_read_refuses_generation_zero.test_read_returns_none_on_foreign_seed_or_failed_read,test_read_returns_none_when_p_reads_another_dtype,test_reader_refuses_rows_larger_than_its_buffer,test_malformed_handle_reads_none_without_raising,test_reader_syncs_its_buffer_before_the_nic_writes_it,test_every_fallback_is_logged_and_counted_by_reason.test_handle_names_its_transport_and_keeps_mooncake_fields_apart,test_factory_builds_mooncake_and_refuses_unknown_transports,test_reader_without_mooncake_raises_on_construction.test_pool_registers_on_the_configured_device,test_pool_registers_on_every_configured_device,test_engine_without_configured_device_uses_the_gpu_local_hca,test_pool_on_tcp_registers_no_hca,test_reader_takes_the_kv_connectors_hca_options,test_engine_registers_on_alternate_hcas,test_matched_rails_warn_that_reads_take_no_rail.test_ec_transfer_imports_nothing_from_kv_transfer.test_pd_pp.py,test_mooncake_rail_address.pyandtest_mooncake_ib_device_select.pypatchmooncake_hca.🤖 Generated with Claude Code