SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2105.01637 · 2021

Implicit differentiation for fast hyperparameter selection in non-smooth convex learning

arXiv · PDF · Open in the Atlas

Code that ran

5 of 5 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; 5 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/2105.01637.json · badge: /api/ran/2105.01637.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
QB3/sparse-ho canonical (classifier label)
classifier basis: census
5 ran · 0 no recorded run
FunctionStatusWhere it lives
compute_beta Ran
ran; our contract draft was wrong, not the code
QB3/sparse-ho/sparse_ho/algo/forward.py
code served (permissive licence) · get_code("37842502f1c4807f")
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 2, 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 numpy as np
from scipy.sparse import csr_matrix
import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal model class that implements the required methods
class MinimalModel(nn.Module):
    def __init__(self, n_features):
        super().__init__()
        self.n_features = n_features
        self.dual_var = None
        self.ddual_var = None
    
    def get_L(self, X):
        """Return Lipschitz constant"""
        return 1.0
    
    def _init_beta_dual_var(self, X, y, mask0, dense0):
        """Initialize beta and dual_var"""
        n_features = X.shape[1]
        beta = np.zeros(n_features)
        dual_var = np.zeros(X.shape[0])
        return beta, dual_var
    
    def _init_dbeta_ddual_var(self, X, y, mask0=None, dense0=None, jac0=None, compute_jac=True):
        """Initialize dbeta and ddual_var"""
        n_features = X.shape[1]
        dbeta = np.zeros(n_features)
        ddual_var = np.zeros(X.shape[0])
        return dbeta, ddual_var
    
    def _get_pobj0(self, dual_var, beta_zeros, alphas, y):
        """Get initial primal objective"""
        return 1.0
    
    def _get_pobj(self, dual_var, X, beta, alphas, y):
        """Get primal objective"""
        return 0.5 * np.sum((y - X @ beta) ** 2) + np.sum(alphas * np.abs(beta))
    
    def _get_dobj(self, dual_var, X, beta, alpha, y):
        """Get dual objective"""
        return 0.1
    
    def _update_beta_jac_bcd(self, X, y, beta, dbeta, dual_var, ddual_var, alphas, L, compute_jac=True):
        """Update beta and jacobian using block coordinate descent (dense)"""
        # Minimal update: just make small changes
        beta[:] += 0.01 * np.random.randn(len(beta))
        if compute_jac:
            dbeta[:] += 0.001 * np.random.randn(len(dbeta))
    
    def _update_beta_jac_bcd_sparse(self, data, indptr, indices, y, n_samples, n_features, beta, dbeta, dual_var, ddual_var, alphas, L, compute_jac=True):
        """Update beta and jacobian using block coordinate descent (sparse)"""
        beta[:] += 0.01 * np.random.randn(len(beta))
        if compute_jac:
            dbeta[:] += 0.001 * np.random.randn(len(dbeta))
    
    def _get_jac(self, dbeta, mask):
        """Get jacobian restricted to support"""
        return dbeta[mask]

# Create small test data
n_samples = 2
n_features = 4

X = np.random.randn(n_samples, n_features).astype(np.float64)
X = np.asfortranarray(X)
y = np.random.randn(n_samples)
log_alpha = np.log(0.1)
model = MinimalModel(n_features)

ARGS = {
    'X': X,
    'y': y,
    'log_alpha': log_alpha,
    'model': model,
    'mask0': None,
    'dense0': None,
    'jac0': None,
    'max_iter': 5,
    'tol': 0.001,
    'compute_jac': True,
    'return_all': False,
    'save_iterates': False,
    'verbose': False,
    'use_stop_crit': True,
    'gap_freq': 10
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, 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
get_grad_backward Ran
ran; our contract draft was wrong, not the code
QB3/sparse-ho/sparse_ho/algo/backward.py
code served (permissive licence) · get_code("6c4af7a7c79feb8e")
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 ndarray, 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 numpy as np
from scipy.sparse import csr_matrix

class MockModel:
    def _init_g_backward(self, arg, n_features):
        return np.zeros(n_features)
    
    def _update_bcd_jac_backward(self, X, alpha, grad, beta, v_, L):
        return grad + np.random.randn(*grad.shape) * 0.01
    
    def _update_bcd_jac_backward_sparse(self, data, indptr, indices, n_samples, n_features, alpha, grad, beta, v_, L):
        return grad + np.random.randn(*grad.shape) * 0.01

n_samples = 5
n_features = 4

X_dense = np.random.randn(n_samples, n_features)
alpha = 0.1
list_beta = np.random.randn(3, n_features)
v = np.random.randn(n_features)
model = MockModel()
jac_v0 = np.random.randn(n_features)

ARGS = {
    "X": X_dense,
    "alpha": alpha,
    "list_beta": list_beta,
    "v": v,
    "model": model,
    "jac_v0": jac_v0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, 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
get_only_jac Ran
ran; our contract draft was wrong, not the code
QB3/sparse-ho/sparse_ho/algo/implicit_forward.py
code served (permissive licence) · get_code("e10b075e29daac9e")
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 ndarray, ndim 1, dtype family float, shape (3,) 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 numpy as np
from scipy.sparse import csr_matrix
import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal model class that satisfies all the method/attribute calls
class MinimalModel:
    def __init__(self):
        pass
    
    def get_L(self, Xs):
        # Return a Lipschitz constant (scalar)
        return 1.0
    
    def _init_dbeta(self, n_features):
        # Initialize dbeta (derivative of beta)
        return np.zeros(n_features)
    
    def _init_ddual_var(self, dbeta, Xs, y, sign_beta, alpha):
        # Initialize dual variable derivative
        n_samples = Xs.shape[0]
        return np.zeros(n_samples)
    
    def _update_only_jac(self, Xs, y, dual_var, dbeta, ddual_var, L, alpha, sign_beta):
        # Update step for dense case
        pass
    
    def _update_only_jac_sparse(self, data, indptr, indices, y, n_samples, n_features, dbeta, dual_var, ddual_var, L, alpha, sign_beta):
        # Update step for sparse case
        pass
    
    def get_jac_residual_norm(self, Xs, y, n_samples, sign_beta, dbeta, dual_var, ddual_var, alpha):
        # Return residual norm (scalar)
        return np.random.rand()

# Construct minimal arguments
n_samples = 2
n_features = 3

# Create a dense data matrix
Xs_dense = np.random.randn(n_samples, n_features).astype(np.float64)

# Create a sparse version for testing
Xs_sparse = csr_matrix(Xs_dense)

# Target vector
y = np.random.randn(n_samples).astype(np.float64)

# Dual variable
dual_var = np.zeros(n_samples)

# Alpha (regularization parameter)
alpha = 0.1

# Sign of beta
sign_beta = np.ones(n_features)

# Model instance
model = MinimalModel()

ARGS = {
    'Xs': Xs_dense,
    'y': y,
    'dual_var': dual_var,
    'alpha': alpha,
    'sign_beta': sign_beta,
    'dbeta': None,
    'niter_jac': 100,
    'tol_jac': 0.0001,
    'model': model,
    'mask': None,
    'dense': None,
    'verbose': False,
    'use_stop_crit': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (3,) — shape (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
grad_search Ran
ran; our contract draft was wrong, not the code
QB3/sparse-ho/sparse_ho/ho.py
code served (permissive licence) · get_code("fa912386b53aa643")
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 float64, ndim 0, 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)

# Create minimal BaseModel
class BaseModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, X):
        return self.linear(X)

# Create minimal BaseCriterion
class BaseCriterion:
    def get_val_grad(self, model, X, y, log_alpha, compute_beta_grad_fn, tol=1e-3, monitor=None):
        # Returns a tuple of (val, grad)
        val = np.float64(0.5)
        grad = np.float64(0.1)
        return val, grad
    
    def proj_hyperparam(self, model, X, y, log_alpha):
        # Projects hyperparameter, returns log_alpha
        return np.clip(log_alpha, -5.0, 5.0)

# Create minimal BaseAlgo
class BaseAlgo:
    def compute_beta_grad(self, X, y, model, log_alpha):
        # Returns gradient computation
        return np.array([0.1, 0.2])

# Create minimal Optimizer
class Optimizer:
    def _grad_search(self, get_val_grad_fn, proj_hyperparam_fn, log_alpha0, monitor):
        # Simulates gradient search
        log_alpha = log_alpha0
        for _ in range(2):
            val, grad = get_val_grad_fn(log_alpha, tol=1e-3, monitor=monitor)
            log_alpha = proj_hyperparam_fn(log_alpha - 0.01 * grad)
        return log_alpha

# Create minimal Monitor
class Monitor:
    def __init__(self):
        self.values = []
    
    def append(self, value):
        self.values.append(value)

# Create sample data
X = np.random.randn(2, 4).astype(np.float32)
y = np.random.randn(2).astype(np.float32)

ARGS = {
    "algo": BaseAlgo(),
    "criterion": BaseCriterion(),
    "model": BaseModel(),
    "optimizer": Optimizer(),
    "X": X,
    "y": y,
    "alpha0": 1.0,
    "monitor": Monitor(),
}
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 float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
grid_search Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
QB3/sparse-ho/sparse_ho/grid_search.py
code served (permissive licence) · get_code("6ef3689e9b922b04")
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 numpy as np

class SimpleModel:
    """Minimal model for grid_search"""
    pass

class SimpleMonitor:
    """Minimal monitor that tracks times"""
    def __init__(self):
        self.times = []

class SimpleCriterion:
    """Minimal criterion with get_val method"""
    def __init__(self):
        self.call_count = 0
    
    def get_val(self, model, X, y, log_alpha, monitor, tol=1e-5):
        """Returns a synthetic loss value"""
        self.call_count += 1
        # Add a small time to simulate computation
        monitor.times.append(self.call_count * 0.1)
        # Return a synthetic loss that depends on alpha
        return np.exp(log_alpha) + np.random.rand() * 0.1

# Create instances
criterion = SimpleCriterion()
model = SimpleModel()
X = np.random.randn(2, 4)  # 2 samples, 4 features
y = np.random.randn(2)      # 2 targets
alpha_min = 0.001
alpha_max = 10.0
monitor = SimpleMonitor()

ARGS = {
    'criterion': criterion,
    'model': model,
    'X': X,
    'y': y,
    'alpha_min': alpha_min,
    'alpha_max': alpha_max,
    'monitor': monitor,
    'max_evals': 5,
    'tol': 1e-5,
    'nb_hyperparam': 1,
    'random_state': 42,
    'samp': 'grid',
    'alphas': None,
    't_max': 100000,
    'reverse': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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

Also present in other papers' code

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

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

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

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

Abstract

Finding the optimal hyperparameters of a model can be cast as a bilevel optimization problem, typically solved using zero-order techniques. In this work we study first-order methods when the inner optimization problem is convex but non-smooth. We show that the forward-mode differentiation of proximal gradient descent and proximal coordinate descent yield sequences of Jacobians converging toward the exact Jacobian. Using implicit differentiation, we show it is possible to leverage the non-smoothness of the inner problem to speed up the computation. Finally, we provide a bound on the error made on the hypergradient when the inner optimization problem is solved approximately. Results on regression and classification problems reveal computational benefits for hyperparameter optimization, especially when multiple hyperparameters are required.

For agents

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

get_harvested_code_for_paper("2105.01637")
get_code_for_paper("2105.01637")
have("2105.01637")

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

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

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

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

Connect an agent — have() is free.