Why a Pixtral VLM could not use token capture, and what this PR adds

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).

Before
Token capture only understood one image format: the Nemotron Omni processor. Turning it on for a Pixtral (Mistral3) model failed at setup, and even past setup the capture code would refuse every Pixtral image.
This PR
Teaches the vLLM worker and 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.
Status
Worker side done; not usable from a run on 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.
Background: token capture. In GRPO the policy generates with vLLM, then the trainer computes log-probs on the same conversation. Without token capture, the trainer rebuilds the input: it re-tokenizes the chat and re-runs the image processor. If anything differs (pixels, image size, where the image tokens sit), the trainer scores a slightly different input than the one the policy saw. With token capture on, the vLLM worker stores the exact tokens and the exact processed pixels it used, and the trainer reads those. For a VLM this is how the learner sees the same pixels and image-token positions the policy did. Dotted words have a short explanation: hover or tap them.

The gap: Pixtral lays out image tokens in rows, Omni in one run

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).

Reading the shapes (one 56ร—84 image, from the PR's unit test, patch size 14, merge 2): [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.
Same 56ร—84 image, two processors Omni (supported before) Pixtral / Mistral3 (what this PR adds) 0 driver: uses_image_placeholder(processor) โœ“ Omni processor is on the list setup.py:1355 (unchanged) โœ— still raises on main, before and after 1 worker setup_token_capture โœ“ NanoNemotronVLProcessingInfo, dynamic tiler reads the image-context token id + patch size worker:912 new Mistral3ProcessingInfo branch โœ“ image_token_index, patch 14, merge 2 before: ValueError "requires โ€ฆ Omni โ€ฆ" 2 prompt tokens for the image (green = image token that gets an embedding) ctx ctx ctx โ€ฆ one unbroken run check: positions are one run โœ“ passes IMG IMG IMG BRK IMG IMG IMG END before: โœ— "requires contiguous image embedding positions" after (captured_media:531): count IMG = 6 โœ“ 6 = (56/28 rows) ร— (84/28 cols) = 2 ร— 3 3 pixel_values_flat [3, 56, 84] + imgs_sizes [56, 84] from the processor already in the engine's model dtype _processed_pixtral_tensors (new) pixel_values [3, 56, 84] float32 โ†’ cast to model dtype (bf16); size from the tensor 4 pack_images (shared, unchanged) imgs [1, 24, 588] imgs_sizes [[56, 84]] The two paths become one here. Same staged columns, same trainer-side reassembly. 5 TQ sink + RolloutReassembler _concat_media / _trainer_media: no change learner that reads Pixtral imgs not in this PR (follow-up, per the PR body)

Legend: green border = works, red border = refused, dashed = still missing. Numbers 0โ€“5 are the order a run goes through.

How the PR closes the gap

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

So what. This is the worker half of Pixtral support. After it, a Pixtral image is captured, checked against its own size, and staged exactly like an Omni image, so nothing downstream of the worker changes. But a GRPO run on 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.