SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2107.03356 · NeurIPS · 2021

M-FAC: Efficient Matrix-Free Approximations of Second-Order Information

Elias Frantar, Dan Alistarh, Eldar Kurtic

arXiv · PDF · Open in the Atlas

Code that ran

7 of 14 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; 4 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 7 no recorded run); 2 of them were also run on the host, not in the jail, by the peer-agreement lane that set their level, measured 2026-11-21; 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/2107.03356.json · badge: /api/ran/2107.03356.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
IST-DASLab/M-FAC canonical (classifier label)
classifier basis: classifier_2025
4 ran · 2 no recorded run
ist-daslab/efcp community
Papers with Code archive
3 ran · 5 no recorded run
FunctionStatusWhere it lives
batch_mvp Ran
ran; our contract draft was wrong, not the code
IST-DASLab/M-FAC/prun.py
code served (permissive licence) · get_code("8050b1947cc48db8")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-05T00:38:37Z). 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
import math

torch.manual_seed(0)

# A should be a matrix that can perform matmul with B reshaped to (b, d, 1)
# If B is (b, d), then B.reshape((b, d, 1)) is (b, d, 1)
# For matmul to work, A should be (b, output_dim, d) or broadcastable
# The result is reshaped to (b, -1), so A.matmul(B.reshape((b, d, 1))) should be (b, output_dim, 1)

b = 2  # batch size
d = 4  # input dimension
output_dim = 3  # output dimension

# A: (b, output_dim, d) - batch of matrices
A = torch.randn(b, output_dim, d)

# B: (b, d) - batch of vectors
B = torch.randn(b, d)

ARGS = {
    "A": A,
    "B": B,
}
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 Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) 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
batch_vmp Ran
ran; our contract draft was wrong, not the code
IST-DASLab/M-FAC/prun.py
code served (permissive licence) · get_code("19650f5d1f338d8a")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-04T22:44:15Z). 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)

# batch_vmp expects:
# A: tensor of shape (b, d) - batch size b, dimension d
# B: tensor of shape (d, k) - dimension d, output dimension k
# The function reshapes A to (b, 1, d), multiplies by B to get (b, 1, k), then reshapes to (b, k)

b = 2  # batch size
d = 4  # input dimension
k = 3  # output dimension

A = torch.randn(b, d)
B = torch.randn(d, k)

ARGS = {
    "A": A,
    "B": B,
}
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 Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) 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
batch_dot Ran
ran; our contract draft was wrong, not the code
IST-DASLab/M-FAC/prun.py
code served (permissive licence) · get_code("87ccd31d3ec472fd")
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 1, dtype family float, shape (2,) 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
import math

torch.manual_seed(0)

# batch_dot takes two parameters: A and B
# Looking at the function body:
# - A.shape is unpacked as (b, d), so A must be a 2D tensor
# - B.reshape((b, d, 1)) suggests B should also be reshapeable to (b, d, 1)
# - The operation is a batched dot product: for each batch element, 
#   it computes the dot product of A[i] and B[i]

# Create A: shape (batch_size=2, dim=4)
A = torch.randn(2, 4)

# Create B: shape (batch_size=2, dim=4)
# B should have the same batch and dimension sizes as A for the dot product
B = torch.randn(2, 4)

ARGS = {
    "A": A,
    "B": B,
}
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 Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) 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_gradients Ran
ran, honoured the contract we drafted
ist-daslab/efcp/optimizers/dense/MFAC.py
code served (permissive licence) · get_code("3cb7ad181b8a381b")
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 1, dtype family float, shape (15,) 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)

# Create a simple model with parameters
model = nn.Linear(4, 3)

# Forward pass to create gradients
x = torch.randn(2, 4)
y = torch.randn(2, 3)
output = model(x)
loss = nn.MSELoss()(output, y)
loss.backward()

# Construct params in the format expected by get_gradients
# This mimics the format returned by optimizer.param_groups
params = [
    {
        'params': [model.weight, model.bias]
    }
]

ARGS = {
    'params': params
}
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 Tensor, ndim 1, dtype family float, shape (15,) — shape (15,) 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_weights Ran
ran, honoured the contract we drafted
ist-daslab/efcp/optimizers/dense/MFAC.py
code served (permissive licence) · get_code("d0a95782e972077b")
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 1, dtype family float, shape (32,) 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)

# The function expects params to be a list of dicts, where each dict has a 'params' key
# containing an iterable of tensors. This is the standard PyTorch optimizer param_groups format.

# Create some sample tensors with distinct sizes
param1 = nn.Parameter(torch.randn(2, 3))
param2 = nn.Parameter(torch.randn(4, 5))
param3 = nn.Parameter(torch.randn(6,))

# Construct param groups in the format expected by the function
params = [
    {
        'params': [param1, param2]
    },
    {
        'params': [param3]
    }
]

ARGS = {
    'params': params
}
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 Tensor, ndim 1, dtype family float, shape (32,) — shape (32,) 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
norm Ran
ran, honoured the contract we drafted
ist-daslab/efcp/optimizers/dense/MFAC.py
code served (permissive licence) · get_code("79cfb98e536acac6")
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 1, dtype family float, shape (4,) 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)

# The function norm(v) expects:
# - v: an object that supports:
#   - ** operator (exponentiation)
#   - .shape attribute with indexing [0]
#   - sum() function
# This is a torch tensor

v = torch.randn(2, 4)

ARGS = {
    "v": v
}
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 1, dtype family float, shape (4,) — shape (4,) 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
test Ran
ran, honoured the contract we drafted
IST-DASLab/M-FAC/main_optim.py
code served (permissive licence) · get_code("c1bbbadad5c3cdcf")
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 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
from torch.utils.data import DataLoader

torch.manual_seed(0)

# Create a minimal model that satisfies the function's usage
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)  # 4 input dims, 3 output classes
        self.device_attr = torch.device('cpu')
    
    @property
    def device(self):
        return self.device_attr
    
    def forward(self, x):
        return self.linear(x)

# Create model instance
model = MinimalModel()

# Create minimal dataset as list of (x, y) tuples
# x: shape (4,) - input features
# y: scalar - class label (0, 1, or 2)
data = [
    (torch.randn(4), torch.tensor(0)),
    (torch.randn(4), torch.tensor(1)),
    (torch.randn(4), torch.tensor(2)),
    (torch.randn(4), torch.tensor(0)),
]

ARGS = {
    'model': model,
    'data': data,
    'batch_size': 128,
}
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 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
DenseMFAC Not yet run
unverified (harvested, no recorded run)
ist-daslab/efcp/optimizers/dense/MFAC.py
code served (permissive licence) · get_code("7290388bb1e94558")
How it ran

no invocation recorded.

HInvFastUpMulti Not yet run
unverified (harvested, no recorded run)
ist-daslab/efcp/optimizers/dense/MFAC.py
code served (permissive licence) · get_code("80db31a3a92821b5")
How it ran

no invocation recorded.

HInvFastUpMulti Not yet run
unverified (harvested, no recorded run)
IST-DASLab/M-FAC/optim.py
code served (permissive licence) · get_code("289ba747a6543b4b")
How it ran

no invocation recorded.

MFAC Not yet run
unverified (harvested, no recorded run)
IST-DASLab/M-FAC/optim.py
code served (permissive licence) · get_code("dadfb3e97237d010")
How it ran

no invocation recorded.

get_first_device Not yet run
unverified (harvested, no recorded run)
ist-daslab/efcp/optimizers/dense/MFAC.py
code served (permissive licence) · get_code("1f9104c9660aeb24")
How it ran

no invocation recorded.

get_gpus Not yet run
unverified (harvested, no recorded run)
ist-daslab/efcp/optimizers/dense/MFAC.py
code served (permissive licence) · get_code("08f4dde70db58de8")
How it ran

no invocation recorded.

update_model Not yet run
unverified (harvested, no recorded run)
ist-daslab/efcp/optimizers/dense/MFAC.py
code served (permissive licence) · get_code("c2dc9537f5e560fa")
How it ran

no invocation recorded.

Also present in other papers' code

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

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Efficiently approximating local curvature information of the loss function is a key tool for optimization and compression of deep neural networks. Yet, most existing methods to approximate second-order information have high computational or storage costs, which limits their practicality. In this work, we investigate matrix-free, linear-time approaches for estimating Inverse-Hessian Vector Products (IHVPs) for the case when the Hessian can be approximated as a sum of rank-one matrices, as in the classic approximation of the Hessian by the empirical Fisher matrix. We propose two new algorithms: the first is tailored towards network compression and can compute the IHVP for dimension d, if the Hessian is given as a sum of m rank-one matrices, using O(dm 2 ) precomputation, O(dm) cost for computing the IHVP, and query cost O(m) for any single element of the inverse Hessian. The second algorithm targets an optimization setting, where we wish to compute the product between the inverse Hessian, estimated over a sliding window of optimization steps, and a given gradient direction, as required for preconditioned SGD. We give an algorithm with cost O(dm + m 2 ) for computing the IHVP and O(dm + m 3 ) for adding or removing any gradient from the sliding window. These two algorithms yield state-of-the-art results for network pruning and optimization with lower computational overhead relative to existing second-order methods. Implementations are available at [9] and [17].

For agents

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

get_harvested_code_for_paper("2107.03356")
get_code_for_paper("2107.03356")
have("2107.03356")

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

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

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

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

Connect an agent — have() is free.