Skip to content

feat(engine): multimodal PD through the chat path - #3410

Merged
zhuyuhua-v merged 16 commits into
mainfrom
junyyang/mm-epd-e1
Nov 25, 2026
Merged

zhuyuhua-v merged 16 commits into
mainfrom
junyyang/mm-epd-e1

Conversation

@junyyang-amd

@junyyang-amd junyyang-amd commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Ready for review. Bottom of stack #3768: this PR → #3407 → #3411 → #3412 → #3408 → #3409 → #3415 → #3417.

Why

ATOMesh is gaining image chat for MiniMax-M3.1 and Kimi-K3.1 as a single instance, 1P1D and E/P/D; this series replaces #3371, and #3417 is its design. Before this PR, a non-streaming image chat sent to prefill dropped its transfer metadata, so prefill handed decode nothing. Decode fetched and preprocessed the image again, though it already held prefill's prompt ids.

What changed

sequenceDiagram
    participant M as ATOMesh
    participant P as ATOM prefill
    participant D as ATOM decode
    M->>P: image chat plus kv_transfer_params
    P->>P: preprocess, encode, prefill (handoff kept: new)
    P-->>M: kv_transfer_params plus cache_seed, mrope_position_delta (new)
    M->>D: same chat plus P's params and prompt ids
    D->>D: pretokenized branch, image parts ignored (new)
    D->>D: Sequence seeded with P's cache_seed (new)
Loading
  • The non-streaming image generator (generate_async_multimodal) hands off kv_transfer_params plus cache_seed and mrope_position_delta.
  • A chat whose params hold do_remote_prefill, cache_seed and prompt_token_ids takes the pretokenized branch before the image check, so decode never fetches the image.
  • Such a decode leg (leaves_media_on_prefill) takes cache_seed and mrope_position_delta from its params; a text request reads neither.
  • Such a leg is never prefilled locally (Scheduler.schedule). preprocess_fanout refuses it with a 400 for a delta outside [1 - prompt length, 0], on RapidServe, or on DeepSeek-V4.1 DSpark.

Review focus

  • The delta's upper bound is 0: a real image delta is never positive, and len + delta <= max_model_len admits positions past the cos/sin table.
  • _refuse_prefill_without_media keeps its tier cases on an instance whose only connector is an offload tier, which starts.

Testing

Decode reuses prefill's ids, cache_seed and MRoPE delta without preprocessing. Such a leg is never prefilled locally, a fresh image leg still waits for its KV, and an out-of-range handoff key is a 400.
CPU unit suite green on e15afb2's tree, main cccc96a merged: 15169 passed, 0 failed.

Follow-ups

  • Recovering a preempted image decode instead of failing it: junyyang-amd/ATOM#34.
  • The MRoPE path (Qwen3.5, Qwen4Exp) has CPU tests only; no end-to-end P/D image run yet.
Evidence

In tests/entrypoints/test_pd_prompt_token_ids.py:

  • TestMultimodalPD::test_decode_reuses_prefill_ids_and_cache_seed: P preprocesses once, D's sequence has no media, P's ids, remote_block_ids, P's cache_seed and delta -2.
  • TestMultimodalPD::test_decode_without_cache_seed_preprocesses_the_media, test_prefill_without_handoff_returns_no_kv_params, test_ids_without_remote_prefill_still_preprocess_media.
  • test_media_dropped_leg_is_never_prefilled_locally: no connector, failed receive, requeued, preempted, and on an offload-only instance tier resume, early load and decline after allocation; all seven fail with the refusal off.
  • test_fresh_image_leg_waits_for_remote_kv: fails with not needs_remote_load dropped from the scheduler gate.
  • test_out_of_range_handoff_key_is_400_on_every_endpoint (chat, completions, /v1/messages, /v1/responses), test_a_handed_off_delta_past_the_prompt_is_refused[-4, 1, 4092].
  • test_rapidserve_refuses_a_media_dropped_leg, test_dspark_refuses_a_media_dropped_leg_as_an_image_request.
  • mrope_decode_positions against the old per-request loop: 0 mismatches over 5000 random batches; bs=512 from 395 us to 27 us.
  • test_image_decode_takes_pretokenized_branch, stream and n in {1, 2}: the engine gets P's ids, no media, and params without prompt_token_ids.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every eligible PR before approval:

  • ✅ Pre Checkin: Black, Ruff, catalog schema validation, non-GPU unit tests

Heavy model tests:

  • ✅ Gate checks are published on every PR so required checks do not stay missing
  • ✅ Expensive jobs run only after the PR is approved, or when a matching ci:* label is present
  • ✅ Pre Checkin must pass before approved heavy jobs continue
  • ✅ Without a matching label, expensive jobs also require a relevant path
  • ✅ A matching ci:* label is an explicit request and can open the gate even when paths would otherwise skip it

Path scope:

  • Native ATOM, vLLM, and SGLang use ignore lists: docs/markdown and unrelated plugin or Mesh paths are skipped
  • ATOMesh uses an include list: Mesh code, ATOMesh scripts/workflows/catalogs, OpenAI entrypoints, and Slurm helpers
  • Relevant path alone does not start expensive jobs; approval still opens the automatic path-scoped gate
Label Tests
ci:full Run all heavy PR model tests: native ATOM, vLLM, SGLang, and ATOMesh
ci:atom Run native ATOM model accuracy tests
ci:vllm Run ATOM vLLM OOT model accuracy tests
ci:sglang Run ATOM SGLang model accuracy tests
ci:mesh Run ATOMesh accuracy/benchmark gates for Mesh-related changes

Without a matching ci:* label, heavy jobs are skipped when the path is not relevant or the PR is not approved.
Add labels via the sidebar or gh pr edit 3410 --add-label <label>

@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..

any e2e run of an image chat request through a real P/D pair?

ci green.

Comment thread atom/model_engine/sequence.py Outdated
self.cache_seed = multimodal_cache_seed(multimodal_data)
self.mrope_positions = mrope_positions
self.mrope_position_delta = mrope_position_delta
self.mrope_position_delta = (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the delta never reaches the batch: ScheduledBatch only keeps seqs with mrope_positions, and decode seq has none, so _build_mrope_decode_positions falls back to arange. include nonzero delta seqs in the dict, and assert the delta shows up in ScheduledBatch in the test?

@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.

⚠️ Action required before merge (4)

  1. Make the handed-off mrope_position_delta actually reach the decode positions. ScheduledBatch.mrope_position_deltas (atom/model_engine/scheduler.py:365-369) only keeps seqs whose mrope_positions is not None. A decode leg has none, so _build_mrope_decode_positions (atom/model_ops/attentions/backends.py:1122-1125) falls back to arange, and every image PD decode on an MRoPE model (Qwen3.5 / qwen4_exp) runs at the wrong positions. That makes the sequence.py:322-326 change dead code. A CPU probe confirms it: a seq built with {"cache_seed": 9, "mrope_position_delta": -2} schedules with batch.mrope_position_deltas == {}. Include seqs with a nonzero delta, and assert the delta in ScheduledBatch / the decode positions rather than only on seq (same as valar-cop's inline note).
  2. Don't take the media-less branch for an image decode leg that has no cache_seed. _chat_completions (api_server.py:2223-2227) drops the image whenever prompt_token_ids and do_remote_prefill are present. test_decode_without_cache_seed_keeps_the_text_seed then locks in seed -1 for that case (e.g. a P built before this PR). The image placeholder ids are the same for every image, so these blocks get hashed and registered as plain text, where another request can hit them. preempt() also misses such a seq and recomputes it as text. Require cache_seed in the condition: preprocess the media as before when it is absent, or return a 400.
  3. Validate the new handoff keys at the boundary, and state the "media lives elsewhere" invariant once. sequence.py:314 and :325 take cache_seed / mrope_position_delta straight from client JSON. A float or string fails later in block_manager.py:88 (cache_seed & …) instead of returning a 400. Check both keys as ints next to the prompt_token_ids adapter in protocol.py. Then give preempt() (scheduler.py:4181) one Sequence property to read instead of "cache_seed" in seq.kv_transfer_params. Also drop the new getattr(request_output, "kv_transfer_params_output", None) (api_server.py:1061): RequestOutput always defines the attribute (request.py:16), so read it directly.
  4. Show one real image request through a P/D pair. The tests only check dict plumbing against fakes, which is how (1) got through. The description says "no blocking issues" but shows no end-to-end run. Post a Qwen3.5 image chat through a P+D pair (pd.sh or manual) whose output matches the non-PD answer, or the MMStar subset from #3414.

Scope: works standalone with the legacy ATOMesh relay on main (carry_prompt_token_ids + P's kv_transfer_params → D). No dependency on #3407 / #3414 / #3417. Pre-checkin CI is green; heavy CI has not run.


Reviewed at 4ccc75e.

@valar-cop

valar-cop commented Nov 16, 2026 •

Copy link
Copy Markdown

…e, 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>
…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>
@junyyang-amd

Copy link
Copy Markdown
Contributor Author

Ready for another look: 57ed4d9 addresses all four items. Item 4 is MiniMax-M3.1 full MMStar through 1P1D, 0.7305 against 0.7070 single instance, 0 failed requests; Qwen3.5 P/D cannot match on main because its GDN state is not transferred.

Per item
  1. MRoPE delta to decode positions. ScheduledBatch.mrope_position_deltas now also keeps a seq with no mrope_positions and a nonzero mrope_position_delta, so _build_mrope_decode_positions offsets a decode leg. The test asserts the delta in the batch ({seq.id: -2}) and in the decode positions built from it; both fail with the fix reverted.
  2. No cache_seed, no media-less branch. A decode leg skips its media only when kv_transfer_params carries cache_seed; otherwise the media is preprocessed as before. test_decode_without_cache_seed_keeps_the_text_seed is replaced by a test that the media is preprocessed when cache_seed is absent.
  3. Boundary checks. check_media_handoff, called from resolve_prompt_token_ids in protocol.py, rejects a non-int cache_seed or mrope_position_delta (bool and null included) with a 400 before enqueue. preempt() reads one flag, Sequence.media_on_prefill_instance, set at construction. The getattr on kv_transfer_params_output is gone.
  4. A real image request through a P/D pair.
    • MiniMax-M3.1-Flash (MXFP4, TP4, recipe flags with DSpark), full MMStar (1500) at this commit on MI355X: 1P1D 0.7305 (stderr 0.0115) against single instance 0.7070 (stderr 0.0118), within 2 combined stderr. KV went over Mooncake RDMA (79.65 GB out of P's HCAs, the same into D's), and D never loaded the multimodal processor, so every decode ran media-less.
    • Qwen3.5-35B-A3B-FP8 1P1D diverges from the single instance even on a text prompt, and from run to run: the GDN recurrent state is not sent over Mooncake (only the Kimi builder publishes state_slot_regions). That holds on main too, independent of this PR. On the image run D did receive cache_seed and mrope_position_delta=-176. So the MRoPE path rests on the unit tests in item 1; no MRoPE model has working P/D on main today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
junyyang-amd added a commit to junyyang-amd/ATOM that referenced this pull request Nov 19, 2026
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
ROCm#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 ROCm#3410's does, and covers the null and absent cases.

Closes #167.

@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.

⚠️ Action required before merge (6)

  1. Remove the new per-step cost from the text path. scheduler.py:366-371 now calls getattr(seq, "mrope_position_delta", 0) for every text seq on every step: +25-30 ns/seq, about +2-4% of ScheduledBatch.__init__ at bs≥64 (concurrent same-core A/B vs merge-base, base/base and head/head controls flat). protocol.py:67 adds ~100 ns to every request. Use direct reads, if seq.mrope_positions is not None or seq.mrope_position_delta (every producer passes real Sequences; also faster than base), and call check_media_handoff only if kv_transfer_params:.
  2. Refuse any local prefill of a media-dropped image decode leg, in one place. The preempt guard (scheduler.py:4183-4188) covers 1 of 3 ways in. (a) A D-leg body sent to a server with no consumer connector prefills all prompt tokens locally (probed: 16-token PREFILL, mrope_positions_by_req == {}); the placeholders run as text with arange positions, a silent wrong answer where main preprocessed the image. (b) Under multi (P/D + offload, ATOM_KV_OFFLOAD), a finished receive resumes as an offload prefill (scheduler.py:2357-2412) and recomputes the received image KV the same way. (c) On moriio, a D leg requeued after the connector query (parked cap / can_allocate / budget / allocate failure, scheduler.py:2444-2551) gets (0, False) on the re-query (moriio_connector.py:1992-1994) and is prefilled locally (probed). Put the check where a local prefill chunk is admitted (_schedule_prefill_seq / right after _query_connector_prefill_match), finish the seq with _finish_rejected_waiting, and drop the preempt special case. Not in _unschedulable_reason: that runs before the connector resolves and would reject every normal D leg.
  3. Take the handoff keys only on a remote-prefill decode leg, validated once for every endpoint. sequence.py:313-330 reads cache_seed / mrope_position_delta for any media-less request, and check_media_handoff only checks type is int and only runs on chat/completions. So: cache_seed=-2 or 2**64 passes and hits to_bytes in prefix_hash.py:35 → OverflowError, a 500 that leaks the entry in io_processor.requests (llm_engine.py:937-945), and an engine-core crash when the hash runs in Scheduler.schedule(). /v1/messages (api_server.py:2891), /v1/responses (:3199-3212) and atom_standalone_service.py:1354,1395 skip the check, so "9"/None fail the same way. A text request with {"cache_seed": 9} gets media_on_prefill_instance=True and is finished on preempt as "preempted image decode has no media". cache_seed=-1 drops the image but hashes it as text. A plain text request with {"mrope_position_delta": D} (no seed) on an MRoPE model gets decode positions shifted by D while prefill is not (silent wrong output; probed 4 -> 4+D), D >= 2**63 raises in the worker, and an out-of-range D reads past the cos/sin cache (triton_mrope.py:79-94 has no position mask). Fix: one predicate shared by api_server.py:2223-2228 and Sequence (do_remote_prefill and cache_seed present), validated where every endpoint builds the Sequence (0 <= cache_seed < 2**64, |delta| <= max_model_len). Commit 57ed4d9's "else 400 before enqueue" is false today.
  4. Fix the text this PR made false. api_server.py:1431-1432 and docs/api_image_input.md:50-51 still say a PD prefill cannot hand an image off (now only true for /v1/messages / /v1/responses). Also: protocol.py:~314 "Pre-tokenized text prompt", the resolve_prompt_token_ids docstring, the preempt_running docstring (scheduler.py:4093-4100), the can_recompute_prompts comment (:689-690) and prepare_kv_change (engine_core.py:~461): a KV change now silently finishes in-flight image decodes instead of recomputing them. Document the chat image-PD contract (P returns cache_seed/mrope_position_delta, D needs both plus prompt_token_ids).
  5. Make the decode-position check run in CI. test_handed_off_mrope_delta_offsets_decode_positions uses gpu_stack_import(...backends) and is skipped in the CPU lane (run 44553665130), and no other workflow runs unit tests, so "both fail with the fix reverted" only holds on a GPU host. Test the delta arithmetic without importing backends, and add tests for 2/3 (no connector, out-of-range seed, /v1/messages, text with cache_seed).
  6. Update the PR description. It still says do_remote_prefill + prompt_token_ids is enough to skip the image (head also needs cache_seed) and lists test_decode_without_cache_seed_keeps_the_text_seed, which is now the opposite test.

Missed by our r30 round: 2(a) and the stale text in 4 were already there at 4ccc75e.


Reviewed at fb89abd (Deep; 4 hunters + B3 review-pr, 5 verifiers, C2). Already fixed: delta reaches ScheduledBatch (r30 #1, CPU test ..._reaches_the_batch), media kept without cache_seed (#2), getattr on kv_transfer_params_output dropped (#3), MiniMax-M3.1 MMStar 1P1D 0.7305 vs 0.7070 (#4). Streaming/n>1 P legs send no seed: not a bug (ATOMesh forces stream=false on P; n>1 PD is broken for text on main too). CI green, one accuracy job pending.

junyyang-amd and others added 2 commits November 20, 2026 02:26
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@junyyang-amd

Copy link
Copy Markdown
Contributor Author

Acceptance at e85ef4c2e (#3407's head, which includes this PR at e15afb2): MiniMax-M3.1 image chat through 1P1D matches single-instance serving, with the KV over RDMA. 0 failed requests in every run.

Run Result
m31 direct mmstar 0.7075, stderr 0.0117, n 1500
m31 single mmstar (behind ATOMesh) 0.7196, within 2 stderr of direct
m31 pd mmstar (1P1D) 0.7035, within 2 stderr of single; P's HCAs sent = D's received = 79,297,228,800 bytes
m31 single mmmu-pro standard 0.7855, vision 0.6798, n 1730 each; recipe 0.791 / 0.682
How it was run

Image rocm/atom-dev:nightly_202611200431, TP4 servers on one MI355 node: single on GPUs 0-3; 1P1D with P on GPUs 0-3 and D on 4-7, Mooncake on each side's local HCAs. Harness from #3414 (236ded5) and, for pd, #3416 (9dfff87). The routing check and full details are in #3407.

junyyang-amd added a commit that referenced this pull request Nov 23, 2026
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>
jgong5
jgong5 previously approved these changes Nov 23, 2026
@junyyang-amd
junyyang-amd removed this pull request from stack #3699 November 23, 2026 07:14
@junyyang-amd
junyyang-amd added this pull request to stack #3730 November 23, 2026 07:15
junyyang-amd added a commit that referenced this pull request Nov 23, 2026
…hey check

With #3414 and #3416 closed, the Acceptance table names the PR each result is posted on (#3407, #3410, #3415) instead of harness files; D8, D17, D18 and D20 describe acceptance topologies and the out-of-tree harness; D19 follows #3415's current cell; the per-PR table drops #3414 and #3416.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One conflict: prepare_kv_change's docstring in atom/model_engine/engine_core.py, where main added the ATOM_STORE_ASYNC_RENEW wait and this branch the image decode leg that is finished rather than recomputed. Both kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	atom/entrypoints/atomesh/atom_standalone_service.py
@junyyang-amd
junyyang-amd removed this pull request from stack #3730 November 24, 2026 05:24
@junyyang-amd
junyyang-amd added this pull request to stack #3768 November 24, 2026 05:24
@zhuyuhua-v
zhuyuhua-v merged commit 13d1d28 into main Nov 25, 2026
119 checks passed
@zhuyuhua-v
zhuyuhua-v deleted the junyyang/mm-epd-e1 branch November 25, 2026 09:40
zhuyuhua-v pushed a commit that referenced this pull request Nov 26, 2026
… selection (#3407)

* 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>

* 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>

* 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>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
wanzhenchn added a commit that referenced this pull request Nov 26, 2026
Conflict in atom/model_engine/llm_engine.py: #3410 put its
mrope_position_delta check for a decode leg whose prefill kept the media
where this branch refuses a prompt of no tokens. Both stay, the empty-prompt
check first: the delta check's range is [1 - len(tokens), 0], which is empty
for a prompt of no tokens.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
zhuyuhua-v pushed a commit that referenced this pull request Nov 27, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants