SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.16742 · ACL · 2023

Parameter-Efficient Fine-Tuning without Introducing New Latency

Christof Monz, Baohao Liao, Yan Meng

arXiv · PDF · Open in the Atlas

Code that ran

1 of 1 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 1 failure of our instrument; 0 no recorded run), measured 2026-11-23; 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/2305.16742.json · badge: /api/ran/2305.16742.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
Aradhye2002/selective-peft-toolkit community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
get_pafi Ran
ran; our contract draft was wrong, not the code
Aradhye2002/selective-peft-toolkit/selective_optimizers/optimizers/pafi.py
code served (permissive licence) · get_code("f9048d571d073134")
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 type. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch.optim import SGD

torch.manual_seed(0)

# Create a simple model with parameters
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

# Create a base optimizer class (SGD in this case)
base_optimizer = SGD

# The get_pafi function creates a Pafi class that inherits from base_optimizer
# We need to instantiate it with proper param_groups and budget
def get_pafi(base_optimizer):
    """
    Factory function to create the Pafi optimizer class, inheriting from base_optimizer.
    The Pafi optimizer selects parameters to fine-tune based on their magnitude.
    """

    class Pafi(base_optimizer):
        """
        Pafi optimizer class that selects parameters with small magnitudes to fine-tune.
        """

        @torch.no_grad()
        def init_chosen(self):
            """
            Initialize the chosen masks by selecting parameters with the smallest magnitudes,
            respecting the global budget.
            """
            total_chosen = 0
            mode2_params = []
            for group_idx, param_group in enumerate(self.param_groups):
                if param_group.get('choose_all', False):
                    for param in param_group['params']:
                        if param.requires_grad:
                            total_chosen += param.numel()
                else:
                    for param in param_group['params']:
                        if param.requires_grad:
                            mode2_params.append((param, group_idx))
            if total_chosen > self.budget:
                raise ValueError(f"[Pafi:init_chosen] 'choose_all' groups alone exceed the budget (got {total_chosen} > budget {self.budget}).")
            device = self.param_groups[0]['params'][0].device
            all_abs = []
            param_shapes = []
            for p, _ in mode2_params:
                all_abs.append(p.abs().view(-1).to(device))
                param_shapes.append(p.shape)
            if len(all_abs) > 0:
                all_abs = torch.cat(all_abs, dim=0)
            else:
                all_abs = torch.tensor([], device=device)
            k = self.budget - total_chosen
            if k > 0 and len(all_abs) > 0:
                sorted_indices = torch.argsort(all_abs)
                chosen_flat_indices = sorted_indices[:k]
            else:
                chosen_flat_indices = torch.tensor([], dtype=torch.long, device=all_abs.device)
            chosen_masks_mode2 = []
            offset = 0
            for param, group_idx in mode2_params:
                size = param.numel()
                mask = torch.zeros(size, dtype=torch.bool, device=param.device)
                start, end = (offset, offset + size)
                in_range = (chosen_flat_indices >= start) & (chosen_flat_indices < end)
                if in_range.any():
                    relevant_indices = chosen_flat_indices[in_range] - start
                    mask[relevant_indices] = True
                mask = mask.view(param.shape)
                chosen_masks_mode2.append((mask, group_idx))
                offset += size
            mode2_counter = 0
            for group_idx, param_group in enumerate(self.param_groups):
                if param_group.get('choose_all', False):
                    chosen_masks = []
                    for param in param_group['params']:
                        if param.requires_grad:
                            chosen_masks.append(torch.ones_like(param.data, dtype=torch.bool))
                        else:
                            chosen_masks.append(None)
                    param_group['chosen_masks'] = chosen_masks
                else:
                    chosen_masks = []
                    for param in param_group['params']:
                        if param.requires_grad:
                            mask, stored_group_idx = chosen_masks_mode2[mode2_counter]
                            if stored_group_idx != group_idx:
                                raise RuntimeError('Internal mismatch of group indices.')
                            chosen_masks.append(mask)
                            mode2_counter += 1
                        else:
                            chosen_masks.append(torch.zeros_like(param.data, dtype=torch.bool))
                    param_group['chosen_masks'] = chosen_masks
            final_used = 0
            for param_group in self.param_groups:
                for mask in param_group['chosen_masks']:
                    final_used += mask.sum().item()
            if final_used > self.budget:
                raise RuntimeError(f'[Pafi:init_chosen] final_used={final_used} exceeds budget={self.budget}.')

        @torch.no_grad()
        def update_chosen(self):
            """
            Pafi does not update chosen masks after initialization.
            """
            pass
    return Pafi

# Create optimizer instance with proper setup
pafi_class = get_pafi(SGD)
optimizer = pafi_class(model.parameters(), lr=0.01)
optimizer.budget = 50

ARGS = {
    'base_optimizer': SGD
}
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 type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type 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

Also present in other papers' code

Of 1 samples lifted from this paper's linked repositories, 1 carry a function identity and 0 do not. Of the 1 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 1 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

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

Parameter-efficient fine-tuning (PEFT) of pretrained language models has recently demonstrated remarkable achievements, effectively matching the performance of full fine-tuning while utilizing significantly fewer trainable parameters, and consequently addressing the storage and communication constraints. Nonetheless, various PEFT methods are limited by their inherent characteristics. In the case of sparse fine-tuning, which involves modifying only a small subset of the existing parameters, the selection of fine-tuned parameters is task-and domain-specific, making it unsuitable for federated learning. On the other hand, PEFT methods with adding new parameters typically introduce additional inference latency. In this paper, we demonstrate the feasibility of generating a sparse mask in a task-agnostic manner, wherein all downstream tasks share a common mask. Our approach, which relies solely on the magnitude information of pre-trained parameters, surpasses existing methodologies by a significant margin when evaluated on the GLUE benchmark. Additionally, we introduce a novel adapter technique that directly applies the adapter to pre-trained parameters instead of the hidden representation, thereby achieving identical inference speed to that of full finetuning. Through extensive experiments, our proposed method attains a new state-of-the-art outcome in terms of both performance and storage efficiency, storing only 0.03% parameters of full fine-tuning.

For agents

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

get_harvested_code_for_paper("2305.16742")
get_code_for_paper("2305.16742")
have("2305.16742")

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

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

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

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

Connect an agent — have() is free.