SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2501.08330 · 2025

Gradient Equilibrium in Online Learning: Theory and Applications

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; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-22; 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/2501.08330.json · badge: /api/ran/2501.08330.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
aangelopoulos/gradient-equilibrium canonical (classifier label)
classifier basis not recorded on the link
7 ran · 1 no recorded run
FunctionStatusWhere it lives
assign_readmission_label Ran
ran on a synthesized input
aangelopoulos/gradient-equilibrium/mimic_stay/mimic_utils.py
code served (permissive licence) · get_code("7e0484dc9295e4e9")
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.

from datetime import datetime, timedelta

class Row:
    def __init__(self, subject_id, admittime, next_row_subject_id, next_row_admittime):
        self.subject_id = subject_id
        self.admittime = admittime
        self.next_row_subject_id = next_row_subject_id
        self.next_row_admittime = next_row_admittime

# Case 1: Different subject IDs - should return label 0
row_diff_subject = Row(
    subject_id=1,
    admittime=datetime(2020, 1, 1, 10, 0, 0),
    next_row_subject_id=2,
    next_row_admittime=datetime(2020, 1, 5, 10, 0, 0)
)

# Case 2: Same subject, but > 15 days apart - should return label 0
row_long_gap = Row(
    subject_id=1,
    admittime=datetime(2020, 1, 1, 10, 0, 0),
    next_row_subject_id=1,
    next_row_admittime=datetime(2020, 1, 20, 10, 0, 0)
)

# Case 3: Same subject, <= 15 days apart - should return label 1
row_readmission = Row(
    subject_id=1,
    admittime=datetime(2020, 1, 1, 10, 0, 0),
    next_row_subject_id=1,
    next_row_admittime=datetime(2020, 1, 10, 10, 0, 0)
)

ARGS = {"row": row_readmission}
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
diag_icd9_to_3digit Ran
ran on a synthesized input
aangelopoulos/gradient-equilibrium/mimic_stay/mimic_utils.py
code served (permissive licence) · get_code("3bc1a8bfab185688")
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.

import torch

# The function diag_icd9_to_3digit takes a single parameter: icd9
# It expects a string representing an ICD-9 diagnosis code
# The function checks if it starts with 'E', and truncates based on length

# We'll provide a valid ICD-9 code string
icd9_code = "41401"  # A standard ICD-9 code (5 digits)

ARGS = {
    "icd9": icd9_code
}
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 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
evaluate Ran
ran on a synthesized input
aangelopoulos/gradient-equilibrium/helpsteer/train_and_generate_rewards.py
code served (permissive licence) · get_code("1e41761889fc4d29")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 torch.nn as nn
from torch.nn import functional as F
import numpy as np

torch.manual_seed(0)

# Small reward model that outputs a scalar prediction
class TinyRewardModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(8, 1)
    
    def forward(self, input_ids, attention_mask):
        # Simple mock: average pooling over sequence, then linear layer
        batch_size = input_ids.shape[0]
        hidden = torch.randn(batch_size, 8)
        output = self.linear(hidden)
        return (output,)  # Return tuple as expected

# Tiny tokenizer stand-in with required methods
class TinyTokenizer:
    def apply_chat_template(self, messages, tokenize=False):
        # Return a simple string representation
        return f"[CHAT: {len(messages)} messages]"
    
    def __call__(self, texts, padding=True, truncation=True, max_length=1024, return_tensors='pt'):
        # Return mock tokenized output
        batch_size = len(texts)
        seq_len = 5
        result = {
            'input_ids': torch.randint(0, 1000, (batch_size, seq_len)),
            'attention_mask': torch.ones(batch_size, seq_len, dtype=torch.long)
        }
        return result

# Mock config
mock_config = {
    'model_name': 'test-model',
    'max_length': 1024,
    'batch_size': 2,
    'learning_rate': 2e-05,
    'num_epochs': 1,
    'warmup_steps': 0,
    'device': 'cpu',
    'gradient_accumulation_steps': 4
}

# Create mock eval loader (list of batches)
def create_mock_batch():
    return {
        'prompt': ['What is 2+2?', 'Tell me a joke'],
        'response': ['The answer is 4', 'Why did the chicken cross the road?'],
        'helpfulness': torch.tensor([0.8, 0.6])
    }

mock_eval_loader = [create_mock_batch(), create_mock_batch()]

# Build all required arguments
model = TinyRewardModel()
tokenizer = TinyTokenizer()
config = mock_config

ARGS = {
    'model': model,
    'eval_loader': mock_eval_loader,
    'tokenizer': tokenizer,
    'config': config
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, tqdm — 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_anchor_year Ran
ran on a synthesized input
aangelopoulos/gradient-equilibrium/mimic_stay/mimic_utils.py
code served (permissive licence) · get_code("e7af70d6225c3f3b")
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

torch.manual_seed(0)

ARGS = {
    "anchor_year_group": "2020-2022"
}
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 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
get_field_at_point Ran
ran on a synthesized input
aangelopoulos/gradient-equilibrium/synthetic/expanding-trajectory.py
code served (permissive licence) · get_code("2e05ca68682f0f01")
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 numpy as np

x_val = 2.5
y_val = 1.5

ARGS = {
    "x": x_val,
    "y": y_val
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
get_field_at_point Ran
ran on a synthesized input
aangelopoulos/gradient-equilibrium/synthetic/positive-curvature.py
code served (permissive licence) · get_code("5f0edb65195ad055")
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 numpy as np

x_val = 2.5
y_val = 1.5

ARGS = {
    "x": x_val,
    "y": y_val
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
prepare_input Ran
ran on a synthesized input
aangelopoulos/gradient-equilibrium/helpsteer/train_and_generate_rewards.py
code served (permissive licence) · get_code("58e8f37cc4e7e6c8")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 AutoTokenizer

torch.manual_seed(0)

# Create a minimal tokenizer stand-in that has the required methods
class MinimalTokenizer:
    def __init__(self):
        self.pad_token_id = 0
        self.eos_token_id = 2
    
    def apply_chat_template(self, messages, tokenize=False):
        # Simple mock: concatenate role and content
        result = ""
        for msg in messages:
            result += f"{msg['role']}: {msg['content']} "
        return result.strip()
    
    def __call__(self, texts, padding=True, truncation=True, max_length=None, return_tensors=None):
        # Mock tokenizer: convert text to token ids
        tokens_list = []
        max_len = 0
        
        for text in texts:
            # Simple mock tokenization: split and hash to get ids
            token_ids = [hash(word) % 100 for word in text.split()][:max_length] if max_length else [hash(word) % 100 for word in text.split()]
            tokens_list.append(token_ids)
            max_len = max(max_len, len(token_ids))
        
        # Pad to max length
        if padding:
            tokens_list = [ids + [self.pad_token_id] * (max_len - len(ids)) for ids in tokens_list]
        
        # Convert to tensor if requested
        if return_tensors == 'pt':
            input_ids = torch.tensor(tokens_list, dtype=torch.long)
            attention_mask = torch.tensor(
                [[1 if token_id != self.pad_token_id else 0 for token_id in ids] for ids in tokens_list],
                dtype=torch.long
            )
            return {
                'input_ids': input_ids,
                'attention_mask': attention_mask
            }
        
        return {'input_ids': tokens_list}

# Create batch data
batch = {
    'prompt': ['What is AI?', 'Explain ML'],
    'response': ['AI is artificial intelligence', 'ML is machine learning']
}

# Create tokenizer
tokenizer = MinimalTokenizer()

# Create config
config = {
    'model_name': 'Ray2333/GRM-gemma2-2B-rewardmodel-ft',
    'max_length': 1024,
    'batch_size': 2,
    'learning_rate': 2e-05,
    'num_epochs': 1,
    'warmup_steps': 0,
    'device': 'cpu',
    'gradient_accumulation_steps': 4
}

# Define ARGS dictionary
ARGS = {
    'batch': batch,
    'tokenizer': tokenizer,
    'config': config
}
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
train_epoch Not yet run
unverified (harvested, no recorded run)
aangelopoulos/gradient-equilibrium/helpsteer/train_and_generate_rewards.py
code served (permissive licence) · get_code("ac0c5764c5f589e0")
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, 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 8 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-22.

Repositories linked to this paper

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

Abstract

We present a new perspective on online learning that we refer to as gradient equilibrium: a sequence of iterates achieves gradient equilibrium if the average of gradients of losses along the sequence converges to zero. In general, this condition is not implied by, nor implies, sublinear regret. It turns out that gradient equilibrium is achievable by standard online learning methods such as gradient descent and mirror descent with constant step sizes (rather than decaying step sizes, as is usually required for no regret). Further, as we show through examples, gradient equilibrium translates into an interpretable and meaningful property in online prediction problems spanning regression, classification, quantile estimation, and others. Notably, we show that the gradient equilibrium framework can be used to develop a debiasing scheme for black-box predictions under arbitrary distribution shift, based on simple post hoc online descent updates. We also show that post hoc gradient updates can be used to calibrate predicted quantiles under distribution shift, and that the framework leads to unbiased Elo scores for pairwise preference prediction.

For agents

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

get_harvested_code_for_paper("2501.08330")
get_code_for_paper("2501.08330")
have("2501.08330")

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

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

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

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

Connect an agent — have() is free.