SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2509.25050 · ICML · 2026

Advantage Weighted Matching: Aligning RL with Pretraining in Diffusion Models

Chongjian Ge, Zhi-Ming Ma, Yichen Li, Shuchen Xue, Shilong Zhang

arXiv · PDF · Open in the Atlas

Code that ran

7 of 8 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; 2 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 1 no recorded run), measured 2026-11-24; 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/2509.25050.json · badge: /api/ran/2509.25050.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
scxue/advantage_weighted_matching canonical (classifier label)
classifier basis: census
7 ran · 1 no recorded run
FunctionStatusWhere it lives
distribute_samples Ran
ran; our contract draft was wrong, not the code
scxue/advantage_weighted_matching/advantage_weighted_matching/dataset/merge_genevaltask.py
code served (permissive licence) · get_code("7558df3f898efd99")
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
import numpy as np

torch.manual_seed(0)

tasks = ['position', 'color_attr', 'colors', 'counting', 'two_object']
weights = [0.7, 0.3, 0.1, 0.5, 0.1]
total_samples = 1000

ARGS = {
    'tasks': tasks,
    'weights': weights,
    'total_samples': total_samples
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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
extract_scores Ran
ran, honoured the contract we drafted
scxue/advantage_weighted_matching/advantage_weighted_matching/flow_grpo/qwenvl.py
code served (permissive licence) · get_code("aaf3538ea48a524d")
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 list, 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 re

def extract_scores(output_text):
    scores = []
    for text in output_text:
        match = re.search('<Score>(\\d+)</Score>', text)
        if match:
            scores.append(float(match.group(1)) / 5)
        else:
            scores.append(0)
    return scores


ARGS = {
    'output_text': [
        'The result is <Score>5</Score> out of 5',
        'No score here',
        'Rating: <Score>3</Score>',
        'Perfect <Score>5</Score>!'
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
pil_image_to_base64 Ran
ran; our contract draft was wrong, not the code
scxue/advantage_weighted_matching/advantage_weighted_matching/flow_grpo/qwenvl.py
code served (permissive licence) · get_code("679c61d741aabb1d")
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 str. 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 numpy as np

# Create a small PIL Image for testing
image_array = np.random.randint(0, 256, (10, 10, 3), dtype=np.uint8)
test_image = Image.fromarray(image_array, mode='RGB')

ARGS = {
    'image': test_image
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
prompt_training_seed Ran
ran, honoured the contract we drafted
scxue/advantage_weighted_matching/advantage_weighted_matching/flow_grpo/prompt_noise.py
code served (permissive licence) · get_code("2b06f4f15a325a0c")
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 int, ndim 0, dtype family int, 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 torch
import numpy as np
import hashlib
import json

ARGS = {
    'seed': 42,
    'epoch': 0,
    'prompt': 'This is a test prompt for training'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, 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
read_jsonl Ran
ran; our contract draft was wrong, not the code
scxue/advantage_weighted_matching/advantage_weighted_matching/dataset/merge_genevaltask.py
code served (permissive licence) · get_code("90a22cdf7d22703b")
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 list, 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 json
import tempfile
import os

# Create a temporary JSONL file with sample data
temp_dir = tempfile.mkdtemp()
file_path = os.path.join(temp_dir, "test_data.jsonl")

# Write sample JSONL data
with open(file_path, 'w', encoding='utf-8') as f:
    f.write(json.dumps({"id": 1, "text": "hello"}) + "\n")
    f.write(json.dumps({"id": 2, "text": "world"}) + "\n")
    f.write(json.dumps({"id": 3, "text": "test"}) + "\n")

ARGS = {
    "file_path": file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
sample_data Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
scxue/advantage_weighted_matching/advantage_weighted_matching/dataset/merge_genevaltask.py
code served (permissive licence) · get_code("eca464d584595994")
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 list, ndim 1, dtype family int; 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 random

# Set seed for reproducibility
random.seed(0)

# Create sample data - a list of items to sample from
data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# Number of samples needed
samples_needed = 5

ARGS = {
    "data": data,
    "samples_needed": samples_needed,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list 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
shared_prompt_training_inputs Ran
ran; our contract draft was wrong, not the code
scxue/advantage_weighted_matching/advantage_weighted_matching/flow_grpo/prompt_noise.py
code served (permissive licence) · get_code("bfac543ac02f1dd0")
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. 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)

# Build tiny tensors
batch_size = 2
latent_dim = 4
rollout_steps = 16

# latent_template: shape [batch, ...latent_dims]
latent_template = torch.randn(batch_size, latent_dim, dtype=torch.float32)

# schedule: shape [batch, rollout_steps]
schedule = torch.randint(0, 1000, (batch_size, rollout_steps), dtype=torch.long)

# prompt_seeds: list or tensor of seeds, length batch
prompt_seeds = [42, 123]

# num_timesteps: number of diffusion timesteps
num_timesteps = 5

# timestep_fraction: fraction of schedule to use
timestep_fraction = 0.8

# time_type: one of DISCRETE_TIME_TYPES
time_type = 'discrete_with_init'

ARGS = {
    'prompt_seeds': prompt_seeds,
    'schedule': schedule,
    'latent_template': latent_template,
    'num_timesteps': num_timesteps,
    'timestep_fraction': timestep_fraction,
    'time_type': time_type,
}
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 tuple — a tuple output has no array shape of its own; none is 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
get_config Not yet run
unverified (harvested, no recorded run)
scxue/advantage_weighted_matching/advantage_weighted_matching/config/dgx_awm.py
code served (permissive licence) · get_code("b6e22297f43ef430")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 2 later) and 4 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.

FunctionAlso present inEarliest-datedOthers named
get_config 6 other papers
5 dated earlier, 1 later
2305.13301 (2023-05)
Training Diffusion Models with Reinforcement Learning
2310.10639 (2023-10)
Zero-Shot Robotic Manipulation with Pretrained Image-Editing Diffusion Models
2402.08552 (2024-02)
Confronting Reward Overoptimization for Diffusion Models: A Perspective of Inductive and Primacy Biases
and 3 more not named here
pil_image_to_base64 2 other papers
1 dated earlier, 1 later
2505.05470 (2025-05)
Flow-GRPO: Training Flow Matching Models via Online RL
2603.18488 (2026-03)
TexEditor: Structure-Preserving Text-Driven Texture Editing
extract_scores 1 other paper
1 dated earlier
2505.05470 (2025-05)
Flow-GRPO: Training Flow Matching Models via Online RL
read_jsonl 1 other paper
1 dated earlier
2410.13509 (2024-10)
RAG-DDR: Optimizing Retrieval-Augmented Generation Using Differentiable Data Rewards

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

Repositories linked to this paper

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

Abstract

Reinforcement Learning (RL) has emerged as a central paradigm for advancing Large Language Models (LLMs), where pre-training and RL post-training share the same log-likelihood formulation. In contrast, recent RL approaches for diffusion models, most notably Denoising Diffusion Policy Optimization (DDPO), optimize an objective different from the pretraining objectives-score/flow matching loss. In this work, we establish a novel theoretical analysis: DDPO is an implicit form of score/flow matching with noisy targets, which increases variance and slows convergence. Building on this analysis, we introduce Advantage Weighted Matching (AWM), a policy-gradient method for diffusion. It uses the same score/flow-matching loss as pretraining to obtain a lower-variance objective and reweights each sample by its advantage. In effect, AWM raises the influence of high-reward samples and suppresses low-reward ones while keeping the modeling objective identical to pretraining. This unifies pretraining and RL conceptually and practically, is consistent with policy-gradient theory, reduces variance, and yields faster convergence. This simple yet effective design yields substantial benefits: on GenEval, OCR, and PickScore benchmarks, AWM delivers up to a 24× speedup over Flow-GRPO (which builds on DDPO), when applied to Stable Diffusion 3.5 Medium and FLUX, without compromising generation quality. Code is available at https://github.com/scxue/advantage_weighted_matching.

For agents

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

get_harvested_code_for_paper("2509.25050")
get_code_for_paper("2509.25050")
have("2509.25050")

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

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

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

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

Connect an agent — have() is free.