SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1810.01367 · 2018

FFJORD: Free-form Continuous Dynamics for Scalable Reversible Generative Models

Will Grathwohl, David Duvenaud, Ricky Chen, Ilya Sutskever, Jesse Bettencourt

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 0 failures of our instrument; 1 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/1810.01367.json · badge: /api/ran/1810.01367.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
rtqichen/ffjord community
Papers with Code archive
2 ran · 0 no recorded run
jackgoffinet/ffjord-lite community
Papers with Code archive
2 ran · 0 no recorded run
lenz3000/ffjord-path community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
CNF Ran
ran on a synthesized input · constructed an object; no result was computed
rtqichen/ffjord/lib/layers/cnf.py
code served (permissive licence) · get_code("95a9c83deee45d05")
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 an instance of its own class, CNF: the run constructed the object and did not call it, so no result was computed. 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 minimal ODE function that implements the required interface
class MinimalODEFunc(nn.Module):
    def __init__(self):
        super(MinimalODEFunc, self).__init__()
        self._num_evals = torch.tensor(0)
        self.linear = nn.Linear(4, 4)
    
    def before_odeint(self, *args, **kwargs):
        pass
    
    def forward(self, t, state):
        # state is (x, logp) tuple
        x, logp = state[:2]
        batch_size = x.shape[0]
        # Return derivatives for x and logp
        dx = self.linear(x)
        dlogp = torch.zeros(batch_size, 1, device=x.device)
        return (dx, dlogp)

# Create a minimal regularization function
def minimal_regularization_fn(x, logp, dx, dlogp, context):
    # Return a regularization state (scalar tensor)
    return torch.tensor(0.0, device=x.device)

# Instantiate the ODE function
odefunc = MinimalODEFunc()

# Create ARGS dictionary with all parameters
ARGS = {
    'odefunc': odefunc,
    'T': 1.0,
    'train_T': False,
    'regularization_fns': None,
    'solver': 'dopri5',
    'atol': 1e-05,
    'rtol': 1e-05
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchdiffeq — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type CNF — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a CNF 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
FfjordModel Ran
ran on a synthesized input
jackgoffinet/ffjord-lite/script.py
code served (permissive licence) · get_code("cc866c798f64c000")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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
import torch.nn.functional as F
from torchdiffeq import odeint_adjoint as odeint

Z_DIM = 2

def _flip(x, dim):
    indices = [slice(None)] * x.dim()
    indices[dim] = torch.arange(x.size(dim) - 1, -1, -1, dtype=torch.long, device=x.device)
    return x[tuple(indices)]

device = torch.device('cpu')

class ODEfunc(nn.Module):
    """
    Calculates time derivatives.

    torchdiffeq requires this to be a torch.nn.Module.
    """

    def __init__(self, hidden_dims=(64, 64)):
        super(ODEfunc, self).__init__()
        dim_list = [Z_DIM] + list(hidden_dims) + [Z_DIM]
        layers = []
        for i in range(len(dim_list) - 1):
            layers.append(nn.Linear(dim_list[i] + 1, dim_list[i + 1]))
        self.layers = nn.ModuleList(layers)

    def get_z_dot(self, t, z):
        """z_dot is parameterized by a NN: z_dot = NN(t, z(t))"""
        z_dot = z
        for l, layer in enumerate(self.layers):
            tz_cat = torch.cat((t.expand(z.shape[0], 1), z_dot), dim=1)
            z_dot = layer(tz_cat)
            if l < len(self.layers) - 1:
                z_dot = F.softplus(z_dot)
        return z_dot

    def forward(self, t, states):
        """
        Calculate the time derivative of z and divergence.

        Parameters
        ----------
        t : torch.Tensor
            time
        state : tuple
            Contains two torch.Tensors: z and delta_logpz

        Returns
        -------
        z_dot : torch.Tensor
            Time derivative of z.
        negative_divergence : torch.Tensor
            Time derivative of the log determinant of the Jacobian.
        """
        z = states[0]
        batchsize = z.shape[0]
        with torch.set_grad_enabled(True):
            z.requires_grad_(True)
            t.requires_grad_(True)
            z_dot = self.get_z_dot(t, z)
            divergence = 0.0
            for i in range(z.shape[1]):
                divergence += torch.autograd.grad(z_dot[:, i].sum(), z, create_graph=True)[0][:, i]
        return (z_dot, -divergence.view(batchsize, 1))


class FfjordModel(torch.nn.Module):
    """Continuous normalizing flow model."""

    def __init__(self):
        super(FfjordModel, self).__init__()
        self.time_deriv_func = ODEfunc()

    def save_state(self, fn='state.tar'):
        """Save model state."""
        torch.save(self.state_dict(), fn)

    def load_state(self, fn='state.tar'):
        """Load model state."""
        self.load_state_dict(torch.load(fn))

    def forward(self, z, delta_logpz=None, integration_times=None, reverse=False):
        """
        Implementation of Eq. 4.

        We want to integrate both f and the trace term. During training, we
        integrate from t_1 (data distribution) to t_0 (base distribution).

        Parameters
        ----------
        z : torch.Tensor
            Samples.
        delta_logpz : torch.Tensor
            Log determinant of the Jacobian.
        integration_times : torch.Tensor
            Which times to evaluate at.
        reverse : bool, optional
            Whether to reverse the integration times.

        Returns
        -------
        z : torch.Tensor
            Updated samples.
        delta_logpz : torch.Tensor
            Updated log determinant term.
        """
        if delta_logpz is None:
            delta_logpz = torch.zeros(z.shape[0], 1).to(device)
        if integration_times is None:
            integration_times = torch.tensor([0.0, 1.0]).to(z)
        if reverse:
            integration_times = _flip(integration_times, 0)
        state = odeint(self.time_deriv_func, (z, delta_logpz), integration_times, method='dopri5', atol=[1e-05, 1e-05], rtol=[1e-05, 1e-05])
        if len(integration_times) == 2:
            state = tuple((s[1] for s in state))
        z, delta_logpz = state
        return (z, delta_logpz)


INIT_ARGS = {}

ARGS = {
    'z': torch.randn(2, 2),
    'delta_logpz': torch.zeros(2, 1),
    'integration_times': torch.tensor([0.0, 1.0]),
    'reverse': False,
}

if __name__ == '__main__':
    model = FfjordModel(**INIT_ARGS)
    z_out, delta_logpz_out = model(**ARGS)
    print("Output z shape:", z_out.shape)
    print("Output delta_logpz shape:", delta_logpz_out.shape)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch, torchdiffeq — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
ODEfunc Ran
ran on a synthesized input
jackgoffinet/ffjord-lite/script.py
code served (permissive licence) · get_code("bc4c9f15c07b078a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. 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
import torch.nn.functional as F

Z_DIM = 2

class ODEfunc(nn.Module):
    """
	Calculates time derivatives.

	torchdiffeq requires this to be a torch.nn.Module.
	"""

    def __init__(self, hidden_dims=(64, 64)):
        super(ODEfunc, self).__init__()
        dim_list = [Z_DIM] + list(hidden_dims) + [Z_DIM]
        layers = []
        for i in range(len(dim_list) - 1):
            layers.append(nn.Linear(dim_list[i] + 1, dim_list[i + 1]))
        self.layers = nn.ModuleList(layers)

    def get_z_dot(self, t, z):
        """z_dot is parameterized by a NN: z_dot = NN(t, z(t))"""
        z_dot = z
        for l, layer in enumerate(self.layers):
            tz_cat = torch.cat((t.expand(z.shape[0], 1), z_dot), dim=1)
            z_dot = layer(tz_cat)
            if l < len(self.layers) - 1:
                z_dot = F.softplus(z_dot)
        return z_dot

    def forward(self, t, states):
        """
		Calculate the time derivative of z and divergence.

		Parameters
		----------
		t : torch.Tensor
			time
		state : tuple
			Contains two torch.Tensors: z and delta_logpz

		Returns
		-------
		z_dot : torch.Tensor
			Time derivative of z.
		negative_divergence : torch.Tensor
			Time derivative of the log determinant of the Jacobian.
		"""
        z = states[0]
        batchsize = z.shape[0]
        with torch.set_grad_enabled(True):
            z.requires_grad_(True)
            t.requires_grad_(True)
            z_dot = self.get_z_dot(t, z)
            divergence = 0.0
            for i in range(z.shape[1]):
                divergence += torch.autograd.grad(z_dot[:, i].sum(), z, create_graph=True)[0][:, i]
        return (z_dot, -divergence.view(batchsize, 1))


INIT_ARGS = {
    "hidden_dims": (16, 16)
}

ARGS = {
    "t": torch.tensor([0.5]),
    "states": (torch.randn(2, 2),)
}

if __name__ == "__main__":
    model = ODEfunc(**INIT_ARGS)
    output = model(**ARGS)
    print("Output shapes:")
    print(f"  z_dot: {output[0].shape}")
    print(f"  negative_divergence: {output[1].shape}")
    print("Success!")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
RegularizedODEfunc Ran
ran on a synthesized input · constructed an object; no result was computed
rtqichen/ffjord/lib/layers/cnf.py
code served (permissive licence) · get_code("846f94d3f2e1378b")
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 an instance of its own class, RegularizedODEfunc: the run constructed the object and did not call it, so no result was computed. 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 ODE function that the RegularizedODEfunc wraps
class SimpleODEFunc(nn.Module):
    def __init__(self):
        super(SimpleODEFunc, self).__init__()
        self._num_evals = 0
        self.linear = nn.Linear(4, 4)
    
    def before_odeint(self, *args, **kwargs):
        pass
    
    def forward(self, t, state):
        x, logp = state
        # Return derivatives for x and logp
        dx = self.linear(x)
        dlogp = torch.zeros_like(logp)
        return (dx, dlogp)

odefunc = SimpleODEFunc()

# Create regularization functions
# Each regularization function takes (x, logp, dx, dlogp, context) and returns a regularization term
def reg_fn_1(x, logp, dx, dlogp, context):
    # Return a regularization term with same shape as dx
    return torch.zeros_like(dx) * 0.01

def reg_fn_2(x, logp, dx, dlogp, context):
    # Return a regularization term with same shape as dlogp
    return torch.zeros_like(dlogp) * 0.01

regularization_fns = [reg_fn_1, reg_fn_2]

ARGS = {
    "odefunc": odefunc,
    "regularization_fns": regularization_fns,
}
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 RegularizedODEfunc — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a RegularizedODEfunc 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
ODEfunc Not yet run
unverified (harvested, no recorded run)
lenz3000/ffjord-path/lib/layers/odefunc.py
code served (permissive licence) · get_code("def28b9e7df60464")
How it ran

no invocation recorded.

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

A promising class of generative models maps points from a simple distribution to a complex distribution through an invertible neural network. Likelihood-based training of these models requires restricting their architectures to allow cheap computation of Jacobian determinants. Alternatively, the Jacobian trace can be used if the transformation is specified by an ordinary differential equation. In this paper, we use Hutchinson's trace estimator to give a scalable unbiased estimate of the log-density. The result is a continuous-time invertible generative model with unbiased density estimation and one-pass sampling, while allowing unrestricted neural network architectures. We demonstrate our approach on high-dimensional density estimation, image generation, and variational inference, achieving the state-of-the-art among exact likelihood methods with efficient sampling.

For agents

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

get_harvested_code_for_paper("1810.01367")
get_code_for_paper("1810.01367")
have("1810.01367")

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

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

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

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

Connect an agent — have() is free.