NVIDIA-NeMo/RL #5201
ยท feat(vllm): token capture for Pixtral (Mistral3) images ยท permalinks pin head 2fc3ba0
(before-the-PR links pin the merge base bb9ed78).
capture_processed_media to read Pixtral images and stage them in the
same packed format Omni already uses, so the storage and trainer-side code stay unchanged.main yet.
The driver check in setup.py
still refuses any VLM that is not Omni. The PR says so, and a code comment says so. A follow-up must open that check
and give Pixtral a learner that reads the packed images.Two things stopped Pixtral. First, the worker's setup accepted only Omni's processor and raised
Media capture requires vLLM's Omni dynamic-resolution processor
(before, worker:907).
Second, the capture code required an image's tokens to be one unbroken run
(before, captured_media:479).
Pixtral writes an image as rows of [IMG] tokens with a break token after each row, so it can never be one run.
The PR's own test feeds a Pixtral prompt down the Omni path and gets exactly that rejection
(test_omni_still_requires_one_contiguous_run).
[3, 56, 84] = [colors, height, width], raw pixels. ยท
One [IMG] token covers a 28ร28 cell (14 px patch ร merge 2), so the image is 2 rows ร 3 columns = 6 image tokens. ยท
imgs [1, 24, 588] = [batch, patches, numbers per patch]: 24 patches of 14ร14 pixels, 588 = 3 colors ร 14 ร 14.Legend: green border = works, red border = refused, dashed = still missing. Numbers 0โ5 are the order a run goes through.
Where it lands: RL only, two source files.
vllm_worker_async.py
picks the image family at setup and passes it on;
captured_media.py
reads Pixtral pixels and checks Pixtral's token rows.
No change to the TQ sink or the reassembler: Pixtral is packed into the format they already read.
Worker setup, after (new lines green)
# vLLM worker, once at startup def setup_token_capture(capture_media): info = engine.mm_processor.info if isinstance(info, Mistral3ProcessingInfo): family = "pixtral" image_token = cfg.image_token_index # [IMG] patch, merge = cfg.vision_config.patch_size, cfg.spatial_merge_size # 14, 2 else: require Omni dynamic tiler, else raise # unchanged Omni checks image_token, patch = omni context token, cfg.patch_size
Capture one image, before โ after
# vLLM worker, per chat call, off the event loop def capture_processed_media(prompt, family, cast_dtype, merge): for image in prompt.images: if family == "pixtral": pixels = image.pixel_values.to(cast_dtype) # fp32 โ bf16, size = tensor's own H, W positions = where token == [IMG] # 6 of the 8 tokens require len(positions) == (H/28) * (W/28) # 2 ร 3 = 6 else: pixels = image.pixel_values_flat require positions are one unbroken run # the check Pixtral always failed require every position holds the image token imgs += pack_images(pixels) # [1, 24, 588] โ same for both
Real code: _processed_pixtral_tensors,
the Pixtral position check,
the call site that passes the family and dtype.
Review comments on this change (all small; none blocks the worker side):
C2 ยท getattr defaults kept only for test stubs โ vllm_worker_async.py:1201
C3 ยท setup error still says Omni only โ vllm_worker_async.py:925
C4 ยท width half of the geometry check untested โ test_captured_media_pixtral.py:126
C5 ยท driver and worker keep separate lists of supported families โ vllm_worker_async.py:912
main still stops at the driver check in step 0. To train a Pixtral VLM with token capture,
a follow-up must add Pixtral to that check and give it a learner that reads the packed imgs.
The PR says this was tested end to end on an internal branch that already has those pieces.