SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2301.12900 · CVPR · 2023

DepGraph: Towards Any Structural Pruning

Xinchao Wang, Mingli Song, Xinyin Ma, Gongfan Fang, Michael Mi

arXiv · PDF · Open in the Atlas

Code that ran

7 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 6 have no contract verdict; 0 failures of our instrument; 0 no recorded run), measured 2026-11-22; 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/2301.12900.json · badge: /api/ran/2301.12900.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
VainF/Torch-Pruning canonical (classifier label)
classifier basis not recorded on the link
7 ran · 0 no recorded run
FunctionStatusWhere it lives
is_scalar Ran
ran, violated the contract we drafted
VainF/Torch-Pruning/torch_pruning/_helpers.py
code served (permissive licence) · get_code("915b7da0362eb2b4")
How it ran

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

import torch
from numbers import Number

torch.manual_seed(0)

# The function is_scalar takes a single parameter 'x' and checks if it's a scalar
# It returns True for:
# - torch.Tensor with shape length 0 (scalar tensor)
# - Number instances
# It returns False for lists, tuples, and other types

ARGS = {
    "x": torch.tensor(5.0)  # A scalar tensor (0-dimensional)
}
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 bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_state_dict Ran
ran on a synthesized input
VainF/Torch-Pruning/torch_pruning/serialization.py
code served (permissive licence) · get_code("44927cfc49a45803")
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 SimpleModel. 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 simple model with some custom attributes
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
        self.custom_attr = 42
        self.custom_str = "test"
        self.custom_list = [1, 2, 3]

model = SimpleModel()

# Create a state_dict by calling the state_dict function
def state_dict(model: torch.nn.Module):
    """ Returns a dictionary containing the state, attributions of a module.
    """
    full_state_dict = {}
    attributions = {}
    for name, module in model.named_modules():
        full_state_dict[name] = module.__dict__.copy()
        module_attr = {}
        for attr_name in dir(module):
            attr_value = getattr(module, attr_name)
            if attr_name == 'T_destination':
                continue
            if not callable(attr_value) and (not attr_name.startswith('__')) and (not attr_name.startswith('_')):
                if not isinstance(attr_value, torch.nn.Parameter) and (not isinstance(attr_value, torch.Tensor)):
                    module_attr[attr_name] = attr_value
        attributions[name] = module_attr
    return {'full_state_dict': full_state_dict, 'attributions': attributions}

# Generate the state dict from the model
captured_state = state_dict(model)

# Create a fresh model to load the state into
fresh_model = SimpleModel()

ARGS = {
    'model': fresh_model,
    'state_dict': captured_state
}
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 SimpleModel — a SimpleModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SimpleModel 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
module2type Ran
ran on a synthesized input
VainF/Torch-Pruning/torch_pruning/ops.py
code served (permissive licence) · get_code("499a656713eb0e7a")
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 OPTYPE. 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 enum import IntEnum

torch.manual_seed(0)

class _CustomizedOp(nn.Module):
    def __init__(self, op_class):
        super().__init__()
        self.op_cls = op_class

    def __repr__(self):
        return 'CustomizedOp({})'.format(str(self.op_cls))

class _ConcatOp(nn.Module):
    def __init__(self, id):
        super(_ConcatOp, self).__init__()
        self.offsets = None
        self.concat_sizes = None
        self.id = id

    def __repr__(self):
        return '_ConcatOp_{}({})'.format(self.id, self.offsets)

class _SplitOp(nn.Module):
    def __init__(self, id):
        super(_SplitOp, self).__init__()
        self.offsets = None
        self.split_sizes = None
        self.id = id

    def __repr__(self):
        return '_SplitOp_{}({})'.format(self.id, self.offsets)

class _UnbindOp(nn.Module):
    def __init__(self, id):
        super(_UnbindOp, self).__init__()
        self.offsets = None
        self.split_sizes = None
        self.id = id

    def __repr__(self):
        return '_UnbindOp_{}({})'.format(self.id, self.offsets)

class _ReshapeOp(nn.Module):
    def __init__(self, id):
        super(_ReshapeOp, self).__init__()
        self.id = id

    def __repr__(self):
        return '_Reshape_{}()'.format(self.id)

class _ExpandOp(nn.Module):
    def __init__(self, id):
        super(_ExpandOp, self).__init__()
        self.id = id

    def __repr__(self):
        return '_ExpandOp_{}()'.format(self.id)

class _OutputOp(nn.Module):
    def __init__(self, id, shape=None):
        super(_OutputOp, self).__init__()
        self.id = id
        self.shape = list(shape) if shape is not None else None

    def __repr__(self):
        return '_OutputOp_{}({})'.format(self.id, self.shape if self.shape is not None else 'None')

class FakeGradFn:
    def __init__(self):
        self._saved_start = 0
        self._saved_end = 4
        self._saved_step = 1
        self._saved_dim = 0

class _SliceOp(nn.Module):
    def __init__(self, id, grad_fn):
        super(_SliceOp, self).__init__()
        self.grad_fn = grad_fn
        self.id = id
        self.start = grad_fn._saved_start
        self.end = grad_fn._saved_end
        self.step = grad_fn._saved_step
        self.dim = grad_fn._saved_dim

    def __repr__(self):
        return '_Slice_{}()'.format(self.id)

# Test with a Conv2d module
conv_module = nn.Conv2d(3, 16, kernel_size=3)
linear_module = nn.Linear(10, 5)
bn_module = nn.BatchNorm2d(16)
prelu_module = nn.PReLU()
concat_op = _ConcatOp(0)
split_op = _SplitOp(1)
ln_module = nn.LayerNorm(8)
embed_module = nn.Embedding(100, 16)
customized_op = _CustomizedOp(nn.ReLU)
gn_module = nn.GroupNorm(4, 16)
in_module = nn.InstanceNorm2d(16)
reshape_op = _ReshapeOp(2)
unbind_op = _UnbindOp(3)
expand_op = _ExpandOp(4)
fake_grad_fn = FakeGradFn()
slice_op = _SliceOp(5, fake_grad_fn)
output_op = _OutputOp(6, shape=[2, 4, 8])
elementwise_module = nn.ReLU()

ARGS = {
    "module": conv_module
}
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 OPTYPE — a OPTYPE output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a OPTYPE output the recorded ndim 0 and dtype family int 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
state_dict Ran
ran on a synthesized input
VainF/Torch-Pruning/torch_pruning/serialization.py
code served (permissive licence) · get_code("f8d1be76d0300bbf")
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 simple model with some parameters and attributes
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
        self.custom_attr = "test_attribute"
        self.custom_number = 42
        self.custom_list = [1, 2, 3]
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

ARGS = {
    'model': model
}
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
to_plain_idxs Ran
ran on a synthesized input
VainF/Torch-Pruning/torch_pruning/_helpers.py
code served (permissive licence) · get_code("a5f40ecfcfcbe7c1")
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 2, 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
from collections import namedtuple

class _HybridIndex(namedtuple('_PruingIndex', ['idx', 'root_idx'])):
    """ A tuple of (idx, root_idx) where idx is the index of the pruned dimension in the current layer, 
    and root_idx is the index of the pruned dimension in the root layer.
    """

    def __repr__(self):
        return str((self.idx, self.root_idx))

# Test case 1: Empty list
empty_idxs = []

# Test case 2: List of _HybridIndex objects
hybrid_idxs = [
    _HybridIndex(idx=0, root_idx=5),
    _HybridIndex(idx=1, root_idx=6),
    _HybridIndex(idx=2, root_idx=7),
]

# Test case 3: List of plain indices (not _HybridIndex)
plain_idxs = [0, 1, 2, 3]

ARGS = {
    "idxs": hybrid_idxs
}
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 2, 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
to_root_idxs Ran
ran on a synthesized input
VainF/Torch-Pruning/torch_pruning/_helpers.py
code served (permissive licence) · get_code("b4c2def331fc3065")
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 2, 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
from collections import namedtuple

class _HybridIndex(namedtuple('_PruingIndex', ['idx', 'root_idx'])):
    """ A tuple of (idx, root_idx) where idx is the index of the pruned dimension in the current layer, 
    and root_idx is the index of the pruned dimension in the root layer.
    """

    def __repr__(self):
        return str((self.idx, self.root_idx))

def to_root_idxs(idxs: _HybridIndex):
    if len(idxs) == 0 or not isinstance(idxs[0], _HybridIndex):
        return idxs
    return [i.root_idx for i in idxs]

# Setup code
torch.manual_seed(0)

# Test case 1: non-empty list of _HybridIndex objects
hybrid_indices = [
    _HybridIndex(idx=0, root_idx=5),
    _HybridIndex(idx=1, root_idx=7),
    _HybridIndex(idx=2, root_idx=3),
]

ARGS = {
    "idxs": hybrid_indices
}
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 2, 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
type2class Ran
ran on a synthesized input
VainF/Torch-Pruning/torch_pruning/ops.py
code served (permissive licence) · get_code("33b3f48ffee9c0cd")
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 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 enum import IntEnum

torch.manual_seed(0)

class OPTYPE(IntEnum):
    CONV = 0
    BN = 1
    LINEAR = 2
    PRELU = 3
    DEPTHWISE_CONV = 4
    CONCAT = 5
    SPLIT = 6
    CUSTOMIZED = 7
    ELEMENTWISE = 8
    LN = 9
    EMBED = 10
    PARAMETER = 11
    MHA = 12
    LSTM = 13
    RESHAPE = 14
    GN = 15
    IN = 16
    UNBIND = 17
    EXPAND = 18
    SLICE = 19
    OUTPUT = 20

TORCH_CONV = nn.modules.conv._ConvNd
TORCH_BATCHNORM = nn.modules.batchnorm._BatchNorm
TORCH_LAYERNORM = nn.modules.normalization.LayerNorm
TORCH_GROUPNORM = nn.GroupNorm
TORCH_INSTANCENORM = nn.modules.instancenorm._InstanceNorm
TORCH_PRELU = nn.PReLU
TORCH_LINEAR = nn.Linear
TORCH_EMBED = nn.Embedding
TORCH_PARAMETER = nn.Parameter
TORCH_LSTM = nn.LSTM

class _CustomizedOp(nn.Module):
    def __init__(self, op_class):
        super().__init__()
        self.op_cls = op_class

    def __repr__(self):
        return 'CustomizedOp({})'.format(str(self.op_cls))

class _ConcatOp(nn.Module):
    def __init__(self, id):
        super(_ConcatOp, self).__init__()
        self.offsets = None
        self.concat_sizes = None
        self.id = id

    def __repr__(self):
        return '_ConcatOp_{}({})'.format(self.id, self.offsets)

class _SplitOp(nn.Module):
    def __init__(self, id):
        super(_SplitOp, self).__init__()
        self.offsets = None
        self.split_sizes = None
        self.id = id

    def __repr__(self):
        return '_SplitOp_{}({})'.format(self.id, self.offsets)

class _UnbindOp(nn.Module):
    def __init__(self, id):
        super(_UnbindOp, self).__init__()
        self.offsets = None
        self.split_sizes = None
        self.id = id

    def __repr__(self):
        return '_UnbindOp_{}({})'.format(self.id, self.offsets)

class _ReshapeOp(nn.Module):
    def __init__(self, id):
        super(_ReshapeOp, self).__init__()
        self.id = id

    def __repr__(self):
        return '_Reshape_{}()'.format(self.id)

class MockGradFn:
    def __init__(self):
        self._saved_start = 0
        self._saved_end = 2
        self._saved_step = 1
        self._saved_dim = 0

class _SliceOp(nn.Module):
    def __init__(self, id, grad_fn):
        super(_SliceOp, self).__init__()
        self.grad_fn = grad_fn
        self.id = id
        self.start = grad_fn._saved_start
        self.end = grad_fn._saved_end
        self.step = grad_fn._saved_step
        self.dim = grad_fn._saved_dim

    def __repr__(self):
        return '_Slice_{}()'.format(self.id)

class _OutputOp(nn.Module):
    def __init__(self, id, shape=None):
        super(_OutputOp, self).__init__()
        self.id = id
        self.shape = list(shape) if shape is not None else None

    def __repr__(self):
        return '_OutputOp_{}({})'.format(self.id, self.shape if self.shape is not None else 'None')

class _ElementWiseOp(nn.Module):
    def __init__(self, id, grad_fn):
        super(_ElementWiseOp, self).__init__()
        self._grad_fn = grad_fn
        self.id = id

    def __repr__(self):
        return '_ElementWiseOp_{}({})'.format(self.id, self._grad_fn)

class _ExpandOp(nn.Module):
    def __init__(self, id):
        super(_ExpandOp, self).__init__()
        self.id = id

    def __repr__(self):
        return '_ExpandOp_{}()'.format(self.id)

ARGS = {
    "op_type": OPTYPE.CONV
}
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 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 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 later) and 4 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
is_scalar 2 other papers
2 later
2402.07839 (2024-02)
Towards Meta-Pruning via Optimal Transport
2502.17941 (2025-02)
Optimal Brain Apoptosis
to_plain_idxs 1 other paper
1 later
2502.17941 (2025-02)
Optimal Brain Apoptosis
to_root_idxs 1 other paper
1 later
2502.17941 (2025-02)
Optimal Brain Apoptosis

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

Structural pruning enables model acceleration by removing structurally-grouped parameters from neural networks. However, the parameter-grouping patterns vary widely across different models, making architecturespecific pruners, which rely on manually-designed grouping schemes, non-generalizable to new architectures. In this work, we study a highly-challenging yet barely-explored task, any structural pruning, to tackle general structural pruning of arbitrary architecture like CNNs, RNNs, GNNs and Transformers. The most prominent obstacle towards this goal lies in the structural coupling, which not only forces different layers to be pruned simultaneously, but also expects all removed parameters to be consistently unimportant, thereby avoiding structural issues and significant performance degradation after pruning. To address this problem, we propose a general and fully automatic method, Dependency Graph (DepGraph), to explicitly model the dependency between layers and comprehensively group coupled parameters for pruning. In this work, we extensively evaluate our method on several architectures and tasks, including ResNe(X)t, DenseNet, MobileNet and Vision transformer for images, GAT for graph, DGCNN for 3D point cloud, alongside LSTM for language, and demonstrate that, even with a simple norm-based criterion, the proposed method consistently yields gratifying performances.

For agents

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

get_harvested_code_for_paper("2301.12900")
get_code_for_paper("2301.12900")
have("2301.12900")

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

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

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

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

Connect an agent — have() is free.