SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2012.14966 · ICLR · 2020

Kaleidoscope: An Efficient, Learnable Representation For All Structured Linear Maps

Christopher Ré, Nimit Sohoni, Albert Gu, Tri Dao, Matthew Eichhorn, Amit Blonder, Megan Leszczynski, Atri Rudra

arXiv · PDF · Open in the Atlas

Code that ran

16 of 23 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (9 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 9 have no contract verdict; 7 failures of our instrument; 7 no recorded run), 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/2012.14966.json · badge: /api/ran/2012.14966.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
HazyResearch/butterfly marked official in Papers with Code
Papers with Code archive
16 ran · 7 no recorded run
FunctionStatusWhere it lives
BbtMultUntied Ran
ran on a synthesized input · constructed an object; no result was computed
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("3b643a65ec60c95f")
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, BbtMultUntied: 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)

# Mock implementations of the functions referenced in BbtMultUntied
def bbt_multiply_untied(twiddle, input):
    batch_size, nstack, n = input.shape
    return torch.zeros_like(input)

def butterfly_bbs_multiply_untied_forward_fast(twiddle, input):
    batch_size, nstack, n = input.shape
    return torch.zeros_like(input)

def bbt_multiply_untied_forward_backward(twiddle, input, grad):
    d_coefficients = torch.zeros_like(twiddle)
    d_input = torch.zeros_like(input)
    return d_coefficients, d_input

def butterfly_bbs_multiply_untied_forward_backward_fast(twiddle, input, grad):
    d_coefficients = torch.zeros_like(twiddle)
    d_input = torch.zeros_like(input)
    return d_coefficients, d_input

# Construct arguments
# Parameters from docstring:
# twiddle: (nstack, nblocks * 2 * log n, n / 2, 2, 2)
# input: (batch_size, nstack, n)

batch_size = 2
nstack = 3
n = 4
nblocks = 1

# For n=4, log2(n) = 2, so nblocks * 2 * log n = 1 * 2 * 2 = 4
twiddle = torch.randn(nstack, nblocks * 2 * 2, n // 2, 2, 2)
input_tensor = torch.randn(batch_size, nstack, n)

ARGS = {
    'twiddle': twiddle,
    'input': input_tensor,
    'fast': True
}
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 BbtMultUntied — 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 BbtMultUntied 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
BbtOrthoMultUntied Ran
ran on a synthesized input · constructed an object; no result was computed
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("fca125309c2b322a")
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, BbtOrthoMultUntied: 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 math

torch.manual_seed(0)

def bbt_ortho_multiply_untied(twiddle_cos, twiddle_sin, input):
    """Stand-in implementation for the forward multiplication"""
    batch_size, nstack, n = input.shape
    return input * 0.5

def bbt_ortho_multiply_untied_backward(twiddle_cos, twiddle_sin, output, grad):
    """Stand-in implementation for the backward pass"""
    batch_size, nstack, n = grad.shape
    nblocks_times_2_log_n = twiddle_cos.shape[1]
    n_half = twiddle_cos.shape[2]
    
    d_coefficients = torch.randn(nstack, nblocks_times_2_log_n, n_half)
    d_input = grad.clone()
    
    return d_coefficients, d_input

# Setup parameters
batch_size = 2
nstack = 3
n = 4
nblocks_times_2_log_n = 8

# twiddle: (nstack, nblocks * 2 * log n, n / 2)
twiddle = torch.randn(nstack, nblocks_times_2_log_n, n // 2)

# input: (batch_size, nstack, n)
input_tensor = torch.randn(batch_size, nstack, n)

ARGS = {
    'twiddle': twiddle,
    'input': input_tensor
}
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 BbtOrthoMultUntied — 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 BbtOrthoMultUntied 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
ButterflyMult Ran
ran on a synthesized input · constructed an object; no result was computed
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("a4e9c34b65b2f6ad")
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, ButterflyMult: 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)

# Mock functions that are called in the forward/backward passes
def butterfly_multiply_intermediate(twiddle, input, increasing_stride, return_intermediate):
    """Mock implementation that returns output with same shape as input"""
    return input.clone()

def butterfly_multiply_intermediate_backward(grad, twiddle, output_and_intermediate, increasing_stride):
    """Mock implementation that returns gradients"""
    batch_size, nstack, n = grad.shape[:3]
    d_coefficients = torch.zeros_like(twiddle)
    d_input = grad.clone()
    return (d_coefficients, d_input)

# Setup parameters for ButterflyMult
batch_size = 2
nstack = 3
n = 4  # Must be power of 2 for butterfly

# Real-valued case
# twiddle: (nstack, n - 1, 2, 2)
twiddle = torch.randn(nstack, n - 1, 2, 2)

# input: (batch_size, nstack, n)
input_tensor = torch.randn(batch_size, nstack, n)

# increasing_stride flag
increasing_stride = True

ARGS = {
    "twiddle": twiddle,
    "input": input_tensor,
    "increasing_stride": increasing_stride
}
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 ButterflyMult — 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 ButterflyMult 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
ButterflyMultUntied Ran
ran on a synthesized input · constructed an object; no result was computed
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("c51c139065af4d76")
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, ButterflyMultUntied: 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 math

torch.manual_seed(0)

# Parameters for ButterflyMultUntied.forward
# twiddle: (nstack, log n, n / 2, 2, 2) if real
# input: (batch_size, nstack, n) if real
# increasing_stride: bool
# is_training: bool
# fast: bool

batch_size = 2
nstack = 3
n = 4  # small power of 2
log_n = int(math.log2(n))

# Create twiddle tensor: (nstack, log_n, n/2, 2, 2)
twiddle = torch.randn(nstack, log_n, n // 2, 2, 2, dtype=torch.float)

# Create input tensor: (batch_size, nstack, n)
input_tensor = torch.randn(batch_size, nstack, n, dtype=torch.float)

ARGS = {
    'twiddle': twiddle,
    'input': input_tensor,
    'increasing_stride': True,
    'is_training': True,
    'fast': False
}
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 ButterflyMultUntied — 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 ButterflyMultUntied 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
ButterflyOrthoMultTied Ran
ran on a synthesized input · constructed an object; no result was computed
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("1a5d3fd2e0f126ae")
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, ButterflyOrthoMultTied: 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)

def butterfly_ortho_multiply_tied(twiddle_cos, twiddle_sin, input, increasing_stride):
    """Stand-in implementation for the multiply function."""
    batch_size, nstack, n = input.shape
    output = input.clone()
    return output

def butterfly_ortho_multiply_tied_backward(twiddle_cos, twiddle_sin, output, grad, increasing_stride):
    """Stand-in implementation for the backward function."""
    nstack, n_minus_1 = twiddle_cos.shape
    batch_size = grad.shape[0]
    d_coefficients = torch.zeros(nstack, n_minus_1)
    d_input = grad.clone()
    return d_coefficients, d_input

# Create small test tensors
batch_size = 2
nstack = 3
n = 4

twiddle = torch.randn(nstack, n - 1)
input_tensor = torch.randn(batch_size, nstack, n)
increasing_stride = True

ARGS = {
    'twiddle': twiddle,
    'input': input_tensor,
    'increasing_stride': increasing_stride
}
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 ButterflyOrthoMultTied — 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 ButterflyOrthoMultTied 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
ButterflyOrthoMultUntied Ran
ran on a synthesized input · constructed an object; no result was computed
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("73e59bd4741ab79a")
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, ButterflyOrthoMultUntied: 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
import math

torch.manual_seed(0)

def butterfly_ortho_multiply_untied(twiddle_cos, twiddle_sin, input, increasing_stride):
    """Mock implementation of butterfly ortho multiply untied"""
    batch_size, nstack, n = input.shape
    return torch.randn_like(input)

def butterfly_ortho_multiply_untied_backward(twiddle_cos, twiddle_sin, output, grad, increasing_stride):
    """Mock implementation of backward pass"""
    d_coefficients = torch.randn_like(twiddle_cos)
    d_input = torch.randn_like(output)
    return d_coefficients, d_input

# Set up parameters
batch_size = 2
n = 4  # Must be power of 2 for butterfly
log_n = 2  # log2(4)
nstack = 3

# Create twiddle: (nstack, log n, n / 2)
twiddle = torch.randn(nstack, log_n, n // 2)

# Create input: (batch_size, nstack, n)
input_tensor = torch.randn(batch_size, nstack, n)

# increasing_stride parameter
increasing_stride = True

ARGS = {
    'twiddle': twiddle,
    'input': input_tensor,
    'increasing_stride': increasing_stride
}
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 ButterflyOrthoMultUntied — 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 ButterflyOrthoMultUntied 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
ComplexMul Ran
ran on a synthesized input · constructed an object; no result was computed
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("e3dd3b51568b948f")
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, ComplexMul: the run constructed the object and did not call it, so no result was computed. 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 numpy as np

torch.manual_seed(0)

# ComplexMul.forward takes (ctx, X, Y) where X and Y are complex64 tensors
# stored as float32 tensors with last dimension = 2
# The function performs complex multiplication and supports broadcasting

# Create two small complex tensors stored as float32 with last dim = 2
# Shape: (batch=2, features=4, complex_dim=2)
X = torch.randn(2, 4, 2, dtype=torch.float32)
Y = torch.randn(2, 4, 2, dtype=torch.float32)

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
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ComplexMul — 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 ComplexMul 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
Conjugate Ran
ran on a synthesized input · constructed an object; no result was computed
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("8aa8af42641ece9f")
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, Conjugate: the run constructed the object and did not call it, so no result was computed. 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 numpy as np

torch.manual_seed(0)

# The Conjugate class is a torch.autograd.Function subclass
# Its forward method takes X as input
# X must have shape[-1] == 2 (last dimension is 2)
# X is treated as a complex64 tensor stored as float32

# Create a small test tensor with shape (..., 2)
# Using batch size 2, spatial dimensions 3x4 to have distinct sizes
X = torch.randn(2, 3, 4, 2, dtype=torch.float32)

# The Conjugate.apply() method is called, which wraps the forward/backward
# We need to pass X as the only parameter to forward

ARGS = {
    'X': X
}
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 Conjugate — 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 Conjugate 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
ODOMultUntied Ran
ran on a synthesized input · constructed an object; no result was computed
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("981183f0e2853095")
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, ODOMultUntied: 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)

# Mock the fmf module since it's not available
class MockFFT:
    @staticmethod
    def butterfly_odo_multiply_untied_forward_fast(twiddle_cos, twiddle_sin, diag, input):
        # Return a tensor of the same shape as input
        batch_size, nstack, n = input.shape
        return torch.randn(batch_size, nstack, n)
    
    @staticmethod
    def butterfly_odo_multiply_untied_forward_backward_fast(twiddle_cos, twiddle_sin, diag, input, grad):
        # Return gradients with appropriate shapes
        d_coefficients = twiddle_cos.clone()
        d_diag = diag.clone()
        d_input = input.clone()
        return (d_coefficients, d_diag, d_input)

import sys
sys.modules['butterfly_odo_multiply_untied_fast'] = MockFFT()

# Inject mock into the function's namespace
import types
fmf = MockFFT()

# Set up dimensions
batch_size = 2
nstack = 3
n = 4
nblocks = 2
log_n = 2  # log2(4) = 2

# Create twiddle: (nstack, nblocks * 2 * log n, n / 2)
twiddle = torch.randn(nstack, nblocks * 2 * log_n, n // 2)

# Create diag: (nstack, nblocks, n)
diag = torch.randn(nstack, nblocks, n)

# Create input: (batch_size, nstack, n)
input_tensor = torch.randn(batch_size, nstack, n)

ARGS = {
    'twiddle': twiddle,
    'diag': diag,
    'input': input_tensor
}
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 ODOMultUntied — 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 ODOMultUntied 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
butterfly_mult_torch Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("5e9c9a827b90d7d0")
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, 3, 4) as a later run recorded it. 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, 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)

# Parameters for butterfly_mult_torch
batch_size = 2
nstack = 3
n = 4  # must be power of 2
m = int(math.log2(n))

# For real-valued case (input.dim() == 3)
# twiddle: (nstack, n - 1, 2, 2)
twiddle = torch.randn(nstack, n - 1, 2, 2)

# input: (batch_size, nstack, n)
input_real = torch.randn(batch_size, nstack, n)

# For complex case (input.dim() == 4)
# twiddle: (nstack, n - 1, 2, 2, 2)
twiddle_complex = torch.randn(nstack, n - 1, 2, 2, 2)

# input: (batch_size, nstack, n, 2)
input_complex = torch.randn(batch_size, nstack, n, 2)

ARGS = {
    'twiddle': twiddle,
    'input': input_real,
    'increasing_stride': True,
    'return_intermediates': False
}
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 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 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
butterfly_mult_untied_torch Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("82f636e827231da2")
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 4, dtype family float, shape (2, 3, 4, 2) as a later run recorded it. 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, 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
import numpy as np

torch.manual_seed(0)

# Small parameters
batch_size = 2
nstack = 3
n = 4  # power of 2
m = int(math.log2(n))  # m = 2

# Construct twiddle tensor (complex case)
# Shape: (nstack, m, n // 2, 2, 2, 2) for complex
twiddle = torch.randn(nstack, m, n // 2, 2, 2, 2, dtype=torch.float32)

# Construct input tensor (complex case)
# Shape: (batch_size, nstack, n, 2) for complex
input_tensor = torch.randn(batch_size, nstack, n, 2, dtype=torch.float32)

ARGS = {
    "twiddle": twiddle,
    "input": input_tensor,
    "increasing_stride": True,
    "return_intermediates": False
}
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 4, dtype family float, shape (2, 3, 4, 2) — shape (2, 3, 4, 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
complex_mul_torch Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("300fc5df893178c7")
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, 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)

# Create two complex tensors represented as real tensors with last dimension = 2
# X and Y should have shape (..., 2) where the last dimension holds [real, imag]
X = torch.randn(2, 4, 2)  # batch=2, features=4, complex=2
Y = torch.randn(2, 4, 2)  # batch=2, features=4, complex=2

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 Tensor, ndim 3, dtype family float, shape (2, 4, 2) — shape (2, 4, 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
conjugate_torch Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("4eb8f139ff99f805")
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, 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)

# X should be a tensor with last dimension = 2
# The function applies element-wise multiplication with (1, -1) to conjugate complex numbers
# Let's create a small tensor with shape (2, 4, 2) - batch of 2, 4 features, last dim is 2
X = torch.randn(2, 4, 2, dtype=torch.float32)

ARGS = {
    'X': X
}
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, 2) — shape (2, 4, 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
cupy2torch Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("c2200840c1a57682")
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
try:
    import cupy as cp
except ImportError:
    # If cupy is not available, create a mock object that has the toDlpack method
    class MockCupyTensor:
        def __init__(self, torch_tensor):
            self.torch_tensor = torch_tensor
        
        def toDlpack(self):
            from torch.utils.dlpack import to_dlpack
            return to_dlpack(self.torch_tensor)
    
    class cp:
        pass

torch.manual_seed(0)

# Create a small torch tensor
torch_tensor = torch.randn(2, 4)

# Create a cupy-like tensor that has toDlpack method
try:
    # Try with real cupy if available
    cupy_tensor = cp.asarray(torch_tensor.numpy())
except:
    # Fall back to mock
    cupy_tensor = MockCupyTensor(torch_tensor)

ARGS = {
    "tensor": cupy_tensor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cupy, 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
torch2numpy Ran
ran; our contract draft was wrong, not the code
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("76afe345657ec2e7")
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 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
import numpy as np

torch.manual_seed(0)

# The function torch2numpy takes a torch tensor X and converts it to numpy
# It calls X.detach().numpy() on the input
# So X must be a torch tensor (float32 as per docstring)

X = torch.randn(2, 4, dtype=torch.float32)

ARGS = {
    "X": X
}
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 ndarray, 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
twiddle_normal_to_fast_format Ran
ran; our contract draft was wrong, not the code
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("a34cfa6d6cd92765")
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 4, dtype family float, shape (2, 3, 2, 8) 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)

# The function expects twiddle with shape (nstack, log_n, n / 2, 2, 2)
# Let's create a small valid example:
# - nstack = 2 (batch size)
# - n = 8 (so log_n = 3, and n/2 = 4)
# - Shape: (2, 3, 4, 2, 2)

nstack = 2
n = 8
log_n = int(math.log2(n))
twiddle = torch.randn(nstack, log_n, n // 2, 2, 2)

ARGS = {
    "twiddle": twiddle
}
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 4, dtype family float, shape (2, 3, 2, 8) — shape (2, 3, 2, 8) 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
Butterfly Not yet run
unverified (harvested, no recorded run)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("56595d236ed87939")
How it ran

no invocation recorded.

bbt_mult_untied Not yet run
unverified (harvested, no recorded run)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("412f0f9356fe1fd3")
How it ran

no invocation recorded.

bbt_ortho_mult_tied Not yet run
unverified (harvested, no recorded run)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("7b7f6728bc8598c3")
How it ran

no invocation recorded.

bbt_ortho_mult_untied Not yet run
unverified (harvested, no recorded run)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("03a76b8c72275a32")
How it ran

no invocation recorded.

butterfly_ortho_mult_tied Not yet run
unverified (harvested, no recorded run)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("719a1fad21bbecd3")
How it ran

no invocation recorded.

butterfly_ortho_mult_untied Not yet run
unverified (harvested, no recorded run)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("3367888f332b5167")
How it ran

no invocation recorded.

torch2cupy Not yet run
unverified (harvested, no recorded run)
HazyResearch/butterfly/butterfly/butterfly.py
code served (permissive licence) · get_code("93fe676e4bff5eb2")
How it ran

no invocation recorded.

Also present in other papers' code

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

Modern neural network architectures use structured linear transformations, such as low-rank matrices, sparse matrices, permutations, and the Fourier transform, to improve inference speed and reduce memory usage compared to general linear maps. However, choosing which of the myriad structured transformations to use (and its associated parameterization) is a laborious task that requires trading off speed, space, and accuracy. We consider a different approach: we introduce a family of matrices called kaleidoscope matrices (K-matrices) that provably capture any structured matrix with near-optimal space (parameter) and time (arithmetic operation) complexity. We empirically validate that K-matrices can be automatically learned within end-to-end pipelines to replace hand-crafted procedures, in order to improve model quality. For example, replacing channel shuffles in ShuffleNet improves classification accuracy on ImageNet by up to 5%. K-matrices can also simplify hand-engineered pipelines-we replace filter bank feature computation in speech data preprocessing with a learnable kaleidoscope layer, resulting in only 0.4% loss in accuracy on the TIMIT speech recognition task. In addition, K-matrices can capture latent structure in models: for a challenging permuted image classification task, a K-matrix based representation of permutations is able to learn the right latent structure and improves accuracy of a downstream convolutional model by over 9%. We provide a practically efficient implementation of our approach, and use K-matrices in a Transformer network to attain 36% faster end-to-end inference speed on a language translation task.

For agents

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

get_harvested_code_for_paper("2012.14966")
get_code_for_paper("2012.14966")
have("2012.14966")

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

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

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

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

Connect an agent — have() is free.