SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2602.22538 · 2026

RAIN-Merging: A Gradient-Free Method to Enhance Instruction Following in Large Reasoning Models with Preserved Thinking Format

Xiaolin Huang, Tao Li, Zhehao Huang, Yuhang Liu, Zhengbao He, Baijiong Lin, Hanling Tian, Yixin Lou

arXiv · PDF · Open in the Atlas

Code that ran

14 of 26 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, 0 violated it and 0 have no contract verdict; 13 failures of our instrument; 12 no recorded run), measured 2026-11-22; 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/2602.22538.json · badge: /api/ran/2602.22538.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
K1nght/RAIN-Merging community
Papers with Code archive
14 ran · 12 no recorded run
FunctionStatusWhere it lives
AT_times_y_o Ran
ran; our contract draft was wrong, not the code
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("00c9c6977a701ff1")
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 2, dtype family float, shape (4, 5) 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)

# Build cons_h dictionary with required tensors
c_vec = torch.randn(3, 4)  # m=3 rows, d_model=4 columns
sc_o = torch.randn(3, 1)   # scaling factors for m=3
z_h = torch.randn(3, 5)    # m=3 rows, hD=5 columns

cons_h = {
    'c_vec': c_vec,
    'sc_o': sc_o,
    'z_h': z_h,
}

# Build y tensor: needs at least m elements (m=3)
y = torch.randn(3)

# Define dimensions
d_model = 4
hD = 5
device = 'cpu'
compute_dtype = torch.float32

ARGS = {
    'y': y,
    'cons_h': cons_h,
    'd_model': d_model,
    'hD': hD,
    'device': device,
    'compute_dtype': compute_dtype,
}
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 2, dtype family float, shape (4, 5) — shape (4, 5) 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
AT_times_y_qk_batched Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("f155dbbce57758d3")
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 3, 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)

# Function parameters
d_model = 4
hD = 3
batch_size = 2

# Construct cons_h dictionary with required tensors
m_q = 2
m_k = 2
total_constraints = m_q + m_k

# Xi_q: (m_q, d_model) - constraint matrix for Q
Xi_q = torch.randn(m_q, d_model)

# sc_q: (m_q, 1) - scale factors for Q constraints
sc_q = torch.randn(m_q, 1)

# kj: (m_q, hD) - key vectors
kj = torch.randn(m_q, hD)

# Xj_k: (m_k, d_model) - constraint matrix for K
Xj_k = torch.randn(m_k, d_model)

# sc_k: (m_k, 1) - scale factors for K constraints
sc_k = torch.randn(m_k, 1)

# qi: (m_k, hD) - query vectors
qi = torch.randn(m_k, hD)

cons_h = {
    'Xi_q': Xi_q,
    'sc_q': sc_q,
    'kj': kj,
    'Xj_k': Xj_k,
    'sc_k': sc_k,
    'qi': qi,
}

# y: gradient vector with total_constraints elements
y = torch.randn(total_constraints)

# shapes tuple
shapes = (d_model, hD)

# device and dtype
device = 'cpu'
compute_dtype = torch.float32

ARGS = {
    'y': y,
    'cons_h': cons_h,
    'shapes': shapes,
    'device': device,
    'compute_dtype': compute_dtype,
}
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 3, 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
cg_ffn_down Ran
ran; our contract draft was wrong, not the code
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("d5691f582cfd141a")
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. 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)

# Build the cons dictionary with required tensors
# The function uses: cons['H'], cons['sc'], cons['c']
# H is used in matrix operations: H.T @ (w * C) and H @ delta_dDown_T
# sc is squeezed and used for scaling
# c is used for element-wise multiplication

d_ff = 4
d_model = 3
batch_size = 2

cons = {
    'H': torch.randn(batch_size, d_ff),  # shape (2, 4)
    'sc': torch.randn(batch_size, 1),     # shape (2, 1) to be squeezed
    'c': torch.randn(batch_size, d_model) # shape (2, 3)
}

# task_dDown_T is used as input to AT_times_y_ffn_down
# It represents a weight matrix gradient: (d_ff, d_model)
task_dDown_T = torch.randn(d_ff, d_model)

# Other parameters with reasonable defaults
lam = 0.0001
maxit = 100
tol = 1e-05
device = 'cpu'
compute_dtype = torch.float32

ARGS = {
    'cons': cons,
    'task_dDown_T': task_dDown_T,
    'lam': lam,
    'maxit': maxit,
    'tol': tol,
    'device': device,
    'compute_dtype': compute_dtype
}
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 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
cg_o Ran
ran; our contract draft was wrong, not the code
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("42f44084ce891789")
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. 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)

# Build cons_h dictionary with required tensors
# The function uses: cons_h['c_vec'], cons_h['sc_o'], cons_h['z_h']
cons_h = {
    'c_vec': torch.randn(3, 4),  # m=3 rows, d_model=4 cols
    'sc_o': torch.randn(3, 1),   # scaling vector for m=3
    'z_h': torch.randn(3, 5),    # m=3 rows, hD=5 cols
}

# Build task_dO tensor
# d_model=4, hD=5 based on cons_h shapes
d_model = 4
hD = 5
task_dO = torch.randn(d_model, hD)

# Define ARGS dictionary with all parameters
ARGS = {
    'cons_h': cons_h,
    'task_dO': task_dO,
    'lam': 0.0001,
    'maxit': 100,
    'tol': 1e-05,
    'device': 'cpu',
    'compute_dtype': torch.float32,
}
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 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
cg_single_head_batched Ran
ran; our contract draft was wrong, not the code
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("c5accd50884f21fc")
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. 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)

# Build small tensors and constraint dict for batched CG solver

d_model = 4
hD = 3

# Create task gradients for Q and K
task_dQ = torch.randn(d_model, hD, dtype=torch.float32)
task_dK = torch.randn(d_model, hD, dtype=torch.float32)

# Build cons_h dictionary with constraint matrices
# Xi_q: constraint matrix for Q (m_q x d_model)
# kj: corresponding K values (m_q x hD)
# sc_q: scaling factors (m_q x 1)
m_q = 2
Xi_q = torch.randn(m_q, d_model, dtype=torch.float32)
kj = torch.randn(m_q, hD, dtype=torch.float32)
sc_q = torch.randn(m_q, 1, dtype=torch.float32)

# Xj_k: constraint matrix for K (m_k x d_model)
# qi: corresponding Q values (m_k x hD)
# sc_k: scaling factors (m_k x 1)
m_k = 2
Xj_k = torch.randn(m_k, d_model, dtype=torch.float32)
qi = torch.randn(m_k, hD, dtype=torch.float32)
sc_k = torch.randn(m_k, 1, dtype=torch.float32)

cons_h = {
    'Xi_q': Xi_q,
    'kj': kj,
    'sc_q': sc_q,
    'Xj_k': Xj_k,
    'qi': qi,
    'sc_k': sc_k,
}

ARGS = {
    'cons_h': cons_h,
    'task_dQ': task_dQ,
    'task_dK': task_dK,
    'lambda_ridge': 0.0001,
    'maxit': 100,
    'tol': 1e-05,
    'device': 'cpu',
    'compute_dtype': torch.float32,
}
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 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
cg_v Ran
ran; our contract draft was wrong, not the code
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("7ac48ccbf2c80177")
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. 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)

# Build cons_h dict with required constraint tensors
# The function expects Xi_v, sc_v, and rv tensors
d_model = 4
hD = 3
m = 2  # number of constraints

cons_h = {
    'Xi_v': torch.randn(m, d_model),
    'sc_v': torch.randn(m, 1),
    'rv': torch.randn(m, hD),
}

# Build task_dV - a gradient update tensor
task_dV = torch.randn(d_model, hD)

# Define ARGS dict with all parameters for cg_v
ARGS = {
    'cons_h': cons_h,
    'task_dV': task_dV,
    'lam': 0.0001,
    'maxit': 100,
    'tol': 1e-05,
    'device': 'cpu',
    'compute_dtype': torch.float32,
}
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 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
ffn_down_dense_project Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("14e5c6e4549a8303")
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. 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)

# Build the 'cons' dict with required keys: 'H', 'c', 'sc'
# H should be shape (m, d) where m is number of constraints, d is some dimension
# c should be shape (m, d) for element-wise operations
# sc should be shape (m, 1) or broadcastable to (m,)

m = 3  # number of constraints
d = 4  # feature dimension

H = torch.randn(m, d, dtype=torch.float32)  # (3, 4)
C = torch.randn(m, d, dtype=torch.float32)  # (3, 4)
sc = torch.randn(m, 1, dtype=torch.float32)  # (3, 1)

cons = {
    'H': H,
    'c': C,
    'sc': sc
}

# task_dDown_T should be a tensor that gets processed
# Looking at the code: Δ = task_dDown_T.to(device, compute_dtype)
# and later: dT_proj = Δ - dT_w where dT_w has shape (d, d)
# So task_dDown_T should be shape (d, d) to match dimensions
task_dDown_T = torch.randn(d, d, dtype=torch.float32)

ARGS = {
    'cons': cons,
    'task_dDown_T': task_dDown_T,
    'lam': 0.0001,
    'device': 'cpu',
    'compute_dtype': torch.float32
}
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 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
k_dense_project Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("9d56cb9c14aa40c3")
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 tuple. 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)

# Construct the constraint dictionary
m = 2  # number of constraints
d_model = 4  # model dimension
hD = 3  # hidden dimension

cons_h = {
    'Xj_k': torch.randn(m, d_model),  # [m, d_model]
    'qi': torch.randn(m, hD),  # [m, hD]
    'sc_k': torch.randn(m, 1),  # [m, 1] - will be squeezed to [m]
}

# task_dK is the delta K matrix
task_dK = torch.randn(d_model, hD)

ARGS = {
    'cons_h': cons_h,
    'task_dK': task_dK,
    'lam': 0.0001,
    'device': 'cpu',
    'compute_dtype': torch.float32,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — 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
locate_segments Ran
ran, honoured the contract we drafted
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("0dbdd515cbf42f3e")
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 re
from typing import List, Dict, Tuple, Any, Optional
import torch

class MockTokenizer:
    """Minimal tokenizer that returns offset_mapping"""
    def __call__(self, text, return_offsets_mapping=False, add_special_tokens=False):
        # Simple tokenization: split by spaces and punctuation
        tokens = re.findall(r'\S+', text)
        
        # Build offset mapping
        offset_mapping = []
        pos = 0
        for token in tokens:
            start = text.find(token, pos)
            end = start + len(token)
            offset_mapping.append((start, end))
            pos = end
        
        return {
            'offset_mapping': offset_mapping
        }

# Create test text with thinking boundaries
text = "This is <think>some thinking content</think> and regular text"

# Create tokenizer instance
tokenizer = MockTokenizer()

ARGS = {
    'text': text,
    'tokenizer': tokenizer,
}
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 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
o_dense_project Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("e21d060263e1cf25")
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 tuple. 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)

# Build cons_h dict with required keys
m = 2  # number of constraints
d_model = 4
hD = 3  # hidden dimension

c_vec = torch.randn(m, d_model)
z_h = torch.randn(m, hD)
sc_o = torch.randn(m, 1)

cons_h = {
    'c_vec': c_vec,
    'z_h': z_h,
    'sc_o': sc_o
}

# Build task_dO: [d_model, hD]
task_dO = torch.randn(d_model, hD)

# Define ARGS
ARGS = {
    'cons_h': cons_h,
    'task_dO': task_dO,
    'lam': 0.0001,
    'device': 'cpu',
    'compute_dtype': torch.float32
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — 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
prepare_samples_unified Ran
ran; our contract draft was wrong, not the code
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("5a360716a871f952")
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 random
from typing import List

torch.manual_seed(0)

class MockTokenizer:
    """Minimal tokenizer that supports the required interface"""
    def __call__(self, text, return_tensors=None, add_special_tokens=False, return_offsets_mapping=False):
        # Simple mock: split by spaces and assign character offsets
        tokens = text.split()
        token_ids = [hash(t) % 1000 for t in tokens]
        
        if return_offsets_mapping:
            # Build character offsets for each token
            offsets = []
            pos = 0
            for token in tokens:
                start = text.find(token, pos)
                end = start + len(token)
                offsets.append((start, end))
                pos = end
            result = {
                'input_ids': token_ids,
                'offset_mapping': offsets
            }
        else:
            result = {'input_ids': token_ids}
        
        if return_tensors == 'pt':
            result['input_ids'] = torch.tensor([result['input_ids']], dtype=torch.long)
        
        return result


# Create sample texts with thinking boundaries
texts = [
    "This is before <think> some thinking content </think> after thinking",
    "Another text <think> internal thoughts </think> conclusion",
]

# Create tokenizer
tokenizer = MockTokenizer()

# Create RNG
rng = random.Random(42)

# Construct ARGS dictionary
ARGS = {
    'texts': texts,
    'tokenizer': tokenizer,
    'radius': 3,
    'merge_types': 'qkvof',
    'q_rows_per_text': 2,
    'k_rows_per_text': 2,
    'v_rows_per_text': 2,
    'o_rows_per_text': 2,
    'ffn_rows_per_text': 2,
    'rng': rng,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — 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
q_dense_project Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("2170244af18f0455")
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 tuple. 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)

# Build cons_h dictionary with required keys
m = 2  # number of constraints
d_model = 4  # model dimension
hD = 3  # hidden dimension

Xi_q = torch.randn(m, d_model)
kj = torch.randn(m, hD)
sc_q = torch.randn(m, 1)

cons_h = {
    'Xi_q': Xi_q,
    'kj': kj,
    'sc_q': sc_q
}

# Build task_dQ tensor
task_dQ = torch.randn(d_model, hD)

# Define ARGS
ARGS = {
    'cons_h': cons_h,
    'task_dQ': task_dQ,
    'lam': 0.0001,
    'device': 'cpu',
    'compute_dtype': torch.float32
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — 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
task_vectors_single_layer_unified Ran
ran; our contract draft was wrong, not the code
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("850f45dfa3a08cf8")
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 torch.nn as nn

torch.manual_seed(0)

# Create a minimal config class
class MinimalConfig:
    def __init__(self):
        self.hidden_size = 8
        self.num_attention_heads = 2
        self.num_key_value_heads = 2
        self.intermediate_size = 16

# Create minimal attention module
class MinimalAttention(nn.Module):
    def __init__(self, d_model, num_heads):
        super().__init__()
        self.q_proj = nn.Linear(d_model, d_model)
        self.k_proj = nn.Linear(d_model, d_model)
        self.v_proj = nn.Linear(d_model, d_model)
        self.o_proj = nn.Linear(d_model, d_model)

# Create minimal MLP module
class MinimalMLP(nn.Module):
    def __init__(self, d_model, intermediate_size):
        super().__init__()
        self.gate_proj = nn.Linear(d_model, intermediate_size)
        self.up_proj = nn.Linear(d_model, intermediate_size)
        self.down_proj = nn.Linear(intermediate_size, d_model)

# Create minimal layer
class MinimalLayer(nn.Module):
    def __init__(self, d_model, num_heads, intermediate_size):
        super().__init__()
        self.self_attn = MinimalAttention(d_model, num_heads)
        self.mlp = MinimalMLP(d_model, intermediate_size)

# Create minimal model
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.config = MinimalConfig()
        self.model = nn.Module()
        self.model.layers = nn.ModuleList([
            MinimalLayer(self.config.hidden_size, self.config.num_attention_heads, self.config.intermediate_size)
        ])

# Instantiate base and instruction models
model_base = MinimalModel()
model_instruct = MinimalModel()

# Initialize instruct model weights differently from base to create task vectors
for param in model_instruct.parameters():
    param.data.add_(torch.randn_like(param.data) * 0.1)

# Define arguments
ARGS = {
    'model_base': model_base,
    'model_instruct': model_instruct,
    'layer': 0,
    'selected_heads': [0, 1],
    'merge_types': 'qkvof',
    'scaling_factor': 1.0
}
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
v_dense_project Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("d47c35c41d796139")
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 tuple. 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)

# Set up dimensions
m = 2  # number of constraints
d_model = 4  # model dimension
hD = 3  # hidden dimension for RV

# Construct cons_h dictionary with required tensors
cons_h = {
    'Xi_v': torch.randn(m, d_model, dtype=torch.float32),  # [m, d_model]
    'rv': torch.randn(m, hD, dtype=torch.float32),  # [m, hD]
    'sc_v': torch.randn(m, 1, dtype=torch.float32),  # [m, 1] - will be squeezed to [m]
}

# Construct task_dV: [d_model, hD]
task_dV = torch.randn(d_model, hD, dtype=torch.float32)

# Define ARGS
ARGS = {
    'cons_h': cons_h,
    'task_dV': task_dV,
    'lam': 0.0001,
    'device': 'cpu',
    'compute_dtype': torch.float32,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — 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
AT_times_y_ffn_down Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("386325217560019b")
How it ran

no invocation recorded.

AT_times_y_v Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("132be6fed0784839")
How it ran

no invocation recorded.

A_times_delta_ffn_down Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("b59409e59cc75ff5")
How it ran

no invocation recorded.

A_times_delta_o Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("0bef599c3d266dd0")
How it ran

no invocation recorded.

A_times_delta_qk_batched Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("ec239cd5afa0e9ab")
How it ran

no invocation recorded.

A_times_delta_v Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("6a80e7e297cc2dfd")
How it ran

no invocation recorded.

PreparedSample Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("e68cff037c0b5994")
How it ran

no invocation recorded.

build_constraints_single_layer_unified Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("18483f343db694e9")
How it ran

no invocation recorded.

cleanup_memory Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("0e35eabd03de87a8")
How it ran

no invocation recorded.

collect_layer_features_with_hooks Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("cc07a611c75febcf")
How it ran

no invocation recorded.

optimized_layerwise_headwise_nullspace_projection Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("88609c4f9a469bab")
How it ran

no invocation recorded.

set_strict_runtime Not yet run
unverified (harvested, no recorded run)
K1nght/RAIN-Merging/nullspace_merge_qkvo_ffn.py
code served (permissive licence) · get_code("64c33317028b2a64")
How it ran

no invocation recorded.

Also present in other papers' code

Of 26 samples lifted from this paper's linked repositories, 26 carry a function identity and 0 do not. Of the 26 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 26 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

Large reasoning models (LRMs) excel at a long chain of reasoning but often fail to faithfully follow instructions regarding output format, constraints, or specific requirements. We investigate whether this gap can be closed by integrating an instruction-tuned model (ITM) into an LRM. Analyzing their differences in parameter space, namely task vectors, we find that their principal subspaces are nearly orthogonal across key modules, suggesting a lightweight merging with minimal interference. However, we also demonstrate that naïve merges are fragile because they overlook the output format mismatch between LRMs (with explicit thinking and response segments) and ITMs (answers-only). We introduce RAIN-Merging (Reasoning-Aware Instruction-attention guided Null-space projection Merging), a gradient-free method that integrates instruction following while preserving thinking format and reasoning performance. First, with a small reasoning calibration set, we project the ITM task vector onto the null space of forward features at thinking special tokens, which preserves the LRM's structured reasoning mechanisms. Second, using a small instruction calibration set, we estimate instruction attention to derive module-specific scaling that amplifies instruction-relevant components and suppresses leakage. Across four instruction-following benchmarks and nine reasoning & general capability benchmarks, RAIN-Merging substantially improves instruction adherence while maintaining reasoning quality. The gains are consistent across model scales and architectures, translating to improved performance in agentic scenarios. Code is available at https://github.com/K1nght/RAIN-Merging.

For agents

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

get_harvested_code_for_paper("2602.22538")
get_code_for_paper("2602.22538")
have("2602.22538")

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

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

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

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

Connect an agent — have() is free.