Skip to content

PD image decode: MRoPE delta reaches decode positions, cache_seed gate, handoff key checks - #155

Merged
junyyang-amd merged 1 commit into
up-e1from
task-147
Nov 19, 2026
Merged

junyyang-amd merged 1 commit into
up-e1from
task-147

Conversation

@junyyang-amd

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

Copy link
Copy Markdown
Owner

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

Why

An image request split across a prefill and a decode server ran its decode at text positions on MRoPE models, because the handed-off position offset never reached the batch. A decode leg missing the prefill's image identity hashed its image blocks as plain text, and malformed handoff values failed deep in the engine instead of at the request.

What changed

  • A decode leg's nonzero MRoPE delta now reaches the batch and the decode positions (ScheduledBatch.mrope_position_deltas).
  • A decode leg drops its media only when the handoff carries cache_seed; otherwise the image is processed as before (_chat_completions).
  • A non-integer cache_seed or mrope_position_delta is a 400 before enqueue (check_media_handoff, called by resolve_prompt_token_ids).
  • Preemption reads one flag, Sequence.media_on_prefill_instance; generate_async_multimodal reads kv_transfer_params_output directly.

These answer items 1 to 3 of valarLip's review on ROCm#3410.

Review focus

  • media_on_prefill_instance is fixed at construction: a local image seq also drops multimodal_data once its prefill is scheduled.
  • check_media_handoff sits in resolve_prompt_token_ids, so it covers chat and completions only.

Testing

Item 4 per the Ruling: MiniMax-M3.1 full MMStar through a 1P1D pair behind ATOMesh scores 0.7305, within two combined standard errors of the single instance's 0.7070, with 0 failed requests. Details and the single-request runs are under Evidence.

bbe6a6e: gate green, pytest 13772 passed, 1478 skipped, 2 deselected; cargo ok; black and ruff clean.

Follow-ups

Dev record
atom/entrypoints/openai/api_server.py	code	5	0	4	6
atom/entrypoints/openai/protocol.py	code	9	0	0	9
atom/model_engine/scheduler.py	code	4	0	5	5.25
atom/model_engine/sequence.py	code	4	0	0	4
tests/entrypoints/test_pd_prompt_token_ids.py	test	65	0	3	65.75
total	code	22	0	9	25
total	test	65	0	3	66
Evidence

MMStar (1500), MiniMax-M3.1-Flash-Quark-MXFP4 (/share_nfs/models/amd/MiniMax-M3.1-Flash-Quark-MXFP4), TP4 on pit2-p03-g07, ATOM and ATOMesh from bbe6a6e, rocm/atom-dev:nightly_202611151511, recipe flags with DSpark:

Topology Score Stderr Failed
single, direct 0.7121 0.0117 0
single behind ATOMesh 0.7070 0.0118 0
1P1D behind ATOMesh, Mooncake RDMA 0.7305 0.0115 0

1P1D vs ATOMesh single: +0.0234 against 2 combined stderr 0.0328; vs direct: +0.0184 against 0.0327. The KV crossed RDMA: 79.65 GB out of P's HCAs and into D's. P loaded the multimodal processor; D never did, so every decode leg took the media-less path.

Commands, from the PR worktree with the harness from fork/EPD at 8e00a49 (tests/accept/atomesh_mm/, untracked; its client trusts the lmms-eval checkout as safe.directory):

export ACCEPT_ISSUE=147 ACCEPT_DIR=/share_nfs/junyan_tmp_r120/accept-147 IMAGE=rocm/atom-dev:nightly_202611151511
bash tests/accept/atomesh_mm/accept.sh m31 direct mmstar
bash tests/accept/atomesh_mm/accept.sh m31 single mmstar
bash tests/accept/atomesh_mm/accept.sh m31 pd mmstar

Single-request runs, MMStar index 0, temperature 0, direct 1P1D. M3.1 with DSpark (single, then D):

single: "...Let me look carefully at what's shown.\n\nThe image shows the open trunk of a car (likely a classic car..."
D:      "...Let me look carefully at what's in the image.\n\nThe image shows the open trunk of a car, with a vintage-style suitcase..."

The same M3.1 instance sent the same request differs from itself: image runs split at 84 to 272 characters, text runs at character 0 or 68, with and without DSpark, quick-reduce INT4 and ATOM_FORCE_ATTN_TRITON.

Qwen3.5-35B-A3B-FP8, one GPU each for single, P and D: the handoff carries cache_seed and mrope_position_delta=-176 to D, but D diverges from the third token because the GDN state is not transferred (#156). D log: has_slot_regions=False, block_regions=20, slot_regions=0.

Revert-red (test file on the g07 GPU image, so the positions test runs; one line removed each time, then restored):

Reverted Result Failing test, assertion
or getattr(seq, "mrope_position_delta", 0) in ScheduledBatch 2 failed, 114 passed test_handed_off_mrope_delta_reaches_the_batch: {} == {0: -2}; test_handed_off_mrope_delta_offsets_decode_positions: [[4], [4], [4]] == [[2], [2], [2]]
and "cache_seed" in handoff in _chat_completions 1 failed, 115 passed test_decode_without_cache_seed_preprocesses_the_media: 0 == 1
check_media_handoff(...) call 6 failed, 110 passed test_non_integer_handoff_key_is_400_before_enqueue[*]: 200 == 400

The positions test skips in the CPU gate (no aiter or triton) and passes on g07.

🤖 Generated with Claude Code

…checks

A decode leg has no mrope_positions, so ScheduledBatch dropped its handed-off
mrope_position_delta and the decode builder ran it at text positions: keep a
seq whose delta is nonzero. Preprocess the media of a decode leg that carries
no cache_seed, reject a non-integer cache_seed or mrope_position_delta with a
400, and let preemption read Sequence.media_on_prefill_instance.

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

Copy link
Copy Markdown
Owner Author

Round 1 pushed bbe6a6e.

First round: items 1 to 3 of the review, tests, gate green. Named result blocked; ruling requested on #147.

@junyyang-amd

Copy link
Copy Markdown
Owner Author

Needs owner ruling: the named result is blocked; the question is on #147 (#147).

@junyyang-amd

Copy link
Copy Markdown
Owner Author

Ruling: #147 (comment). Brief updated: Named result.

@junyyang-amd junyyang-amd removed the agent-team/need-human Waits on a human ruling (agent-team) label Nov 19, 2026
@junyyang-amd

Copy link
Copy Markdown
Owner Author

Round 2 pushed bbe6a6e.

No new commit: the Ruling changed only the named result. The M3.1 1P1D run is in the body; it cannot match because the single instance is not reproducible at temperature 0. Ruling requested on #147.

@junyyang-amd junyyang-amd added the agent-team/need-human Waits on a human ruling (agent-team) label Nov 19, 2026
@junyyang-amd

Copy link
Copy Markdown
Owner Author

Ruling: #147 (comment). Brief updated: Named result.

@junyyang-amd junyyang-amd removed the agent-team/need-human Waits on a human ruling (agent-team) label Nov 19, 2026
@junyyang-amd

Copy link
Copy Markdown
Owner Author

Round 3 pushed bbe6a6e.

No new commit: the Ruling changed only the named result.

@junyyang-amd

Copy link
Copy Markdown
Owner Author

APPROVE @ bbe6a6e.

Checked: the whole head against #147 as the second Ruling left it. Items 1 to 3 of valarLip's review are fixed as asked. Item 4 is answered by the M3.1 MMStar run, with Qwen3.5 in #156.
Checked: gate at bbe6a6e on g07, 13772 passed, 1478 skipped, 2 deselected; cargo, black and ruff clean. line_count.py matches the Dev record (code 25, test 66).
Checked: revert-red in my own tree. Each revert turned its test red: the batch delta ({} == {0: -2}), the cache_seed gate (0 == 1), the key check (6 cases, 200 == 400) and media_on_prefill_instance in preempt (WAITING == FINISHED).
Checked: the named result. 1P1D 0.7305 against single 0.7070 is a 0.0234 gap, inside two combined stderr (0.0330), with 0 failed requests.
Accepted with reservation: I did not rerun the positions test or the MMStar runs. Without aiter the positions test skips on CPU; the batch test fails on the same revert.
Watch next: the key check lives in resolve_prompt_token_ids, so an endpoint that builds a Sequence from kv_transfer_params without calling it is unchecked.

@junyyang-amd
junyyang-amd merged commit 2740581 into up-e1 Nov 19, 2026
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