SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2408.10419 · 2024

Second-Order Forward-Mode Automatic Differentiation for Optimization

arXiv · PDF · Open in the Atlas

Code that ran

10 of 10 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; 2 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 8 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/2408.10419.json · badge: /api/ran/2408.10419.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
sri-csl/fomoh canonical (classifier label)
classifier basis: census
10 ran · 0 no recorded run
FunctionStatusWhere it lives
calculate_output_shape Ran
ran; our contract draft was wrong, not the code
sri-csl/fomoh/src/fomoh/util.py
code served (permissive licence) · get_code("03c4d3b2fd4d59f6")
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

torch.manual_seed(0)

# X and Y are torch tensors used in matrix multiplication
# The function checks dimensions and computes output shape for batched matrix multiplication
# X needs at least 2 dimensions: (..., m, n)
# Y needs at least 2 dimensions: (..., n, p)
# where the inner dimension n matches (X.size(-1) == Y.size(-2))

# Create X with shape (2, 4, 5) - batch_size=2, m=4, inner_dim=5
X = torch.randn(2, 4, 5)

# Create Y with shape (2, 5, 3) - batch_size=2, inner_dim=5, p=3
# The inner dimensions must match: X.size(-1) = 5, Y.size(-2) = 5
Y = torch.randn(2, 5, 3)

ARGS = {
    'X': X,
    'Y': Y
}
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 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_d2Z_dT1T2 Ran
ran; our contract draft was wrong, not the code
sri-csl/fomoh/src/fomoh/util.py
code served (permissive licence) · get_code("13430b547d6472d9")
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 3, dtype family float, shape (2, 4, 5) 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)

# Define small tensors for X and Y with compatible dimensions
# X: (batch, m, n) where m=4, n=3
# Y: (batch, n, p) where n=3, p=5
# This allows matmul(X, Y) to work

X = torch.randn(2, 4, 3)
Y = torch.randn(2, 3, 5)

# X_eps1: same shape as X for first-order derivative
X_eps1 = torch.randn(2, 4, 3)

# X_eps2: same shape as X for second first-order derivative
X_eps2 = torch.randn(2, 4, 3)

# Y_eps1: same shape as Y for first-order derivative
Y_eps1 = torch.randn(2, 3, 5)

# Y_eps2: same shape as Y for second first-order derivative
Y_eps2 = torch.randn(2, 3, 5)

# d2X_dTT: second derivative of X, shape (batch, m, n)
d2X_dTT = torch.randn(2, 4, 3)

# d2Y_dTT: second derivative of Y, shape (batch, n, p)
d2Y_dTT = torch.randn(2, 3, 5)

ARGS = {
    'X': X,
    'Y': Y,
    'X_eps1': X_eps1,
    'X_eps2': X_eps2,
    'Y_eps1': Y_eps1,
    'Y_eps2': Y_eps2,
    'd2X_dTT': d2X_dTT,
    'd2Y_dTT': d2Y_dTT,
}
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 3, dtype family float, shape (2, 4, 5) — shape (2, 4, 5) 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_dZ_dT Ran
ran; our contract draft was wrong, not the code
sri-csl/fomoh/src/fomoh/util.py
code served (permissive licence) · get_code("5c67ce0d094b0545")
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 3, dtype family float, shape (2, 4, 5) 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)

# X: shape (batch, m, n) where n is the shared inner dimension
# Y: shape (batch, n, p) where n is the shared inner dimension
# Result Z will be (batch, m, p)

X = torch.randn(2, 4, 3)  # batch=2, m=4, n=3
Y = torch.randn(2, 3, 5)  # batch=2, n=3, p=5

# dX_dT: derivative of X with respect to T, same shape as X
dX_dT = torch.randn(2, 4, 3)

# dY_dT: derivative of Y with respect to T, same shape as Y
dY_dT = torch.randn(2, 3, 5)

ARGS = {
    "X": X,
    "Y": Y,
    "dX_dT": dX_dT,
    "dY_dT": dY_dT,
}
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 3, dtype family float, shape (2, 4, 5) — shape (2, 4, 5) 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
init_bias Ran
ran, honoured the contract we drafted
sri-csl/fomoh/src/fomoh/layers.py
code served (permissive licence) · get_code("83f36c715570b676")
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 1, dtype family float, shape (16,) 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 math

torch.manual_seed(0)

ARGS = {
    "out_features": 16
}
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 1, dtype family float, shape (16,) — shape (16,) 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
init_kaiming Ran
ran, honoured the contract we drafted
sri-csl/fomoh/src/fomoh/layers.py
code served (permissive licence) · get_code("aeb04885a2579d96")
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 2, dtype family float, shape (4, 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 torch
import math

torch.manual_seed(0)

ARGS = {
    "in_features": 4,
    "out_features": 3,
}
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 2, dtype family float, shape (4, 3) — shape (4, 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
init_uniform Ran
ran; our contract draft was wrong, not the code
sri-csl/fomoh/src/fomoh/layers.py
code served (permissive licence) · get_code("38ee06cbca66bf07")
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 2, dtype family float, shape (2, 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

torch.manual_seed(0)

ARGS = {
    "shape": (2, 4),
    "k": 0.5
}
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 2, dtype family float, shape (2, 4) — shape (2, 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
make_tensor Ran
ran; our contract draft was wrong, not the code
sri-csl/fomoh/src/fomoh/hyperdual.py
code served (permissive licence) · get_code("e60ee540637c5ca4")
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 2, dtype family float, shape (2, 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

torch.manual_seed(0)

# Test case 1: Pass a tensor
tensor_obj = torch.randn(2, 4)

# Test case 2: Pass None
none_obj = None

# Test case 3: Pass a list that can be converted to tensor
list_obj = [[1, 2, 3, 4], [5, 6, 7, 8]]

# Test case 4: Pass a numpy array
import numpy as np
numpy_obj = np.array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]])

# Define ARGS with a tensor as the primary test case
ARGS = {
    'obj': tensor_obj,
    'device': 'cpu'
}
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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 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
mean Ran
ran; our contract draft was wrong, not the code
sri-csl/fomoh/src/fomoh/nn.py
code served (permissive licence) · get_code("68aa86b28a69f9b3")
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 2, dtype family float, shape (2, 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 torch

torch.manual_seed(0)

# Create a small tensor with distinct dimensions
a = torch.randn(2, 4, 3)

# dim parameter - reduce along dimension 1
dim = 1

# keepdim parameter - don't keep the dimension
keepdim = False

ARGS = {
    "a": a,
    "dim": dim,
    "keepdim": keepdim,
}
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 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
nll_loss Ran
ran; our contract draft was wrong, not the code
sri-csl/fomoh/src/fomoh/nn.py
code served (permissive licence) · get_code("f3958881d36885b5")
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 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

torch.manual_seed(0)

# Construct valid arguments for nll_loss function
# The function expects:
# - input: 2D (n, c) or 3D (batch_size, n, c) tensor of log probabilities
# - target: 1D or 2D tensor of class indices
# - reduce: string for reduction method
# - ignore_index: optional index to ignore

# Create a batched example (3D input)
batch_size = 2
n = 4  # sequence length
c = 3  # number of classes

# input should be log probabilities: shape (batch_size, n, c)
input_tensor = torch.randn(batch_size, n, c, requires_grad=False)

# target should contain class indices: shape (batch_size, n)
# Values should be in range [0, c)
target_tensor = torch.randint(0, c, (batch_size, n))

ARGS = {
    'input': input_tensor,
    'target': target_tensor,
    'reduce': 'mean',
    'ignore_index': None
}
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 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
nll_loss_old Ran
ran; our contract draft was wrong, not the code
sri-csl/fomoh/src/fomoh/nn.py
code served (permissive licence) · get_code("f5019e843d4e2762")
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 nn

torch.manual_seed(0)

# The function expects:
# - input: a tensor with .real attribute and .dim() method, shape [n, c] where n is batch size, c is num classes
# - target: a tensor with .real attribute and .dim() method, shape [n] containing class indices
# - reduce: a string, either 'mean' or other value

# Create input tensor: shape [2, 4] - batch size 2, num classes 4
# Complex tensor so .real works
input_tensor = torch.complex(
    torch.randn(2, 4),
    torch.randn(2, 4)
)

# Create target tensor: shape [2] - batch size 2, containing class indices
# Use indices within valid range [0, 3]
target_tensor = torch.complex(
    torch.tensor([1.0, 2.0]),
    torch.zeros(2)
)

ARGS = {
    'input': input_tensor,
    'target': target_tensor,
    'reduce': 'mean'
}
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

Also present in other papers' code

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

This paper introduces a second-order hyperplane search, a novel optimization step that generalizes a second-order line search from a line to a $k$-dimensional hyperplane. This, combined with the forward-mode stochastic gradient method, yields a second-order optimization algorithm that consists of forward passes only, completely avoiding the storage overhead of backpropagation. Unlike recent work that relies on directional derivatives (or Jacobian--Vector Products, JVPs), we use hyper-dual numbers to jointly evaluate both directional derivatives and their second-order quadratic terms. As a result, we introduce forward-mode weight perturbation with Hessian information (FoMoH). We then use FoMoH to develop a novel generalization of line search by extending it to a hyperplane search. We illustrate the utility of this extension and how it might be used to overcome some of the recent challenges of optimizing machine learning models without backpropagation. Our code is open-sourced at https://github.com/SRI-CSL/fomoh.

For agents

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

get_harvested_code_for_paper("2408.10419")
get_code_for_paper("2408.10419")
have("2408.10419")

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

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

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

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

Connect an agent — have() is free.