Repository navigation
fix(multimodal): preserve distinct image prompts - #696
Open
Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
Open
Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Same-image context extensions still delete routes from retained training rows, causing require_routed_experts=True to raise and requiring route preservation plus a multi-turn regression test.
1 open issue
What changed in this PR
Fixes #695 by distinguishing image-conditioned requests that share prompt token IDs, preserving distinct transitions through event processing and training-data alignment.
Changes:
- Share a deduplication key based on prompt token IDs and ordered image URLs.
- Align image recovery and route retention with image-aware identity while preserving the trimmed event schema.
- Add API and training-batch regression coverage and document retry behavior.
| File | Description |
|---|---|
tests/verl/test_agl_rollout_manager.py |
Tests image alignment and server-to-training batches with optional required routes. |
tests/server/test_endpoints.py |
Tests image identity, ordering, serialized content, and unchanged triplet output. |
docs/80-example-multimodal-qa.md |
Documents image-aware deduplication and last-response retry behavior. |
agentlightning/verl/agl_rollout_manager.py |
Uses shared prompt identity to align images with triplets. |
agentlightning/server/routes/events.py |
Deduplicates raw events before trimming and preserves routes across different images. |
agentlightning/_prompt_identity.py |
Adds shared image extraction and prompt-key helpers. |
Review effort: Balanced
Comment on lines
+41
to
+43
| if image_urls != extract_image_urls_from_messages(previous_messages): | ||
| # Equal placeholder IDs do not imply equal visual inputs or routes. | ||
| return |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #695.
Different images can produce identical prompt token IDs because the IDs represent image placeholders, not pixels. The triplet view currently treats those requests as retries and drops the earlier image-conditioned transition. The manager repeats the same token-only deduplication when aligning images.
Use a shared key containing prompt IDs and ordered image URLs. Deduplicate before trimming the raw events, then retain the existing triplet schema. The manager uses the same key to align images. Route compaction also preserves previous routed-expert payloads when the image inputs differ; otherwise the newly retained row would fail when R3 requires routes. True same-image retries still keep the last response.
A CPU reproduction with Qwen2-VL preprocessing produced identical 88-token prompts for red and blue images but different pixel tensors. Three requests (red, red retry, blue) previously produced one blue training row; they now produce one red and one blue row. Regression tests exercise the real event API, manager, PIL decoding, and adapter with and without required routed experts. They also cover image order, serialized content, and unchanged trimmed output without data URLs.
Validation
The development environment uses the locked
devandverl-cpudependencies.PYTHONPATHwas set to this checkout's root for the commands below, and imported module paths were verified explicitly..venv/bin/pytest -v --durations=20 tests— 245 passed, 4 skipped..venv/bin/pyright— 0 errors, 0 warnings..venv/bin/pre-commit run --all-files --show-diff-on-failure— passed..venv/bin/ruff check .,.venv/bin/ruff format --check ., and.venv/bin/python scripts/check_headers.py— passed.UV_PROJECT_ENVIRONMENT=/tmp/agent-lightning-image-docs uv run --locked --no-sync mkdocs build --strict,uv build --no-sources, andgit diff --cached --check— passed.The separate docs environment was installed with the locked
docsgroup. Independent review also checked mixed response schemas and server/manager alignment.This was found during a follow-up audit with AI assistance. AI assistance was also used for the fix, tests, and review. The Qwen check used preprocessing only; no model weights, GPU inference, or end-to-end training were run.