SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.22389 · NeurIPS · 2025

Train with Perturbation, Infer after Merging: A Two-Stage Framework for Continual Learning

Miao Zhang, Liqiang Nie, Ziyue Qiao, Haomiao Qiu

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 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, 1 violated it and 1 has no contract verdict; 5 failures of our instrument; 2 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/2505.22389.json · badge: /api/ran/2505.22389.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
qhmiao/P-M-for-Continual-Learning canonical (classifier label)
classifier basis not recorded on the link
7 ran · 2 no recorded run
FunctionStatusWhere it lives
calc_accuracy Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
qhmiao/P-M-for-Continual-Learning/utils/misc.py
code served (permissive licence) · get_code("971c46b0aa73eb28")
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)

# Case 1: preds is long dtype with 2D shape (batch_size, num_classes)
# target is long dtype with 1D shape (batch_size,)
# topk is a tuple of integers

batch_size = 2
num_classes = 4

preds = torch.tensor([
    [0, 1, 2, 3],
    [3, 2, 1, 0]
], dtype=torch.long)

target = torch.tensor([1, 3], dtype=torch.long)

topk = (1, 2)

ARGS = {
    "preds": preds,
    "target": target,
    "topk": topk
}
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
format_duration Ran
ran; our contract draft was wrong, not the code
qhmiao/P-M-for-Continual-Learning/utils/misc.py
code served (permissive licence) · get_code("d06fe57a613a4c54")
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
import numpy as np

# Analyze the function:
# format_duration takes a single parameter delta_time of type float
# It converts delta_time to seconds and formats as HH:MM:SS
# The function only performs arithmetic operations on delta_time

ARGS = {
    'delta_time': 3661.7  # 1 hour, 1 minute, 1 second with decimal
}
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 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
get_init_weights_vit Ran
ran; our contract draft was wrong, not the code
qhmiao/P-M-for-Continual-Learning/utils/vit_builder.py
code served (permissive licence) · get_code("398c127f958b7a62")
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 partial. 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 torch.nn as nn
from functools import partial

torch.manual_seed(0)

ARGS = {
    'mode': 'jax',
    'head_bias': 0.0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type partial — a partial output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a partial 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
get_lora_parameters Ran
ran on a synthesized input
qhmiao/P-M-for-Continual-Learning/lora/utils.py
code served (permissive licence) · get_code("5df638207a6149a9")
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. 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 torch.nn as nn

torch.manual_seed(0)

class LoRAModel(nn.Module):
    def __init__(self):
        super().__init__()
        # Linear layer with lora parameters
        self.linear1 = nn.Linear(4, 3)
        self.lora_A = nn.Parameter(torch.randn(4, 2))
        self.lora_B = nn.Parameter(torch.randn(2, 3))
        self.bias = nn.Parameter(torch.randn(3))
        
        # Another linear layer with lora
        self.linear2 = nn.Linear(3, 5)
        self.linear2_lora_A = nn.Parameter(torch.randn(3, 2))
        self.linear2_lora_B = nn.Parameter(torch.randn(2, 5))
        self.linear2_bias = nn.Parameter(torch.randn(5))

model = LoRAModel()

ARGS = {
    'model': model,
    'bias': 'none'
}
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 — a list 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
lora_state_dict Ran
ran; our contract draft was wrong, not the code
qhmiao/P-M-for-Continual-Learning/lora/utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from shihaohou/FedPuReL, is pointer only (licence: NONE) · get_code("660073ae6862ac6e")
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 shihaohou/FedPuReL, 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.

resize_pos_embed Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
qhmiao/P-M-for-Continual-Learning/utils/vit_builder.py
code served (permissive licence) · get_code("aba59faf86f45da9")
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 3, dtype family float, shape (1, 10, 8) 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 math

torch.manual_seed(0)

# Construct position embedding tensors
# Old posemb: shape (1, num_tokens, embed_dim)
# For a 4x4 grid + 1 prefix token: 17 tokens total, embed_dim=8
gs_old = 4
num_prefix_tokens = 1
num_tokens_old = gs_old * gs_old + num_prefix_tokens  # 17
embed_dim = 8
posemb = torch.randn(1, num_tokens_old, embed_dim)

# New posemb: shape (1, num_tokens_new, embed_dim)
# For a 3x3 grid + 1 prefix token: 10 tokens total
gs_new_val = 3
num_tokens_new = gs_new_val * gs_new_val + num_prefix_tokens  # 10
posemb_new = torch.randn(1, num_tokens_new, embed_dim)

ARGS = {
    'posemb': posemb,
    'posemb_new': posemb_new,
    'num_prefix_tokens': 1,
    'gs_new': (3, 3),
    'interpolation': 'bicubic',
    'antialias': 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 3, dtype family float, shape (1, 10, 8) — shape (1, 10, 8) 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
str2bool Ran
ran, violated the contract we drafted
qhmiao/P-M-for-Continual-Learning/utils/misc.py
code served (permissive licence) · get_code("29848dd47d2443ef")
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 argparse

def str2bool(s):
    if isinstance(s, bool):
        return s
    true_list = ('y', 'true', '1')
    false_list = ('n', 'false', '0')
    s = str(s).lower()
    if s in true_list:
        return True
    elif s in false_list:
        return False
    else:
        raise argparse.ArgumentTypeError(f"'{s}' should be in {true_list} or {false_list}")

# Test with different input types
ARGS = {
    "s": "true"
}
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 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
define_dataset Not yet run
unverified (harvested, no recorded run)
qhmiao/P-M-for-Continual-Learning/utils/dataset_builder.py
code served (permissive licence) · get_code("35a10325e8443f2e")
How it ran

no invocation recorded.

set_param Not yet run
unverified (harvested, no recorded run)
qhmiao/P-M-for-Continual-Learning/lora/layers.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from maxzanella/clip-lora, is pointer only (licence: AGPL-3.0) · get_code("e39f18623c2d033c")
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 maxzanella/clip-lora, and AGPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. 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 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 8 are also present in other papers whose code we hold (8 with at least one paper dated earlier, 0 the same month, 2 later) and 1 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
lora_state_dict 13 other papers
11 dated earlier, 2 later
2202.00535 (2022-02)
Novelty Controlled Paraphrase Generation with Retrieval Augmented Conditional Prompt Tuning
2202.07962 (2022-02)
Revisiting Parameter-Efficient Tuning: Are We Really There Yet?
2211.09790 (2022-11)
ConStruct-VL: Data-Free Continual Structured VL Concepts Learning
and 10 more not named here
set_param 7 other papers
3 dated earlier, 4 later · 2 only as an assembly brick
2401.09257 (2024-01)
A First-Order Multi-Gradient Algorithm for Multi-Objective Bi-Level Optimization
2405.18541 (2024-05)
Low-Rank Few-Shot Adaptation of Vision-Language Models
2501.10945 (2025-01)
Gradient-Based Multi-Objective Deep Learning: Algorithms, Theories, Applications, and Beyond
and 4 more not named here
get_init_weights_vit 2 other papers
2 dated earlier
2406.05658 (2024-06)
Visual Prompt Tuning in Null Space for Continual Learning
2406.18051 (2024-06)
ViT-1.58b: Mobile Vision Transformers in the 1-bit Era
calc_accuracy 1 other paper
1 dated earlier
2406.05658 (2024-06)
Visual Prompt Tuning in Null Space for Continual Learning
define_dataset 1 other paper
1 dated earlier
2406.05658 (2024-06)
Visual Prompt Tuning in Null Space for Continual Learning
format_duration 1 other paper
1 dated earlier
2406.05658 (2024-06)
Visual Prompt Tuning in Null Space for Continual Learning
resize_pos_embed 1 other paper
1 dated earlier
2406.05658 (2024-06)
Visual Prompt Tuning in Null Space for Continual Learning
str2bool 1 other paper
1 dated earlier
2406.05658 (2024-06)
Visual Prompt Tuning in Null Space for Continual Learning

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

Continual Learning (CL) aims to enable models to continuously acquire new knowledge from a sequence of tasks with avoiding the forgetting of learned information. However, existing CL methods only rely on the parameters of the most recent task for inference, which makes them susceptible to catastrophic forgetting. Inspired by the recent success of model merging techniques, we propose Perturband-Merge (P&M), a novel continual learning framework that integrates model merging into the CL paradigm to mitigate forgetting. Specifically, after training on each task, P&M constructs a new model by forming a convex combination of the previous model and the newly trained task-specific model. Through theoretical analysis, We minimize the total loss increase across all tasks and derive a closed-form solution for the merging coefficient under mild assumptions. To further improve the performance of the merged model, we observe that the degradation introduced during merging can be alleviated by a regularization term composed of the task vector and the Hessian matrix of the loss function. Interestingly, we show that this term can be efficiently approximated using second-order symmetric finite differences, and a stochastic perturbation strategy along the task vector direction is accordingly devised which incurs no additional forward or backward passes while providing an effective approximation of the regularization term. Finally, we combine P&M with LoRA, a parameter-efficient fine-tuning method, to reduce memory overhead. Our proposed approach achieves state-of-the-art performance on several continual learning benchmark datasets. The code is available at https://github.com/qhmiao/P-M-for-Continual-Learning.

For agents

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

get_harvested_code_for_paper("2505.22389")
get_code_for_paper("2505.22389")
have("2505.22389")

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

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

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

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

Connect an agent — have() is free.