SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.17921 · ICLR · 2024

The Need for Speed: Pruning Transformers with One Recipe

Konstantinos Plataniotis, Samir Khaki

arXiv · PDF · Open in the Atlas

Code that ran

15 of 23 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; 8 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 6 failures of our instrument; 8 no recorded run), measured 2026-11-24; 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/2403.17921.json · badge: /api/ran/2403.17921.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
Skhaki18/optin-transformer-pruning canonical (classifier label)
classifier basis: classifier_2025
2 ran · 1 no recorded run
skhaki18/optin-transformer-pruning community
Papers with Code archive
13 ran · 7 no recorded run
FunctionStatusWhere it lives
KLDiv Ran
ran, honoured the contract we drafted
Skhaki18/optin-transformer-pruning/prune/loss_components.py
code served (permissive licence) · get_code("027ae849d003750b")
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 Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch.nn import functional as F

torch.manual_seed(0)

# Create a simple stand-in class that has a logits attribute
class ModelOutput:
    def __init__(self, logits):
        self.logits = logits

# Create teacher output with logits
teacher_logits = torch.randn(2, 4)
TeacherOutput = ModelOutput(teacher_logits)

# Create student output with logits
student_logits = torch.randn(2, 4)
StudentOutput = ModelOutput(student_logits)

# Define temperature parameter
temp = 4

ARGS = {
    "TeacherOutput": TeacherOutput,
    "StudentOutput": StudentOutput,
    "temp": temp
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, 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
KLDiv Ran
ran, honoured the contract we drafted
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("da78ffebac4be236")
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 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch.nn import functional as F

torch.manual_seed(0)

# Create a minimal class with logits attribute for TeacherOutput
class ModelOutput:
    def __init__(self, logits):
        self.logits = logits

# Create sample outputs with tiny tensors (batch=2, dim=4)
teacher_logits = torch.randn(2, 4)
student_logits = torch.randn(2, 4)

TeacherOutput = ModelOutput(teacher_logits)
StudentOutput = ModelOutput(student_logits)

ARGS = {
    "TeacherOutput": TeacherOutput,
    "StudentOutput": StudentOutput,
    "temp": 4
}
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 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
calculateComplexity Ran
ran; our contract draft was wrong, not the code
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("3e6b8dd06f26bd2e")
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 torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

class DummyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(768, 768)
    
    def forward(self, x):
        return self.linear(x)

class DummyArgs:
    def __init__(self):
        self.task_name = 'vision'
        self.model_name = 'base'

prunedProps = {
    'num_att_head': 12,
    'num_layers': 4,
    'inter_size': 3072,
    'patch_size': 197,
    'hidden_size': 768,
}

pruningParams = {
    'head_mask': torch.ones(4, 12),
    'neuron_mask': torch.ones(4, 3072),
    'patch_mask': [torch.ones(196) for _ in range(4)],
}

train_dataset = [
    (torch.randn(2, 3, 224, 224), torch.tensor([0, 1])),
    (torch.randn(2, 3, 224, 224), torch.tensor([1, 0])),
]

ARGS = {
    'args': DummyArgs(),
    'model': DummyModel(),
    'train_dataset': train_dataset,
    'prunedProps': prunedProps,
    'pruningParams': pruningParams,
}
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 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
compute_base_mac Ran
ran, honoured the contract we drafted
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("b8a3e26f899df98f")
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 float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class MockArgs:
    def __init__(self, model_name, task_name):
        self.model_name = model_name
        self.task_name = task_name

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x):
        return self.linear(x)

# Create args object
args = MockArgs(model_name='base', task_name='vision')

# Create prunedProps dictionary with required keys
prunedProps = {
    'num_att_head': 12,
    'num_layers': 2,
    'inter_size': 3072,
    'patch_size': 197,
    'hidden_size': 768,
}

# skipConv parameter
skipConv = False

# Map all parameters of compute_base_mac
ARGS = {
    'args': args,
    'prunedProps': prunedProps,
    'skipConv': skipConv,
}
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 float, 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
compute_mac Ran
ran, violated the contract we drafted
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("b9d5144329aa001b")
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 float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Analyze the function:
# - head_mask: list of integers (num_heads per layer)
# - neuron_mask: list of integers (num_neurons per layer)
# - patch_mask: list of integers (num_patches per layer)
# - seq_len: integer (sequence length)
# - hidden_size: integer (hidden dimension)
# - attention_head_size: integer (attention head dimension)

# The function iterates over layers and accesses head_mask[layer], neuron_mask[layer], patch_mask[layer]
# It also accesses patch_mask[num_layers - 1] in the last layer branch
# All masks are indexed by layer number, so they need to be sequences (lists)

num_layers = 3

# Create mask lists with distinct values for each layer
head_mask = [4, 4, 4]  # 4 heads per layer
neuron_mask = [8, 8, 8]  # 8 neurons per layer
patch_mask = [16, 16, 16]  # 16 patches per layer

seq_len = 16  # sequence length
hidden_size = 32  # hidden size dimension
attention_head_size = 8  # attention head size

ARGS = {
    "head_mask": head_mask,
    "neuron_mask": neuron_mask,
    "patch_mask": patch_mask,
    "seq_len": seq_len,
    "hidden_size": hidden_size,
    "attention_head_size": attention_head_size,
}
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 float, 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
compute_patch_mac Ran
ran, honoured the contract we drafted
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("18b585baff750730")
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 torch
import numpy as np

torch.manual_seed(0)

# Build args dict with all required parameters

# args: a generic object/dict with config-like properties
args = {}

# prunedProps: dict containing pruning configuration properties
prunedProps = {
    'patch_size': 10,
    'hidden_size': 16,
    'num_att_head': 4,
    'num_layers': 6
}

# mac_details: dict containing MAC (multiply-accumulate) calculations
# The function accesses: mac_details['head_mac'] and mac_details['neuron_mac']
mac_details = {
    'head_mac': 5120,  # computed from mac_per_head with some seq_len
    'neuron_mac': 320   # computed from mac_per_neuron with some seq_len
}

ARGS = {
    'args': args,
    'prunedProps': prunedProps,
    'mac_details': mac_details
}
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 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
compute_pruned_mac Ran
ran, honoured the contract we drafted
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("57a2ac87aeb75bf5")
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 float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Helper class for args
class Args:
    def __init__(self, model_name, task_name):
        self.model_name = model_name
        self.task_name = task_name

# Create args object
args = Args(model_name='base', task_name='vision')

# Create prunedProps dict
prunedProps = {
    'patch_size': 197,  # 14*14 + 1 for class token
    'num_layers': 3,
    'hidden_size': 768,
    'num_att_head': 12,
}

# Create pruningParams dict with masks
num_layers = prunedProps['num_layers']

# head_mask: shape (num_layers, num_heads) - we'll sum over last dim
head_mask_tensor = torch.randint(0, 2, (num_layers, 12))
pruningParams = {
    'head_mask': head_mask_tensor,
    'neuron_mask': torch.randint(0, 2, (num_layers, 3072)),
    'patch_mask': [torch.randint(0, 2, (197,)) for _ in range(num_layers)],
}

# Ensure at least some non-zero values
pruningParams['head_mask'][0, 0] = 1
pruningParams['neuron_mask'][0, 0] = 1
pruningParams['patch_mask'][0][0] = 1

skipConv = False

ARGS = {
    'args': args,
    'prunedProps': prunedProps,
    'pruningParams': pruningParams,
    'skipConv': skipConv,
}
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 float, 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
get_mac_details Ran
ran; our contract draft was wrong, not the code
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("8addab3b55f6f68e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

# Define a small stand-in class for args
class ArgsStandIn:
    def __init__(self, task_name='vision', model_name='base'):
        self.task_name = task_name
        self.model_name = model_name

# Create args object
args = ArgsStandIn(task_name='vision', model_name='base')

# Create prunedProps dictionary with realistic values for a Vision Transformer
prunedProps = {
    'num_att_head': 12,
    'num_layers': 12,
    'inter_size': 3072,
    'patch_size': 197,  # 196 patches + 1 CLS token
    'hidden_size': 768,
}

# Define ARGS as a dictionary mapping every parameter of get_mac_details
ARGS = {
    'args': args,
    'prunedProps': prunedProps,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
globalRankingLanguage Ran
ran; our contract draft was wrong, not the code
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("fa816ac012e18bee")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Construct the arguments for globalRankingLanguage

# Number of layers and attention heads
num_layers = 2
num_att_head = 3
inter_size = 8

# Create head_rank: list of tuples (score_tensor, layer, head_index, name)
head_rank_list = []
for layer in range(num_layers):
    for head in range(num_att_head):
        score = torch.tensor(-0.5 - (layer * num_att_head + head) * 0.1)
        head_rank_list.append((score, layer, head, f"head_{layer}_{head}"))

# Create neuron_rank: list of tuples (score_tensor, layer, neuron_index, name)
neuron_rank_list = []
for layer in range(num_layers):
    for neuron in range(inter_size):
        score = torch.tensor(-0.3 - (layer * inter_size + neuron) * 0.05)
        neuron_rank_list.append((score, layer, neuron, f"neuron_{layer}_{neuron}"))

# Create args dict
args = {
    'mac_constraint': 0.8  # 80% of baseline MAC budget
}

# Create prunedProps dict
prunedProps = {
    'num_att_head': num_att_head,
    'num_layers': num_layers,
    'inter_size': inter_size
}

# Create languageProps dict
languageProps = {
    'head_results': {
        'final_head_ranking': head_rank_list
    },
    'intermediate_results': {
        'final_neuron_ranking': neuron_rank_list
    },
    'mac_details': {
        'head_mac': 10.0,      # MAC cost per head
        'neuron_mac': 5.0,     # MAC cost per neuron
        'base_mac': 1000.0     # Baseline total MAC
    }
}

# Convert args dict to a simple namespace-like object
class Args:
    def __init__(self, d):
        for k, v in d.items():
            setattr(self, k, v)

args_obj = Args(args)

ARGS = {
    'args': args_obj,
    'prunedProps': prunedProps,
    'languageProps': languageProps
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
mac_per_head Ran
ran, honoured the contract we drafted
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("77c8d1bcdfe79662")
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 = {
    "seq_len": 8,
    "hidden_size": 16,
    "attention_head_size": 4,
}
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
mac_per_neuron Ran
ran, honoured the contract we drafted
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("159b80cd46f12b30")
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 = {
    "seq_len": 128,
    "hidden_size": 256,
}
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
manifold_Distillation Ran
ran; our contract draft was wrong, not the code
Skhaki18/optin-transformer-pruning/prune/loss_components.py
code served (permissive licence) · get_code("82a7f6c6a07d3234")
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 Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch.nn import functional as F
import numpy as np

torch.manual_seed(0)

# Create a minimal args object with aggregate attribute
class Args:
    def __init__(self, aggregate='mean'):
        self.aggregate = aggregate

args = Args(aggregate='mean')

# Create minimal teacher and student models
# The function uses them as tensors directly (F_s = student, F_t = teacher)
# So we need to pass tensors, not nn.Module instances
# Shape: (batch_size, patch_num, feature_dim)
batch_size = 2
patch_num = 3
feature_dim = 4

teacher = torch.randn(batch_size, patch_num, feature_dim)
student = torch.randn(batch_size, patch_num, feature_dim)

ARGS = {
    'args': args,
    'teacher': teacher,
    'student': student
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, 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
manifold_Distillation Ran
ran; our contract draft was wrong, not the code
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("93b2e14d2ed2e49d")
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 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as F

torch.manual_seed(0)

# Create a minimal args object with the aggregate attribute
class Args:
    def __init__(self, aggregate='mean'):
        self.aggregate = aggregate

args = Args(aggregate='mean')

# Create minimal teacher and student tensors
# Shape: (batch_size=2, patch_num=3, feature_dim=4)
teacher = torch.randn(2, 3, 4)
student = torch.randn(2, 3, 4)

ARGS = {
    'args': args,
    'teacher': teacher,
    'student': student
}
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 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
process_patch_mask Ran
ran; our contract draft was wrong, not the code
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("dda1ad56be460a00")
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 numpy as np

torch.manual_seed(0)

# The function expects patch_mask to be a list of tensors
# Each tensor contains binary values (0s and 1s)
# The function processes them sequentially, checking sums and finding indices

# Create a list of patch masks with varying properties
patch_mask_1 = torch.tensor([1, 1, 0, 1], dtype=torch.float32)  # sum=3, 75% selected
patch_mask_2 = torch.tensor([1, 1, 1, 0], dtype=torch.float32)  # sum=3, 75% selected
patch_mask_3 = torch.tensor([0, 1, 0, 0], dtype=torch.float32)  # sum=1, 25% selected (less than prev)
patch_mask_4 = torch.tensor([1, 0, 0, 1], dtype=torch.float32)  # sum=2, 50% selected

patch_mask = [patch_mask_1, patch_mask_2, patch_mask_3, patch_mask_4]

ARGS = {
    "patch_mask": patch_mask
}
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 — 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
query_conv_mac Ran
ran, honoured the contract we drafted
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("4cabaf97a1cafcd2")
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
import torch.nn as nn

class SimpleArgs:
    def __init__(self, model_name):
        self.model_name = model_name

# Test with 'base' model to get output_channels = 768
ARGS = {
    'args': SimpleArgs(model_name='base')
}
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
ModelHooking Not yet run
unverified (harvested, no recorded run)
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("72a06dbfb15610ae")
How it ran

no invocation recorded.

Prune Not yet run
unverified (harvested, no recorded run)
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("cb63f4eebf8926c2")
How it ran

no invocation recorded.

cnn_mmd Not yet run
unverified (harvested, no recorded run)
Skhaki18/optin-transformer-pruning/prune/loss_components.py
code served (permissive licence) · get_code("fb4f698a0e53c90a")
How it ran

no invocation recorded.

globalRankingVision Not yet run
unverified (harvested, no recorded run)
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("a7ccc4f26fd33e50")
How it ran

no invocation recorded.

pruneHead Not yet run
unverified (harvested, no recorded run)
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("053bf2646cdcfa75")
How it ran

no invocation recorded.

pruneLanguageNeurons Not yet run
unverified (harvested, no recorded run)
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("c07e8573b3785e73")
How it ran

no invocation recorded.

pruneModel Not yet run
unverified (harvested, no recorded run)
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("76238266383a6956")
How it ran

no invocation recorded.

pruneVisionNeurons Not yet run
unverified (harvested, no recorded run)
skhaki18/optin-transformer-pruning/prune/main_prune.py
code served (permissive licence) · get_code("cd869fbca8ce1494")
How it ran

no invocation recorded.

Also present in other papers' code

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

We introduce the One-shot Pruning Technique for Interchangeable Networks (OPTIN) framework as a tool to increase the efficiency of pre-trained transformer architectures, across many domains, without requiring re-training. Recent works have explored improving transformer efficiency, however often incur computationally expensive re-training procedures or depend on architecture-specific characteristics, thus impeding practical wide-scale adoption across multiple modalities. To address these shortcomings, the OPTIN framework leverages intermediate feature distillation, capturing the long-range dependencies of model parameters (coined trajectory), to produce state-of-the-art results on natural language, image classification, transfer learning, and semantic segmentation tasks. Our motivation stems from the need for a generalizable model compression framework that scales well across different transformer architectures and applications. Given a FLOP constraint, the OPTIN framework will compress the network while maintaining competitive accuracy performance and improved throughput. Particularly, we show a ≤ 2% accuracy degradation from NLP baselines and a 0.5% improvement from stateof-the-art methods on image classification at competitive FLOPs reductions. We further demonstrate the generalization of tasks and architecture with comparative performance on Mask2Former for semantic segmentation and cnn-style networks. OPTIN presents one of the first one-shot efficient frameworks for compressing transformer architectures that generalizes well across multiple class domains, in particular: natural language and image-related tasks, without re-training. Code is available at: https://github.com/Skhaki18/optin-transformer-pruning.

For agents

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

get_harvested_code_for_paper("2403.17921")
get_code_for_paper("2403.17921")
have("2403.17921")

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

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

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

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

Connect an agent — have() is free.