Skip to content

mesh: test that the ATOM media relay needs prefill's handoff - #179

Merged
junyyang-amd merged 2 commits into
up-m1from
task-167
Nov 19, 2026
Merged

junyyang-amd merged 2 commits into
up-m1from
task-167

Conversation

@junyyang-amd

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

Copy link
Copy Markdown
Owner

Closes #167. Ready for review. No blocking issues.

Why

An image chat sent down ATOM's PD response relay fails today, because ATOM's multimodal prefill on main hands off nothing: it answers with a null handoff. The relay answered that null with 500 instead of refusing it as a missing handoff, and the PD test hid both: its mock prefill always answered with a handoff.

What changed

  • execute_atom_relay treats a null kv_transfer_params as missing, so such a chat gets 502 prefill_missing_kv_transfer_params, not 500.
  • The mock prefill answers an image chat as feat(engine): multimodal PD through the chat path ROCm/ATOM#3410's prefill does: non-streaming, kv_transfer_params with cache_seed and mrope_position_delta, plus prompt_token_ids. Decode is checked to receive all of them.
  • Two more cases answer the image chat with kv_transfer_params null and absent: the client gets 502 and decode is never called.
  • AtomAdapter::can_chunk_request's comment says media takes the relay because decode needs prefill's expanded ids and cache seed, which ATOM's prefill hands off once feat(engine): multimodal PD through the chat path ROCm/ATOM#3410 lands.

Review focus

Testing

The null and absent cases pass: without prefill's handoff the relay refuses the image chat with 502, so the relay depends on ROCm#3410.
task-167 @ 24c8778: gate.sh green (black, ruff diff, pytest 14819 passed, cargo 1670 passed, 0 failed, one known up-m1 test skipped).

Follow-ups

none

Dev record
line_count.py $(git merge-base fork/up-m1 fork/task-167) fork/task-167
atom/mesh/src/core/placement/backend/atom.rs	code	6	0	3	6.75
atom/mesh/src/routers/http_pd_router.rs	code	3	0	2	3.5
atom/mesh/tests/routing/http_pd_load_tests.rs	test	47	11	8	51.75
total	code	9	0	5	11
total	test	47	11	8	52
Evidence

Revert-red, each mutation run alone with cargo test --lib atom_pd_ingress_relays_an_image_chat in atom-gate:local on g07, then restored:

Mutation Result
execute_atom_relay's null check reverted (Some(v) => v, None =>), at 24c8778 0 passed, 1 failed: left: 500, right: 502 at the null case's status assert
execute_atom_relay takes a missing kv_transfer_params as {} (round 1) 0 passed, 1 failed: the 502 case's response never arrives (Elapsed) because decode is dispatched
can_chunk_request ignores carries_media (round 1) 0 passed, 1 failed: image prefill body has chunked_transfer: true, expected Null

With the change at 24c8778: 1 passed; cargo fmt --check clean.

🤖 Generated with Claude Code

The PD image-chat test's mock prefill now answers as ATOM's multimodal
prefill does once it hands off (non-streaming, kv_transfer_params with
cache_seed and mrope_position_delta, plus prompt_token_ids), and decode
is checked to receive them. A third case answers the image chat without
kv_transfer_params and gets 502 prefill_missing_kv_transfer_params with
decode never reached. can_chunk_request's comment names the dependency
on ROCm#3410.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@junyyang-amd

Copy link
Copy Markdown
Owner Author

Round 1 pushed 1187e64.

  • First round: the mock prefill answers an image chat with a handoff carrying cache_seed, a no-handoff case gets 502, and can_chunk_request's comment names the dependency.

let with_handoff = json!({"choices": [], "prompt_token_ids": prompt_ids,
"kv_transfer_params": handoff});
// One that does not hand off answers the image chat without `kv_transfer_params`.
let without_handoff = json!({"choices": [], "prompt_token_ids": prompt_ids});

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ATOM's prefill answers without a handoff as "kv_transfer_params": null, not by omitting the key (ROCm#3410's test_prefill_without_handoff_returns_no_kv_params). With null here the case gets 500, not 502: execute_atom_relay passes Some(Null) to enrich_decode_kv, which rejects it. Make the mock answer null and have execute_atom_relay treat null as missing.

/// ids prefill expands from the media and the handoff's `cache_seed`,
/// which chunked mode starts decode without. ATOM's multimodal prefill
/// hands them off only once ROCm/ATOM#3410 lands; before it, the relay
/// answers such a request 502 `prefill_missing_kv_transfer_params`.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Against a real ATOM prefill this request gets 500 enrich_decode_kv_failed, not 502 prefill_missing_kv_transfer_params: the prefill returns kv_transfer_params: null. Keep this sentence once execute_atom_relay treats null as missing, or state the real code.

@junyyang-amd

Copy link
Copy Markdown
Owner Author

REQUEST CHANGES @ 1187e64: 1 blocking.

Blocking (inline on the test and on can_chunk_request's comment): the no-handoff mock omits kv_transfer_params, but ATOM's prefill sends it as null. With null the relay answers 500 enrich_decode_kv_failed, so the named result does not hold for the real answer. Fix: execute_atom_relay treats a null kv_transfer_params as missing (one line in atom/mesh/src/routers/http_pd_router.rs, outside #167's file set), and the mock answers null.

Checked: gate on g07 @ 1187e64, green: pytest 14819 passed, cargo 1670 passed, 0 failed, the known up-m1 vendoring test skipped. Merges cleanly into up-m1 @ 3951aae. line_count.py matches the Dev record (code 6, test 48). The handoff mock matches ROCm#3410's pd_engine fixture and response: non-streaming, top-level kv_transfer_params with cache_seed and mrope_position_delta, plus prompt_token_ids. Editing the existing test is justified: its mock was the defect the upstream reviewers named, the text case is unchanged, and the image case's assertions only got stronger.

Accepted with reservation: the Dev record says #167 asks for an in-place extension; #167 only names the PD test's mock.

Watch next: none.

Evidence

Each run: cargo test --lib atom_pd_ingress_relays_an_image_chat in atom-gate:local on g07, file md5 matched on both sides, mtime touched in the container.

Tree Result
head 1 passed
head, mock answers "kv_transfer_params": null 0 passed, 1 failed: left: 500, right: 502 at the status assert
head, execute_atom_relay takes a missing kv_transfer_params as {} 0 passed, 1 failed: Elapsed, decode dispatched

Why null: ChatCompletionResponse.kv_transfer_params defaults to None and the chat path returns resp.model_dump(mode="json"); ROCm#3410's test_prefill_without_handoff_returns_no_kv_params asserts response.json()["kv_transfer_params"] is None. The 500: enrich_decode_kv calls kv.as_object_mut() on null and returns BodyNotObject.

ATOM's prefill answers without a handoff as "kv_transfer_params": null,
which the relay passed to enrich_decode_kv and answered 500. Answer it 502
prefill_missing_kv_transfer_params, as for an absent field, and test both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@junyyang-amd

Copy link
Copy Markdown
Owner Author

Round 2 pushed 24c8778.

task-167 @ 24c8778: gate.sh green (pytest 14819 passed, cargo 1670 passed, 0 failed, one known up-m1 skip).

@junyyang-amd

Copy link
Copy Markdown
Owner Author

APPROVE @ 24c8778.

No blocking issues. Round 1's finding is fixed: ATOM's real no-handoff answer ("kv_transfer_params": null) now gets 502, and the test's null case holds it.

Checked:

  • Gate on g07 @ 24c8778, green: pytest 14819 passed, cargo 1670 passed, 0 failed, the known up-m1 vendoring test skipped. Merges cleanly into up-m1 @ 3951aae.
  • line_count.py matches the Dev record (code 11, test 52).
  • A text request cannot newly get 502 from this change. Before it, a null kv_transfer_params reached enrich_decode_kv, whose as_object_mut() fails on null, so every null answer, text or media, already failed (500 enrich_decode_kv_failed). The change only moves that failure to 502; no answer that used to reach decode is refused.
  • execute_atom_relay is the only place mesh reads kv_transfer_params from a prefill response, so no other site needs the same null check.
  • The extra file is the one-line fix round 1 asked for, which the orchestrator accepted.

Accepted with reservation: can_chunk_request's comment says prefill answers null "before" ROCm#3410 lands; it goes stale when ROCm#3410 lands. The brief asks the comment to name that dependency, so it stays.

Watch next: none.

Evidence

Each run: cargo test -q atom_pd_ingress_relays_an_image_chat in atom-gate:local on g07, file md5 matched on both sides, sources touched with a future mtime in the container.

Tree Result
head 1 passed
head, null check reverted (Some(v) => v, None =>, line count kept) 0 passed, 1 failed: left: 500, right: 502 at the null case's status assert (http_pd_load_tests.rs:545)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant