Repository navigation
feat(engine): multimodal PD through the chat path - #3410
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🏷️ CI GuideRuns automatically on every eligible PR before approval:
Heavy model tests:
Path scope:
|
valar-cop
left a comment
There was a problem hiding this comment.
some changes needed..
any e2e run of an image chat request through a real P/D pair?
ci green.
| self.cache_seed = multimodal_cache_seed(multimodal_data) | ||
| self.mrope_positions = mrope_positions | ||
| self.mrope_position_delta = mrope_position_delta | ||
| self.mrope_position_delta = ( |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (4)
- Make the handed-off
mrope_position_deltaactually reach the decode positions.ScheduledBatch.mrope_position_deltas(atom/model_engine/scheduler.py:365-369) only keeps seqs whosemrope_positions is not None. A decode leg has none, so_build_mrope_decode_positions(atom/model_ops/attentions/backends.py:1122-1125) falls back toarange, and every image PD decode on an MRoPE model (Qwen3.5 / qwen4_exp) runs at the wrong positions. That makes thesequence.py:322-326change dead code. A CPU probe confirms it: a seq built with{"cache_seed": 9, "mrope_position_delta": -2}schedules withbatch.mrope_position_deltas == {}. Include seqs with a nonzero delta, and assert the delta inScheduledBatch/ the decode positions rather than only onseq(same as valar-cop's inline note). - 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 wheneverprompt_token_idsanddo_remote_prefillare present.test_decode_without_cache_seed_keeps_the_text_seedthen 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. Requirecache_seedin the condition: preprocess the media as before when it is absent, or return a 400. - Validate the new handoff keys at the boundary, and state the "media lives elsewhere" invariant once.
sequence.py:314and:325takecache_seed/mrope_position_deltastraight from client JSON. A float or string fails later inblock_manager.py:88(cache_seed & …) instead of returning a 400. Check both keys as ints next to theprompt_token_idsadapter inprotocol.py. Then givepreempt()(scheduler.py:4181) oneSequenceproperty to read instead of"cache_seed" in seq.kv_transfer_params. Also drop the newgetattr(request_output, "kv_transfer_params_output", None)(api_server.py:1061):RequestOutputalways defines the attribute (request.py:16), so read it directly. - 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.shor 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.
|
ci triage for e0c73a0:
|
…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>
|
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 Per item
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (6)
- Remove the new per-step cost from the text path.
scheduler.py:366-371now callsgetattr(seq, "mrope_position_delta", 0)for every text seq on every step: +25-30 ns/seq, about +2-4% ofScheduledBatch.__init__at bs≥64 (concurrent same-core A/B vs merge-base, base/base and head/head controls flat).protocol.py:67adds ~100 ns to every request. Use direct reads,if seq.mrope_positions is not None or seq.mrope_position_delta(every producer passes realSequences; also faster than base), and callcheck_media_handoffonlyif kv_transfer_params:. - 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 witharangepositions, a silent wrong answer wheremainpreprocessed the image. (b) Undermulti(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 /allocatefailure,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. - Take the handoff keys only on a remote-prefill decode leg, validated once for every endpoint.
sequence.py:313-330readscache_seed/mrope_position_deltafor any media-less request, andcheck_media_handoffonly checkstype is intand only runs on chat/completions. So:cache_seed=-2or2**64passes and hitsto_bytesinprefix_hash.py:35→ OverflowError, a 500 that leaks the entry inio_processor.requests(llm_engine.py:937-945), and an engine-core crash when the hash runs inScheduler.schedule()./v1/messages(api_server.py:2891),/v1/responses(:3199-3212) andatom_standalone_service.py:1354,1395skip the check, so"9"/Nonefail the same way. A text request with{"cache_seed": 9}getsmedia_on_prefill_instance=Trueand is finished on preempt as "preempted image decode has no media".cache_seed=-1drops 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; probed4 -> 4+D),D >= 2**63raises in the worker, and an out-of-range D reads past the cos/sin cache (triton_mrope.py:79-94has no position mask). Fix: one predicate shared byapi_server.py:2223-2228andSequence(do_remote_prefillandcache_seedpresent), validated where every endpoint builds theSequence(0 <= cache_seed < 2**64,|delta| <= max_model_len). Commit 57ed4d9's "else 400 before enqueue" is false today. - Fix the text this PR made false.
api_server.py:1431-1432anddocs/api_image_input.md:50-51still 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", theresolve_prompt_token_idsdocstring, thepreempt_runningdocstring (scheduler.py:4093-4100), thecan_recompute_promptscomment (:689-690) andprepare_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 returnscache_seed/mrope_position_delta, D needs both plusprompt_token_ids). - Make the decode-position check run in CI.
test_handed_off_mrope_delta_offsets_decode_positionsusesgpu_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 importingbackends, and add tests for 2/3 (no connector, out-of-range seed,/v1/messages, text withcache_seed). - Update the PR description. It still says
do_remote_prefill+prompt_token_idsis enough to skip the image (head also needscache_seed) and liststest_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.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Acceptance at
|
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>
…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
… 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>
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>
…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>
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)generate_async_multimodal) hands offkv_transfer_paramspluscache_seedandmrope_position_delta.do_remote_prefill,cache_seedandprompt_token_idstakes the pretokenized branch before the image check, so decode never fetches the image.leaves_media_on_prefill) takescache_seedandmrope_position_deltafrom its params; a text request reads neither.Scheduler.schedule).preprocess_fanoutrefuses it with a 400 for a delta outside[1 - prompt length, 0], on RapidServe, or on DeepSeek-V4.1 DSpark.Review focus
len + delta <= max_model_lenadmits positions past the cos/sin table._refuse_prefill_without_mediakeeps its tier cases on an instance whose only connector is an offload tier, which starts.Testing
Decode reuses prefill's ids,
cache_seedand 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,
maincccc96a merged: 15169 passed, 0 failed.Follow-ups
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'scache_seedand 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 withnot needs_remote_loaddropped 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_positionsagainst 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 withoutprompt_token_ids.🤖 Generated with Claude Code