SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2604.28123 · 2026

Beyond SFT-to-RL: Pre-alignment via Black-Box On-Policy Distillation for Multimodal RL

Chen Chen, Chengwei Qin, Zuhao Yang, Wenxuan Wang, Chaojun Xiao, Beier Zhu, Xiaomin Yu, Keming Wu, Yunjian Zhang, Hehai Lin, Weiquan Huang, Sudong Wang, and 1 more

arXiv · PDF · Open in the Atlas

Code that ran

7 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 2 violated it and 0 have no contract verdict; 4 failures of our instrument; 4 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2604.28123.json · badge: /api/ran/2604.28123.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
XIAO4579/PRISM canonical (classifier label)
classifier basis: census
7 ran · 4 no recorded run
FunctionStatusWhere it lives
collate_fn Ran
ran; our contract draft was wrong, not the code
XIAO4579/PRISM/moe/dense_model/train_dense_vl_warmup.py
code served (permissive licence) · get_code("d36fc4b002a2590e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct a batch of data items
batch_item_1 = {
    'teacher_input_ids': torch.randint(0, 100, (5,)),
    'teacher_attention_mask': torch.ones(5, dtype=torch.long),
    'student_input_ids': torch.randint(0, 100, (5,)),
    'student_attention_mask': torch.ones(5, dtype=torch.long),
    'teacher_pixel_values': torch.randn(1, 3, 32, 32),
    'student_pixel_values': torch.randn(1, 3, 32, 32),
    'teacher_image_grid_thw': torch.tensor([2, 16, 16]),
    'student_image_grid_thw': torch.tensor([4, 8, 8]),
}

batch_item_2 = {
    'teacher_input_ids': torch.randint(0, 100, (5,)),
    'teacher_attention_mask': torch.ones(5, dtype=torch.long),
    'student_input_ids': torch.randint(0, 100, (5,)),
    'student_attention_mask': torch.ones(5, dtype=torch.long),
    'teacher_pixel_values': torch.randn(1, 3, 32, 32),
    'student_pixel_values': torch.randn(1, 3, 32, 32),
    'teacher_image_grid_thw': torch.tensor([2, 16, 16]),
    'student_image_grid_thw': torch.tensor([4, 8, 8]),
}

batch = [batch_item_1, batch_item_2]

ARGS = {
    'batch': batch,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
convert_safetensors_to_pt Ran
ran, violated the contract we drafted
XIAO4579/PRISM/moe/convert_value_head.py
code served (permissive licence) · get_code("9c7b92287d75fe98")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import torch
import tempfile
from safetensors.torch import save_file

torch.manual_seed(0)

# Create a temporary directory with a valid safetensors file
temp_dir = tempfile.mkdtemp()

# Create a small state dict
state_dict = {
    'weight': torch.randn(4, 3),
    'bias': torch.randn(3),
}

# Save it as safetensors
safetensors_path = os.path.join(temp_dir, 'value_head.safetensors')
save_file(state_dict, safetensors_path)

ARGS = {
    'model_path': temp_dir,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
safetensors, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_value_head Ran
ran, violated the contract we drafted
XIAO4579/PRISM/moe/extract_value_head.py
code served (permissive licence) · get_code("ee32a88292584e6b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import json
import tempfile
import torch
from safetensors.torch import save_file

torch.manual_seed(0)

# Create a temporary directory to serve as the model_path
temp_dir = tempfile.mkdtemp()

# Create minimal v_head weights
v_head_weights = {
    'v_head.0.weight': torch.randn(4, 3),
    'v_head.0.bias': torch.randn(4),
    'v_head.1.weight': torch.randn(5, 4),
    'v_head.1.bias': torch.randn(5),
}

# Create shard files
shard1_path = os.path.join(temp_dir, 'model-00001-of-00002.safetensors')
shard2_path = os.path.join(temp_dir, 'model-00002-of-00002.safetensors')

shard1_data = {
    'v_head.0.weight': v_head_weights['v_head.0.weight'],
    'v_head.0.bias': v_head_weights['v_head.0.bias'],
}

shard2_data = {
    'v_head.1.weight': v_head_weights['v_head.1.weight'],
    'v_head.1.bias': v_head_weights['v_head.1.bias'],
}

save_file(shard1_data, shard1_path)
save_file(shard2_data, shard2_path)

# Create the index.json file
index = {
    'metadata': {'total_size': 1024},
    'weight_map': {
        'v_head.0.weight': 'model-00001-of-00002.safetensors',
        'v_head.0.bias': 'model-00001-of-00002.safetensors',
        'v_head.1.weight': 'model-00002-of-00002.safetensors',
        'v_head.1.bias': 'model-00002-of-00002.safetensors',
    }
}

index_path = os.path.join(temp_dir, 'model.safetensors.index.json')
with open(index_path, 'w') as f:
    json.dump(index, f)

ARGS = {
    'model_path': temp_dir,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
safetensors, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_last_token_scores Ran
ran; our contract draft was wrong, not the code
XIAO4579/PRISM/moe/dense_model/value_head.py
code served (permissive licence) · get_code("c11b99400c6e3f56")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create small tensors for testing
batch_size = 2
seq_len = 5
num_labels = 4

# Create logits tensor [batch_size, seq_len, num_labels]
logits = torch.randn(batch_size, seq_len, num_labels)

# Create attention_mask for right padding case
# [1, 1, ..., 1, 0, 0, ..., 0]
attention_mask = torch.tensor([
    [1, 1, 1, 0, 0],
    [1, 1, 0, 0, 0]
], dtype=torch.long)

ARGS = {
    "logits": logits,
    "attention_mask": attention_mask,
    "debug": False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_image Ran
ran, honoured the contract we drafted
XIAO4579/PRISM/moe/dense_model/train_dense_vl_warmup.py
code served (permissive licence) · get_code("c6e48cbf2dfb014e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Image. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from PIL import Image
import io
import tempfile
import os

# Create a small test image and save it locally
test_image = Image.new('RGB', (800, 600), color='red')
with tempfile.NamedTemporaryFile(suffix='.png', delete=False) as tmp:
    tmp_path = tmp.name
    test_image.save(tmp_path)

ARGS = {
    'image_source': tmp_path,
    'max_size': 560
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, requests — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
process_sample Ran
ran; our contract draft was wrong, not the code
XIAO4579/PRISM/moe/inference_2_vl_moe.py
code served (permissive licence) · get_code("8927c27669d0e910")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from PIL import Image
from io import BytesIO

torch.manual_seed(0)

class MockProcessor:
    """Minimal processor that mimics a vision-language processor"""
    
    def apply_chat_template(self, messages, tokenize=False, add_generation_prompt=False):
        """Convert messages to a text string"""
        text_parts = []
        for msg in messages:
            role = msg.get('role', '')
            content = msg.get('content', '')
            if isinstance(content, list):
                for item in content:
                    if item.get('type') == 'text':
                        text_parts.append(item.get('text', ''))
            else:
                text_parts.append(str(content))
        return ' '.join(text_parts)
    
    def __call__(self, text=None, images=None, padding=None, max_length=None, 
                 truncation=None, return_tensors=None, max_pixels=None):
        """Process text and images into model inputs"""
        batch_size = len(text) if text else 1
        
        # Return minimal tensors with distinct shapes
        return {
            'input_ids': torch.randint(0, 1000, (batch_size, max_length or 128)),
            'attention_mask': torch.ones((batch_size, max_length or 128)),
            'pixel_values': torch.randn((batch_size, 3, 224, 224)) if images else None,
        }

def create_mock_image():
    """Create a small mock RGB image"""
    img_array = np.random.randint(0, 256, (32, 32, 3), dtype=np.uint8)
    return Image.fromarray(img_array, mode='RGB')

# Create a temporary image file path (we won't actually use file I/O)
mock_image_path = "mock_image.jpg"

# Create test item
item = {
    'prompt': 'What is in this image?',
    'image': mock_image_path,
    'teacher_res': 'This is a detailed teacher response about the image.',
    'student_res': 'This is a shorter student response.'
}

# Create processor mock
processor = MockProcessor()

# Define base path for images
image_base_path = None

# Max length for tokenization
max_length = 128

ARGS = {
    'item': item,
    'processor': processor,
    'image_base_path': image_base_path,
    'max_length': max_length,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, requests, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
process_sample Ran
ran; our contract draft was wrong, not the code
XIAO4579/PRISM/moe/inference_vl_moe.py
code served (permissive licence) · get_code("35a9e9f1edf6e6c1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from PIL import Image
from io import BytesIO

torch.manual_seed(0)

class MockProcessor:
    """Mock processor that mimics LLaVA/vision processor behavior"""
    
    def apply_chat_template(self, messages, tokenize=False, add_generation_prompt=False):
        """Convert messages to text format"""
        text = ""
        for msg in messages:
            role = msg.get('role', '')
            content = msg.get('content', '')
            if isinstance(content, str):
                text += f"[{role}] {content}\n"
            elif isinstance(content, list):
                for item in content:
                    if isinstance(item, dict):
                        if item.get('type') == 'image':
                            text += "[image]\n"
                        elif item.get('type') == 'text':
                            text += item.get('text', '') + "\n"
        return text
    
    def __call__(self, text=None, images=None, padding=None, max_length=None, 
                 truncation=None, return_tensors=None, max_pixels=None):
        """Mock processor call that returns a dict-like object with tensor outputs"""
        batch_size = len(text) if text else 1
        
        # Return mock processor outputs
        return {
            'input_ids': torch.randint(0, 1000, (batch_size, max_length or 512), dtype=torch.long),
            'attention_mask': torch.ones((batch_size, max_length or 512), dtype=torch.long),
            'pixel_values': torch.randn(batch_size, 3, 224, 224) if images and images[0] is not None else None,
        }


def create_test_image():
    """Create a small test image"""
    img = Image.new('RGB', (32, 32), color=(73, 109, 137))
    return img


# Create mock processor
processor = MockProcessor()

# Create test item with image and responses
item = {
    'prompt': 'What is shown in this image?',
    'image': 'test_image.jpg',
    'teacher_res': '<caption>\n- A simple test image\n</caption>\n<think>\nThis is a mock response\n</think>\n<answer>\nA test image\n</answer>',
    'student_res': '<caption>\n- Test image\n</caption>\n<think>\nStudent reasoning\n</think>\n<answer>\nTest answer\n</answer>'
}

# Base path for images (use current directory, no actual file I/O needed)
image_base_path = '/tmp'

# Maximum sequence length
max_length = 512

# Define arguments dictionary
ARGS = {
    'item': item,
    'processor': processor,
    'image_base_path': image_base_path,
    'max_length': max_length
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, requests, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
test_image_forward Not yet run
unverified (harvested, no recorded run)
XIAO4579/PRISM/moe/create_2_vl_moe.py
code served (permissive licence) · get_code("c80cfd02a636fcf2")
How it ran

no invocation recorded.

test_text_only_forward Not yet run
unverified (harvested, no recorded run)
XIAO4579/PRISM/moe/create_2_vl_moe.py
code served (permissive licence) · get_code("76fd4d8019fa116b")
How it ran

no invocation recorded.

upcycle_qwen3_to_moe Not yet run
unverified (harvested, no recorded run)
XIAO4579/PRISM/moe/create_moe.py
code served (permissive licence) · get_code("ea98384919e02f3a")
How it ran

no invocation recorded.

upcycle_qwen3_vl_to_moe Not yet run
unverified (harvested, no recorded run)
XIAO4579/PRISM/moe/create_vl_moe.py
code served (permissive licence) · get_code("016994fd5d99afdc")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

The standard post-training recipe for large multimodal models (LMMs) applies supervised fine-tuning (SFT) on curated demonstrations followed by reinforcement learning with verifiable rewards (RLVR). However, SFT introduces distributional drift that neither preserves the model's original capabilities nor faithfully matches the supervision distribution. This problem is further amplified in multimodal reasoning, where perception errors and reasoning failures follow distinct drift patterns that compound during subsequent RL. We introduce PRISM, a three-stage pipeline that mitigates this drift by inserting an explicit distribution-alignment stage between SFT and RLVR. Building on the principle of on-policy distillation (OPD), PRISM casts alignment as a black-box, response-level adversarial game between the policy and a Mixture-of-Experts (MoE) discriminator with dedicated perception and reasoning experts, providing disentangled corrective signals that steer the policy toward the supervision distribution without requiring access to teacher logits. While 1.26M public demonstrations suffice for broad SFT initialization, distribution alignment demands higher-fidelity supervision; we therefore curate 113K additional demonstrations from Gemini 3 Flash, featuring dense visual grounding and stepby-step reasoning on the hardest unsolved problems. Experiments on Qwen3-VL show that PRISM consistently improves downstream RLVR performance across multiple RL algorithms (GRPO, DAPO, GSPO) and diverse multimodal benchmarks, improving average accuracy by +4.4 and +6.0 points over the SFT→RLVR baseline on 4B and 8B, respectively. Our code, data, and model checkpoints are publicly available at https://github.com/XIAO4579/PRISM.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2604.28123")
get_code_for_paper("2604.28123")
have("2604.28123")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2604.28123.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2604.28123.svg)](https://syntology.ai/paper/2604.28123)

Connect an agent — have() is free.