SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.09655 · 2025

DRA-GRPO: Your GRPO Needs to Know Diverse Reasoning Paths for Mathematical Reasoning

arXiv · PDF · Open in the Atlas

Code that ran

8 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; 1 honoured the contract we drafted, 1 violated it and 1 has no contract verdict; 5 failures of our instrument; 0 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; 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/2505.09655.json · badge: /api/ran/2505.09655.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
xiwenc1/dra-grpo canonical (classifier label)
classifier basis not recorded on the link
8 ran · 0 no recorded run
FunctionStatusWhere it lives
apply_chat_template Ran
ran; our contract draft was wrong, not the code
xiwenc1/dra-grpo/src/open_r1/trl/data_utils.py
code served (permissive licence) · get_code("53017c7a8e570221")
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
from transformers import PreTrainedTokenizer
from typing import Optional, Union, Callable

torch.manual_seed(0)

class MockTokenizer(PreTrainedTokenizer):
    """Minimal tokenizer mock with apply_chat_template method"""
    
    def __init__(self):
        # Initialize with minimal required attributes
        self.model_max_length = 512
        self.eos_token = "</s>"
        self.bos_token = "<s>"
        self.unk_token = "<unk>"
        self.pad_token = "<pad>"
    
    def apply_chat_template(self, messages, tools=None, tokenize=True, 
                           add_generation_prompt=False, continue_final_message=False):
        """Mock implementation that returns formatted text"""
        if isinstance(messages, str):
            return messages
        
        # Build a simple text representation
        text_parts = []
        for msg in messages:
            role = msg.get('role', 'user')
            content = msg.get('content', '')
            text_parts.append(f"{role}: {content}")
        
        result = "\n".join(text_parts)
        
        if add_generation_prompt:
            result += "\nassistant:"
        
        if continue_final_message and messages and messages[-1].get('role') == 'assistant':
            # Remove the last closing if we're continuing
            pass
        
        return result
    
    def vocab_size(self):
        return 1000
    
    def get_vocab(self):
        return {}


# Create a minimal example with 'prompt' and 'completion' keys
example = {
    'prompt': [
        {'role': 'user', 'content': 'What is 2+2?'}
    ],
    'completion': [
        {'role': 'assistant', 'content': 'The answer is 4.'}
    ]
}

tokenizer = MockTokenizer()

tools = None

ARGS = {
    'example': example,
    'tokenizer': tokenizer,
    'tools': tools
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — 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
flatten_dict Ran
ran; our contract draft was wrong, not the code
xiwenc1/dra-grpo/src/open_r1/trl/core.py
code served (permissive licence) · get_code("dfd0ecd9cb25af69")
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
from collections.abc import Mapping

torch.manual_seed(0)

# Create a nested dictionary with various data types
nested_dict = {
    'model': {
        'layers': {
            'layer1': 0.5,
            'layer2': 0.3
        },
        'name': 'test_model'
    },
    'training': {
        'epochs': 100,
        'batch_size': 32
    },
    'data': 42
}

# The function takes:
# 1. nested: dict - a nested dictionary to flatten
# 2. sep: str - separator to use when concatenating keys (default '/')

ARGS = {
    'nested': nested_dict,
    'sep': '/'
}
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
format_reward Ran
ran, honoured the contract we drafted
xiwenc1/dra-grpo/src/open_r1/rewards.py
code served (permissive licence) · get_code("0a5c0b6fb53cd48c")
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 torch

torch.manual_seed(0)

# The function expects:
# - completions: a list of lists, where each inner list contains dicts with 'content' key
# - **kwargs: additional keyword arguments (unused in the function body)

# Build valid completions structure
completions = [
    [{'content': 'Some reasoning\n</think>\nFinal answer'}],
    [{'content': 'Thinking process\n</think>\nAnswer here'}],
]

ARGS = {
    'completions': completions,
}
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 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
is_conversational Ran
ran, violated the contract we drafted
xiwenc1/dra-grpo/src/open_r1/trl/data_utils.py
code served (permissive licence) · get_code("3c42df7a6e98e89c")
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 torch

# Example 1: Conversational format with messages
example_conversational = {
    "prompt": [
        {"role": "user", "content": "What color is the sky?"}
    ]
}

# Example 2: Non-conversational format (string prompt)
example_non_conversational = {
    "prompt": "The sky is"
}

# Example 3: Conversational format with chosen/rejected
example_conversational_chosen = {
    "chosen": [
        {"role": "assistant", "content": "The sky is blue."}
    ]
}

# Example 4: Conversational format with messages key
example_conversational_messages = {
    "messages": [
        {"role": "system", "content": "You are helpful."},
        {"role": "user", "content": "Hello"}
    ]
}

# Use the first example as the main test case
ARGS = {
    "example": example_conversational
}
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 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
masked_mean Ran
ran; our contract draft was wrong, not the code
xiwenc1/dra-grpo/src/open_r1/trl/core.py
code served (permissive licence) · get_code("4f7075aac2163cbc")
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 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 torch
import numpy as np

torch.manual_seed(0)

# Create small tensors for testing masked_mean
# values: tensor of shape (2, 4) with float values
values = torch.randn(2, 4)

# mask: binary tensor of same shape as values, with 0s and 1s
mask = torch.randint(0, 2, (2, 4)).float()

# axis: can be None or an integer axis
axis = None

ARGS = {
    "values": values,
    "mask": mask,
    "axis": axis,
}
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 Tensor, 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
masked_var Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
xiwenc1/dra-grpo/src/open_r1/trl/core.py
code served (permissive licence) · get_code("67607956afbb2a83")
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 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 torch

torch.manual_seed(0)

# Create small test tensors
# values: the tensor to compute variance over
# mask: binary mask to select which values to include
values = torch.randn(2, 4)  # shape (2, 4)
mask = torch.ones(2, 4)     # shape (2, 4), all ones means all values are included

ARGS = {
    "values": values,
    "mask": mask,
    "unbiased": True,
}
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 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
maybe_apply_chat_template Ran
ran; our contract draft was wrong, not the code
xiwenc1/dra-grpo/src/open_r1/trl/data_utils.py
code served (permissive licence) · get_code("c695ba9ac4cc3b93")
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
from typing import Any, Callable, Optional, Union
from unittest.mock import Mock

torch.manual_seed(0)

# Create a mock tokenizer
class MockTokenizer:
    def apply_chat_template(
        self,
        messages,
        tools=None,
        tokenize=False,
        add_generation_prompt=False,
        continue_final_message=False
    ):
        # Simple mock: concatenate role and content fields
        if isinstance(messages, list) and len(messages) > 0:
            result = ""
            for msg in messages:
                if isinstance(msg, dict) and 'role' in msg and 'content' in msg:
                    result += f"[{msg['role']}]: {msg['content']} "
            if add_generation_prompt:
                result += "[assistant]: "
            return result.strip()
        return ""

tokenizer = MockTokenizer()

# Create a valid conversational example with prompt and chosen/rejected
example = {
    "prompt": [
        {"role": "user", "content": "What is 2+2?"}
    ],
    "chosen": [
        {"role": "assistant", "content": "The answer is 4."}
    ],
    "rejected": [
        {"role": "assistant", "content": "The answer is 5."}
    ]
}

# Optional tools parameter
tools = None

ARGS = {
    "example": example,
    "tokenizer": tokenizer,
    "tools": tools
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, transformers — 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
tag_count_reward Ran
ran on a synthesized input
xiwenc1/dra-grpo/src/open_r1/rewards.py
code served (permissive licence) · get_code("0a9f60618bd16d86")
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 torch
import numpy as np

torch.manual_seed(0)

# The function expects `completions` which is a list of objects where each element
# has index [0] and that indexed element has a 'content' key.
# Based on the function body, completions is a list of lists/tuples where:
# - completions[i][0] is a dict-like object
# - completions[i][0]['content'] is a string to be analyzed

# Create sample completions with proper structure
completions = [
    [
        {
            'content': '<think>\nThis is a thinking section\n</think>\nThis is the answer.'
        }
    ],
    [
        {
            'content': '<think>\nAnother thought\n</think>\nAnother answer.'
        }
    ]
]

ARGS = {
    'completions': completions
}
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 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

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, 8 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 6 the same month, 7 later) and 0 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
flatten_dict 6 other papers
1 dated earlier, 2 the same month, 3 later
2504.20157 (2025-04)
Toward Evaluative Thinking: Meta Policy Optimization with Evolving Reward Models
2505.15404 (2025-05)
How Should We Enhance the Safety of Large Reasoning Models: An Empirical Study
2505.15656 (2025-05)
Be Careful When Fine-tuning On Open-Source LLMs: Your Fine-tuning Data Could Be Secretly Stolen!
and 3 more not named here
masked_mean 6 other papers
1 dated earlier, 2 the same month, 3 later
2504.20157 (2025-04)
Toward Evaluative Thinking: Meta Policy Optimization with Evolving Reward Models
2505.15404 (2025-05)
How Should We Enhance the Safety of Large Reasoning Models: An Empirical Study
2505.15656 (2025-05)
Be Careful When Fine-tuning On Open-Source LLMs: Your Fine-tuning Data Could Be Secretly Stolen!
and 3 more not named here
masked_var 6 other papers
1 dated earlier, 2 the same month, 3 later
2504.20157 (2025-04)
Toward Evaluative Thinking: Meta Policy Optimization with Evolving Reward Models
2505.15404 (2025-05)
How Should We Enhance the Safety of Large Reasoning Models: An Empirical Study
2505.15656 (2025-05)
Be Careful When Fine-tuning On Open-Source LLMs: Your Fine-tuning Data Could Be Secretly Stolen!
and 3 more not named here
is_conversational 4 other papers
1 dated earlier, 1 the same month, 2 later
2504.20157 (2025-04)
Toward Evaluative Thinking: Meta Policy Optimization with Evolving Reward Models
2505.15656 (2025-05)
Be Careful When Fine-tuning On Open-Source LLMs: Your Fine-tuning Data Could Be Secretly Stolen!
2509.13760 (2025-09)
Iterative Prompt Refinement for Safer Text-to-Image Generation
and 1 more not named here
format_reward 3 other papers
2 dated earlier, 1 later
2503.16219 (2025-03)
Reinforcement Learning for Reasoning in Small LLMs: What Works and What Doesn't
2504.15777 (2025-04)
Tina: Tiny Reasoning Models via LoRA
2601.19404 (2026-01)
RPO:Reinforcement Fine-Tuning with Partial Reasoning Optimization
apply_chat_template 2 other papers
1 the same month, 1 later
2505.15656 (2025-05)
Be Careful When Fine-tuning On Open-Source LLMs: Your Fine-tuning Data Could Be Secretly Stolen!
2509.13760 (2025-09)
Iterative Prompt Refinement for Safer Text-to-Image Generation
maybe_apply_chat_template 2 other papers
1 the same month, 1 later
2505.15656 (2025-05)
Be Careful When Fine-tuning On Open-Source LLMs: Your Fine-tuning Data Could Be Secretly Stolen!
2509.13760 (2025-09)
Iterative Prompt Refinement for Safer Text-to-Image Generation
tag_count_reward 2 other papers
2 dated earlier
2503.16219 (2025-03)
Reinforcement Learning for Reasoning in Small LLMs: What Works and What Doesn't
2504.15777 (2025-04)
Tina: Tiny Reasoning Models via LoRA

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

Post-training LLMs with Reinforcement Learning, specifically Group Relative Policy Optimization (GRPO), has emerged as a paradigm for enhancing mathematical reasoning. However, standard GRPO relies on scalar correctness rewards that are often non-injective with respect to semantic content: distinct reasoning paths receive identical rewards. This leads to a Diversity-Quality Inconsistency, where the policy collapses into a narrow set of dominant modes while ignoring equally valid but structurally novel strategies. To bridge this gap, we propose Diversity-aware Reward Adjustment (DRA), a theoretically grounded framework that calibrates the reward signal using the semantic density of sampled groups. By leveraging Submodular Mutual Information (SMI), DRA implements an Inverse Propensity Scoring (IPS) mechanism that effectively de-biases the gradient estimation. This creates a repulsive force against redundancy, driving the policy to achieve better coverage of the high-reward landscape. Our method is plug-and-play and integrates seamlessly with GRPO variants. Empirical evaluations on five math benchmarks demonstrate that DRA-GRPO consistently outperforms strong baselines, achieving an average accuracy of 58.2% on DeepSeek-R1-Distill-Qwen-1.5B with only 7,000 training samples and $55 cost, highlighting the critical role of diversity calibration in data-efficient alignment. The code is available at https://github.com/xiwenc1/DRA-GRPO.

For agents

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

get_harvested_code_for_paper("2505.09655")
get_code_for_paper("2505.09655")
have("2505.09655")

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

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

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

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

Connect an agent — have() is free.