SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2506.00385 · 2025

MagiCodec: Simple Masked Gaussian-Injected Codec for High-Fidelity Reconstruction and Generation

Xie Chen, Zhuo Chen, Yuping Wang, Yuxuan Wang, Jiawei Chen, Jian Wu, Yakun Song, Ziyang Ma, Dongya Jia, Chenpeng Du, Jian Cong, Xiaobin Zhuang

arXiv · PDF · Open in the Atlas

Code that ran

8 of 8 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, 1 violated it and 6 have no contract verdict; 1 failure of our instrument; 0 no recorded run), measured 2026-11-23; 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/2506.00385.json · badge: /api/ran/2506.00385.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
Ereboas/MagiCodec canonical (classifier label)
classifier basis not recorded on the link
8 ran · 0 no recorded run
FunctionStatusWhere it lives
bias_gelu Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Ereboas/MagiCodec/components/ops/activations.py
code served (permissive licence) · get_code("0bda6e53e10d00b2")
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; 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)

# The function bias_gelu takes two tensor arguments: y and bias
# It adds bias to y, then applies a GELU activation using tanh approximation
# Both y and bias need to be tensors that support addition and dtype conversion

y = torch.randn(2, 4)
bias = torch.randn(2, 4)

ARGS = {
    "y": y,
    "bias": bias,
}
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 — no output shape is stated: observe_signature.py could not observe it (import:OSError)
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
bias_gelu_back Ran
ran on a synthesized input
Ereboas/MagiCodec/components/ops/activations.py
code served (permissive licence) · get_code("06a68b038a2bc78d")
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. 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

torch.manual_seed(0)

# The function expects:
# g: gradient tensor with shape (B, D)
# y: output tensor with shape (B, D)
# bias: bias tensor with shape (D,)

B = 2  # batch size
D = 4  # dimension

g = torch.randn(B, D, dtype=torch.float32)
y = torch.randn(B, D, dtype=torch.float32)
bias = torch.randn(D, dtype=torch.float32)

ARGS = {
    "g": g,
    "y": y,
    "bias": bias,
}
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 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: none by the harness; any seed is in the setup block
maybe_contiguous Ran
ran on a synthesized input
Ereboas/MagiCodec/components/ops/flash_attn_2_3_interface.py
code served (permissive licence) · get_code("58e6542897e7d424")
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, 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)

# The function checks if x.stride(-1) == 1, and calls x.contiguous() if not
# So x must be a torch.Tensor with stride and contiguous methods

# Create a non-contiguous tensor by transposing
x = torch.randn(2, 4).t()  # Shape (4, 2), and transposed tensors are non-contiguous
# Verify it's non-contiguous
assert x.stride(-1) != 1, "Tensor should be non-contiguous for testing"

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 2, dtype family float, shape (4, 2) — shape (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
modulate Ran
ran on a synthesized input
Ereboas/MagiCodec/components/block.py
code served (permissive licence) · get_code("9da99d54baee61a5")
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)

# Create small tensors with distinct shapes for clarity
# x: (batch=2, dim=4) - the input to be modulated
x = torch.randn(2, 4)

# shift: needs to be squeezable to (4,) after squeeze(0)
# So it should have shape (1, 4) or similar
shift = torch.randn(1, 4)

# scale: needs to be squeezable to (4,) after squeeze(0)
# So it should have shape (1, 4) or similar
scale = torch.randn(1, 4)

ARGS = {
    "x": x,
    "shift": shift,
    "scale": scale,
}
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
new_gelu Ran
ran on a synthesized input
Ereboas/MagiCodec/components/ops/activations.py
code served (permissive licence) · get_code("9112633659fb264d")
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; 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 math

torch.manual_seed(0)

# The function new_gelu takes a single parameter 'x' which should be a tensor
# It performs operations: multiplication, addition, tanh, pow
# So x needs to be a torch.Tensor that supports these operations

x = torch.randn(2, 4)

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 2, dtype family float — no output shape is stated: observe_signature.py could not observe it (import:OSError)
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
pad_input Ran
ran on a synthesized input
Ereboas/MagiCodec/components/ops/padding.py
code served (permissive licence) · get_code("3c9fe8b8927b497e")
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. 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
from einops import rearrange, repeat

torch.manual_seed(0)

# Parameters for pad_input function
batch = 2
seqlen = 3
hidden_dim = 4

# total_nnz represents the number of selected tokens (must be <= batch * seqlen)
total_nnz = 4

# hidden_states: (total_nnz, hidden_dim)
hidden_states = torch.randn(total_nnz, hidden_dim)

# indices: (total_nnz,) - indices into the flattened (batch, seqlen) space
# Values should be in range [0, batch*seqlen)
indices = torch.tensor([0, 2, 3, 5], dtype=torch.long)

ARGS = {
    "hidden_states": hidden_states,
    "indices": indices,
    "batch": batch,
    "seqlen": seqlen,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, 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
precompute_freqs_cis Ran
ran, violated the contract we drafted
Ereboas/MagiCodec/roformer.py
pointer only (licence: MIT); the stored copy get_code serves, from meituan-automl/visionllama, is pointer only (licence: NONE) · get_code("14a84c2cbfebc413")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from meituan-automl/visionllama, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

unpad_input Ran
ran on a synthesized input
Ereboas/MagiCodec/components/ops/padding.py
code served (permissive licence) · get_code("b4ca9ddf6b6d4cad")
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. 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.functional as F
from einops import rearrange, repeat

torch.manual_seed(0)

# Create small tensors for testing
batch_size = 2
seq_len = 3
hidden_dim = 4

# hidden_states: (batch, seqlen, hidden_dim)
hidden_states = torch.randn(batch_size, seq_len, hidden_dim)

# attention_mask: (batch, seqlen), bool tensor where 1 means valid
# Create a mask that selects some tokens
attention_mask = torch.tensor([
    [True, False, True],   # batch 0: select positions 0 and 2
    [True, True, False]    # batch 1: select positions 0 and 1
], dtype=torch.bool)

ARGS = {
    "hidden_states": hidden_states,
    "attention_mask": attention_mask
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, 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: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 1 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.

FunctionAlso present inEarliest-datedOthers named
precompute_freqs_cis 47 other papers
43 dated earlier, 3 later, 1 same year, order not determinable · 1 only as an assembly brick
2023.emnlp-main.534 (2023 (year only))
Disentangling Transformer Language Models as Superposed Topic Models
2303.09736 (2023-03)
Dynamic Structure Pruning for Compressing CNNs
2307.09288 (2023-07)
Llama 2: Open Foundation and Fine-Tuned Chat Models
and 44 more not named here
maybe_contiguous 2 other papers
2 dated earlier
2502.17421 (2025-02)
LongSpec: Long-Context Lossless Speculative Decoding with Efficient Drafting and Verification
2503.02130 (2025-03)
Forgetting Transformer: Softmax Attention with a Forget Gate
bias_gelu 1 other paper
1 dated earlier
2406.02528 (2024-06)
Scalable MatMul-free Language Modeling

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-23.

Repositories linked to this paper

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

Abstract

Neural audio codecs have made significant strides in efficiently mapping raw audio waveforms into discrete token representations, which are foundational for contemporary audio generative models. However, most existing codecs are optimized primarily for reconstruction quality, often at the expense of the downstream modelability of the encoded tokens. Motivated by the need to overcome this bottleneck, we introduce MagiCodec, a novel single-layer, streaming Transformer-based audio codec. MagiCodec is designed with a multistage training pipeline that incorporates Gaussian noise injection and latent regularization, explicitly targeting the enhancement of semantic expressiveness in the generated codes while preserving high reconstruction fidelity. We analytically derive the effect of noise injection in the frequency domain, demonstrating its efficacy in attenuating high-frequency components and fostering robust tokenization. Extensive experimental evaluations show that MagiCodec surpasses state-of-the-art codecs in both reconstruction quality and downstream tasks. Notably, the tokens produced by MagiCodec exhibit Zipf-like distributions, as observed in natural languages, thereby improving compatibility with language-model-based generative architectures. The code and pre-trained models are available at https://github.com/Ereboas/MagiCodec.

For agents

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

get_harvested_code_for_paper("2506.00385")
get_code_for_paper("2506.00385")
have("2506.00385")

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

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

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

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

Connect an agent — have() is free.