SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2605.20247 · 2026

CP-MoE: Consistency-Preserving Mixture-of-Experts for Continual Learning

Yang Liu, Flora Salim, Toan Nguyen

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 3 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/2605.20247.json · badge: /api/ran/2605.20247.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
YangLiu-Lewis/CP-MoE canonical (classifier label)
classifier basis: census
8 ran · 3 no recorded run
FunctionStatusWhere it lives
build_map Ran
ran; our contract draft was wrong, not the code
YangLiu-Lewis/CP-MoE/experts_shift.py
code served (permissive licence) · get_code("e28fd872f53c4165")
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 defaultdict. 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 import defaultdict

torch.manual_seed(0)

# Construct valid arguments for build_map
records = [
    {
        'layer': 'conv1',
        'topk_idx': [[0, 1], [2, 3], [4, 5]]
    },
    {
        'layer': 'conv2',
        'topk_idx': [[1, 2], [3, 4]]
    },
    {
        'layer': 'fc1',
        'topk_idx': [[0, 0], [1, 1]]
    },
    {
        'layer': None,
        'topk_idx': [[5, 6]]
    },
    {
        'layer': 'pool1',
        'topk_idx': 'not_a_list'
    },
    {
        'layer': 'norm1',
        'topk_idx': [[7], [8, 9, 10]]
    }
]

ARGS = {
    'records': records
}
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 defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict 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
calculate_sum_from_txt Ran
ran; our contract draft was wrong, not the code
YangLiu-Lewis/CP-MoE/statistic.py
code served (permissive licence) · get_code("d0c1cfb7876c27a8")
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 tempfile
import os

# Create a temporary file with test data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("1:10\n")
temp_file.write("2:20\n")
temp_file.write("1:5\n")
temp_file.write("3:15\n")
temp_file.write("2:8\n")
temp_file.close()

file_path = temp_file.name

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 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_span Ran
ran, honoured the contract we drafted
YangLiu-Lewis/CP-MoE/routing_count.py
code served (permissive licence) · get_code("eba69dd21da96ec2")
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 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 torch
import numpy as np

torch.manual_seed(0)

# The function find_span expects a list/sequence of tokens
# It iterates through tokens and checks if '<0x0A>' is in the string representation
# If found at index i, it returns (i+1, len(tokens))
# If not found, it raises ValueError

# Create a list of tokens where one contains '<0x0A>'
tokens = [
    'token_0',
    'token_1',
    '<0x0A>',  # This token contains '<0x0A>'
    'token_3',
    'token_4'
]

ARGS = {
    'tokens': tokens
}
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 tuple, ndim 1, dtype family int — 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_layer_id Ran
ran, honoured the contract we drafted
YangLiu-Lewis/CP-MoE/routing_count.py
code served (permissive licence) · get_code("b4c262eef66c401f")
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

def get_layer_id(name):
    m = re.search('layers\\.(\\d+)', name)
    return int(m.group(1)) if m else None

# Test cases to understand the function
# The function takes a string 'name' and extracts a layer ID from it
# It searches for the pattern 'layers.<digits>' and returns the digits as an int
# If the pattern is not found, it returns None

ARGS = {
    'name': 'model.layers.5.weight'
}
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
get_param_key Ran
ran; our contract draft was wrong, not the code
YangLiu-Lewis/CP-MoE/vis_masks_global.py
code served (permissive licence) · get_code("d62ab970b292ce5b")
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

torch.manual_seed(0)

ARGS = {
    'layer_name': 'conv1',
    'param_name': 'weight'
}
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
load_mask_file Ran
ran; our contract draft was wrong, not the code
YangLiu-Lewis/CP-MoE/vis_masks_global.py
code served (permissive licence) · get_code("e8a35054f7a59e21")
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 os
import tempfile

torch.manual_seed(0)

# Create a temporary directory and save a dummy mask file
temp_dir = tempfile.mkdtemp()
dummy_masks = {
    'mask_1': torch.randn(2, 4),
    'mask_2': torch.randn(3, 5)
}
torch.save(dummy_masks, os.path.join(temp_dir, 'clmoe_masks.pt'))

ARGS = {
    'path': temp_dir
}
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 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
preprocess_tokens Ran
ran; our contract draft was wrong, not the code
YangLiu-Lewis/CP-MoE/routing_count.py
code served (permissive licence) · get_code("b637df6b15fcd286")
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)

# Test case 1: raw_tokens as a string
test_string = "hello world this is a test"

# Test case 2: raw_tokens as a list
test_list = ["token1", "token2", "token3", "token4"]

# We'll use the string case as the primary test
ARGS = {
    "raw_tokens": test_string
}
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
read_indices Ran
ran, honoured the contract we drafted
YangLiu-Lewis/CP-MoE/params.py
code served (permissive licence) · get_code("2531e753c1826002")
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 tempfile
import os

# Create a temporary file with integer indices
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("0\n")
temp_file.write("1\n")
temp_file.write("42\n")
temp_file.write("100\n")
temp_file.close()

file_path = temp_file.name

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 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
get_peft_state_maybe_zero_3 Not yet run
unverified (harvested, no recorded run)
YangLiu-Lewis/CP-MoE/llava/train/train_MOE.py
code served (permissive licence) · get_code("fa1225dfac92bc0d")
How it ran

no invocation recorded.

get_peft_state_non_lora_maybe_zero_3 Not yet run
unverified (harvested, no recorded run)
YangLiu-Lewis/CP-MoE/llava/train/train_MOE.py
code served (permissive licence) · get_code("1c53657305b66e9f")
How it ran

no invocation recorded.

maybe_zero_3 Not yet run
unverified (harvested, no recorded run)
YangLiu-Lewis/CP-MoE/llava/train/train_MOE.py
code served (permissive licence) · get_code("616ffbdc154ed2d8")
How it ran

no invocation recorded.

Also present in other papers' code

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

FunctionAlso present inEarliest-datedOthers named
maybe_zero_3 37 other papers
35 dated earlier, 1 the same month, 1 later
2310.01779 (2023-10)
HallE-Control: Controlling Object Hallucination in Large Multimodal Models
2311.16839 (2023-11)
Beyond Hallucinations: Enhancing LVLMs through Hallucination-Aware Direct Preference Optimization
2312.02949 (2023-12)
LLaVA-Grounding: Grounded Visual Chat with Large Multimodal Models
and 34 more not named here
get_peft_state_maybe_zero_3 23 other papers
22 dated earlier, 1 the same month
2310.01779 (2023-10)
HallE-Control: Controlling Object Hallucination in Large Multimodal Models
2401.02330 (2024-01)
LLaVA-Phi: Efficient Multi-Modal Assistant with Small Language Model
2402.12501 (2024-02)
Your Vision-Language Model Itself Is a Strong Filter: Towards High-Quality Instruction Tuning with Data Selection
and 20 more not named here
get_peft_state_non_lora_maybe_zero_3 23 other papers
22 dated earlier, 1 the same month
2310.01779 (2023-10)
HallE-Control: Controlling Object Hallucination in Large Multimodal Models
2312.02949 (2023-12)
LLaVA-Grounding: Grounded Visual Chat with Large Multimodal Models
2401.02330 (2024-01)
LLaVA-Phi: Efficient Multi-Modal Assistant with Small Language Model
and 20 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

Catastrophic forgetting remains a major obstacle to continual learning in large language models (LLMs) and vision-language models (VLMs). Although Mixture-of-Experts (MoE) architectures offer an efficient path to scaling, existing LoRA-based MoE continual learning methods still face a fundamental trade-off: they either isolate experts too aggressively, limiting knowledge transfer across tasks, or allow task-specific updates to overwrite important existing parameters, leading to severe forgetting. To address this, we propose CP-MoE, a continual learning framework built around a transient expert that captures early task-specific updates and guides their integration into stable experts. CP-MoE introduces a consistency-preserving routing bias, which uses the transient expert to estimate representation similarity with stable experts and steer routing towards more compatible expert selection, and a transient expert-guided regularisation mechanism, which selectively protects important historical parameters during merging. Together, these components reduce parameter interference and forgetting while preserving cross-task knowledge transfer. We validate CP-MoE on both unimodal and multimodal continual learning benchmarks with LLM-based and VLM-based MoE models. On SuperNI benchmark, spanning diverse sequential language tasks, CP-MoE achieves state-of-the-art performance and stronger zero-shot transfer to unseen tasks. On VQA v2 dataset, it scales effectively to multimodal visual reasoning, consistently reduces forgetting, and outperforms strong MoE baselines. Our source code is available at https://github.com/YangLiu-Lewis/CP-MoE.

For agents

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

get_harvested_code_for_paper("2605.20247")
get_code_for_paper("2605.20247")
have("2605.20247")

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

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

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

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

Connect an agent — have() is free.