SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2603.19470 · 2026

Adaptive Layerwise Perturbation: Unifying Off-Policy Corrections for LLM RL

Jing Huang, Tong Zhang, Yifan Hao, Yu Zhou, Xuanchang Zhang, Ziji Zhang, Chen Hao, Chenlu Ye, Abhinav Gullapalli

arXiv · PDF · Open in the Atlas

Code that ran

9 of 10 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, 1 violated it and 2 have no contract verdict; 4 failures of our instrument; 1 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/2603.19470.json · badge: /api/ran/2603.19470.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
amazon-science/adaptive-layerwise-perturbation canonical (classifier label)
classifier basis: census
9 ran · 1 no recorded run
FunctionStatusWhere it lives
change_format Ran
ran; our contract draft was wrong, not the code
amazon-science/adaptive-layerwise-perturbation/multi-turn/sft/prepare_data.py
code served (permissive licence) · get_code("67d84efdd510ba3e")
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 re

def change_format(example):
    """
    Process response format conversion:
    1. Remove <end_of_step> inside <code>...<end_of_code> and replace with ```python ... 
    2. Replace <output>...<end_of_output> with Code execution result: ...
    3. Remove outer tags of <answer>...<end_of_answer>, keep only content
    """
    if 'response' not in example or not example['response']:
        return example
    response = example['response']

    def process_code(match):
        code_content = match.group(1)
        code_content = code_content.replace('<end_of_step>\n', '').replace('<end_of_step>\n\n', '\n')
        return f'```python\n{code_content}\n```'
    response = re.sub('<code>\\s*(.*?)\\s*<end_of_code>', process_code, response, flags=re.DOTALL)

    def process_output(match):
        output_content = match.group(1)
        return f'Code execution result: {output_content}'
    response = re.sub('<output>\\s*(.*?)\\s*<end_of_output>', process_output, response, flags=re.DOTALL)

    def process_answer(match):
        answer_content = match.group(1)
        return answer_content.strip()
    response = re.sub('<answer>\\s*(.*?)\\s*<end_of_answer>', process_answer, response, flags=re.DOTALL)
    example['response'] = response
    return example


ARGS = {
    'example': {
        'response': 'Here is some text <code>\nprint("hello")<end_of_step>\nx = 1\n<end_of_code> and then <output>result here<end_of_output> and finally <answer>  the answer content  <end_of_answer> done.'
    }
}
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 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_to_messages Ran
ran; our contract draft was wrong, not the code
amazon-science/adaptive-layerwise-perturbation/multi-turn/sft/prepare_data.py
code served (permissive licence) · get_code("220deae3dc0666e8")
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)

# Create a simple example dict with query and response
example = {
    'query': 'What is the capital of France?',
    'response': 'The capital of France is Paris.'
}

ARGS = {
    'example': example
}
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
find_last_error_turn Ran
ran, honoured the contract we drafted
amazon-science/adaptive-layerwise-perturbation/multi-turn/sft/custom_masking.py
code served (permissive licence) · get_code("e571d212afdb9fd9")
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 re
from typing import Dict, List

# Test case 1: Text with an error observation
text_with_error = """
Some code here
Code execution result:
Error: Something went wrong

More text
"""

# Test case 2: Text with successful observation
text_with_success = """
Some code here
Code execution result:
42

More text
"""

# Test case 3: Text with multiple observations, last one has error
text_multiple_with_error = """
Code execution result:
Success output

More code
Code execution result:
timeout occurred

"""

# Test case 4: Text with no observations
text_no_observations = "Just some regular text without any observations"

# Test case 5: Text with empty observation
text_empty_obs = """
Code execution result:


"""

# Test case 6: Text with none observation
text_none_obs = """
Code execution result:
None

"""

# Use the first test case as the main argument
ARGS = {
    "text": text_with_error
}
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 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
find_observation_positions Ran
ran, honoured the contract we drafted
amazon-science/adaptive-layerwise-perturbation/multi-turn/sft/custom_masking.py
code served (permissive licence) · get_code("3adf731a6c79f8a2")
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 2, 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 re
from typing import Dict, List

# Setup code to construct valid arguments for find_observation_positions

# Example text with various observation patterns
text_with_observations = """
Some initial text here.

Code execution result:
Successfully executed the command

More text in between.

Code execution result:
Error: timeout occurred during execution

Final section.

Code execution result:
[]

End of document.
"""

# Simpler test case
simple_text = """
Code execution result:
Output data: 123

Code execution result:
Error in traceback
"""

# Edge case with no observations
no_observations_text = "Just regular text without any code execution results"

# Edge case with empty observation
empty_observation_text = """
Code execution result:

More text after
"""

# Edge case with exception
exception_text = """
Code execution result:
Exception: ValueError occurred

Done
"""

ARGS = {
    "text": text_with_observations
}
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 2, 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
generate_completions Ran
ran; our contract draft was wrong, not the code
amazon-science/adaptive-layerwise-perturbation/multi-turn/eval/qwen_evaluation/model_utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from fanqiwan/FuseAI, is pointer only (licence: NONE) · get_code("1525d8bc0fc8d5a0")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from fanqiwan/FuseAI, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

has_error_in_observation Ran
ran, violated the contract we drafted
amazon-science/adaptive-layerwise-perturbation/multi-turn/sft/custom_masking.py
code served (permissive licence) · get_code("2948a4668af3cbc4")
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

# The function takes a single parameter: obs (a string)
# It checks if the observation string contains error keywords or is empty/null-like

ARGS = {
    "obs": "This is a normal observation with no errors"
}
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
parallel_sandbox Ran
ran on a synthesized input
amazon-science/adaptive-layerwise-perturbation/multi-turn/sandbox/local_sandbox.py
code served (permissive licence) · get_code("15fce704ed90381f")
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 coroutine. 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 asyncio
import os

# Set the sandbox endpoint environment variable
os.environ['SANDBOX_ENDPOINT'] = 'http://localhost:8000/api/execute'

# Create test code snippets
tasks = [
    'print("Hello")',
    'x = 1 + 1\nprint(x)',
    'import sys\nprint(sys.version)',
]

# Create stdin inputs for each task
stdin_list = [
    '',
    '',
    '',
]

# Set number of concurrent processes
num_processes = 5

ARGS = {
    'tasks': tasks,
    'stdin_list': stdin_list,
    'num_processes': num_processes,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
aiohttp — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine 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
single_sandbox Ran
ran on a synthesized input
amazon-science/adaptive-layerwise-perturbation/multi-turn/sandbox/local_sandbox.py
code served (permissive licence) · get_code("920a3efbf7dbb3b1")
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 coroutine. 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 asyncio
import logging

# Setup logging
logging.basicConfig(level=logging.WARNING)

# Define ARGS dictionary with all parameters for single_sandbox
ARGS = {
    'code': '''
def hello():
    print("Hello from sandbox")
    return 42

result = hello()
print(f"Result: {result}")
''',
    'stdin': 'test input\n',
    'endpoint': 'http://localhost:8000/run',
    'language': 'python',
    'compile_timeout': 1.0,
    'run_timeout': 3.0,
    'semaphore': asyncio.Semaphore(1),
    'max_attempts': 2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
aiohttp — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine 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
unpad_dataproto Ran
ran; our contract draft was wrong, not the code
amazon-science/adaptive-layerwise-perturbation/multi-turn/verl/protocol.py
code served (permissive licence) · get_code("25f0ea3f460f6ce1")
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) and returned DataProto. 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)

class DataProto:
    """Stand-in class for DataProto that supports slicing."""
    def __init__(self, data):
        self.data = data
    
    def __getitem__(self, key):
        """Support slicing to return a new DataProto with sliced data."""
        sliced_data = self.data[key]
        return DataProto(sliced_data)
    
    def __repr__(self):
        return f"DataProto({self.data})"

# Create a small DataProto instance with some data
data_tensor = torch.randn(2, 4)
data_proto = DataProto(data_tensor)

ARGS = {
    "data": data_proto,
    "pad_size": 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataProto — a DataProto output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataProto 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
load_hf_lm_and_tokenizer Not yet run
unverified (harvested, no recorded run)
amazon-science/adaptive-layerwise-perturbation/multi-turn/eval/qwen_evaluation/model_utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from YangLing0818/SuperCorrect-llm, is pointer only (licence: NONE) · get_code("ee71a94d9dd1b8e9")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from YangLing0818/SuperCorrect-llm, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 1 the same month, 3 later) and 7 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
unpad_dataproto 89 other papers
50 dated earlier, 6 the same month, 30 later, 3 undated
2409.19256 (2024-09)
HybridFlow: A Flexible and Efficient RLHF Framework
2410.21236 (2024-10)
Flaming-hot Initiation with Regular Execution Sampling for Large Language Models
2025.findings-emnlp.1015 (2025 (year only))
MT-R1-Zero: Advancing LLM-based Machine Translation via R1-Zero-like Reinforcement Learning
and 86 more not named here
load_hf_lm_and_tokenizer 18 other papers
14 dated earlier, 4 later
2405.14365 (2024-05)
JiuZhang3.0: Efficiently Improving Mathematical Reasoning by Training Small Data Synthesis Models
2408.07471 (2024-08)
Bridging and Modeling Correlations in Pairwise Data for Direct Preference Optimization
2410.07985 (2024-10)
Omni-MATH: A Universal Olympiad Level Mathematic Benchmark For Large Language Models
and 15 more not named here
generate_completions 17 other papers
13 dated earlier, 4 later
2405.14365 (2024-05)
JiuZhang3.0: Efficiently Improving Mathematical Reasoning by Training Small Data Synthesis Models
2408.07471 (2024-08)
Bridging and Modeling Correlations in Pairwise Data for Direct Preference Optimization
2410.07985 (2024-10)
Omni-MATH: A Universal Olympiad Level Mathematic Benchmark For Large Language Models
and 14 more not named here

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

Off-policy problems such as policy staleness and training-inference mismatch have become a major bottleneck for training stability and further exploration in LLM RL. The distribution gap between the inference and updated policies grows because of the techniques to enhance inference efficiency, leading to heavy-tailed importance ratios. Heavy-tailed ratios arise when the policy is locally sharp, which further inflates gradients and can push updates outside the trust region. To address this, we propose Adaptive Layerwise Perturbation (ALP), which injects small learnable perturbations into the input hidden states of each layer during updates and uses the resulting perturbed policy as the numerator of the importance ratio against the unchanged inference policy in the objective. Intuitively, by adding controlled noise to intermediate representations, ALP prevents the updated policy from deviating too sharply from the inference policy and enlarges the policy family to cover inference-time mismatch noise. Hence, the flattened distribution can naturally tighten the gap between the updated and inference policies and reduce the tail of importance ratios, thus maintaining training stability. This is further validated empirically. Experiments on single-turn math and multi-turn tool-integrated reasoning tasks show that ALP not only improves final performance, but also avoids blow-up in the importance-ratio tail and KL spikes during iterative training, along with boosted exploration. Ablations show that representation-level perturbations across all layers are most effective, substantially outperforming partial-layer and logits-only variants. Codes and training recipes are available at https://github.com/amazon-science/adaptive-layerwise-perturbation.

For agents

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

get_harvested_code_for_paper("2603.19470")
get_code_for_paper("2603.19470")
have("2603.19470")

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

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

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

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

Connect an agent — have() is free.