SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2605.11396 · 2026

MuonQ: Enhancing Low-Bit Muon Quantization via Directional Fidelity Optimization

Zheng Zhang, Yequan Zhao, Ziyue Liu, Ruijie Zhang, Yupeng Su

arXiv · PDF · Open in the Atlas

Code that ran

10 of 15 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 7 failures of our instrument; 5 no recorded run), measured 2026-11-23; 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/2605.11396.json · badge: /api/ran/2605.11396.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
YupengSu/MuonQ canonical (classifier label)
classifier basis: census
10 ran · 5 no recorded run
FunctionStatusWhere it lives
apply_rope Ran
ran; our contract draft was wrong, not the code
YupengSu/MuonQ/src/models.py
code served (permissive licence) · get_code("25e9d5a6a1f48f0f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 5, 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)

# Construct tensors according to function signature and docstring
# q, k: (B, nh, T, hs) where B=batch, nh=num_heads, T=sequence_length, hs=head_size
# cos, sin: (1, 1, T, hs) broadcastable to q/k

B = 2      # batch size
nh = 3     # number of heads
T = 5      # sequence length
hs = 4     # head size

q = torch.randn(B, nh, T, hs)
k = torch.randn(B, nh, T, hs)
cos = torch.randn(1, 1, T, hs)
sin = torch.randn(1, 1, T, hs)

ARGS = {
    "q": q,
    "k": k,
    "cos": cos,
    "sin": sin
}
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, ndim 5, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_dotenv_required Ran
ran; our contract draft was wrong, not the code
YupengSu/MuonQ/src/env.py
code served (permissive licence) · get_code("f56ee8827f787d5a")
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 dict. 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 os
import tempfile
from pathlib import Path

# Create a temporary directory for testing
temp_dir = tempfile.mkdtemp()
temp_env_path = Path(temp_dir) / '.env'

# Write a sample .env file with required keys
env_content = """
# Sample environment file
export DATABASE_URL=postgresql://localhost/mydb
API_KEY=secret_key_123
DEBUG=true
# This is a comment
ANOTHER_VAR="quoted_value"
"""

temp_env_path.write_text(env_content)

# Define the arguments for load_dotenv_required
ARGS = {
    'required_keys': ['DATABASE_URL', 'API_KEY', 'DEBUG'],
    'env_path': str(temp_env_path)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
mu_law_compress Ran
ran; our contract draft was wrong, not the code
YupengSu/MuonQ/src/quantize.py
code served (permissive licence) · get_code("b9bb928d4ea01c64")
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
import math

torch.manual_seed(0)

# The function takes a single parameter 'x' which should be a tensor
# The function clamps it, computes absolute value, sign, and applies log1p
# So x should be a float tensor with values in a reasonable range

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, 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
mu_law_expand Ran
ran; our contract draft was wrong, not the code
YupengSu/MuonQ/src/quantize.py
code served (permissive licence) · get_code("7c723adc90909d53")
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
import math

torch.manual_seed(0)

# Construct a small tensor for the function
# mu_law_expand expects a tensor y and performs operations:
# - y.abs()
# - y.sign()
# - torch.expm1()
# The function works element-wise, so any shape works
y = torch.randn(2, 4)

ARGS = {
    "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 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
muon_state_bytes Ran
ran, honoured the contract we drafted
YupengSu/MuonQ/src/train_distributed.py
code served (permissive licence) · get_code("b6c9612e8185cb15")
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 int, ndim 0, dtype family int, 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.optim as optim

torch.manual_seed(0)

class SimpleModel(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = torch.nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

model = SimpleModel()
optimizer = optim.SGD(model.parameters(), lr=0.01)

# Simulate some optimizer state with muon-specific entries
param = model.parameters().__next__()
optimizer.state[param] = {
    'use_muon': True,
    'tensor1': torch.randn(2, 4),
    'tensor2': torch.randn(3, 5),
    'nested': {
        'tensor3': torch.randn(2, 2),
        'list_of_tensors': [torch.randn(1, 3), torch.randn(2, 1)]
    }
}

# Add another param without muon
param2 = list(model.parameters())[1]
optimizer.state[param2] = {
    'use_muon': False,
    'tensor4': torch.randn(4, 4)
}

# Add a third param with muon and some tensors
param3 = torch.nn.Parameter(torch.randn(5, 2))
optimizer.state[param3] = {
    'use_muon': True,
    'tensor5': torch.randn(3, 3),
    'tuple_tensors': (torch.randn(2, 2), torch.randn(1, 4))
}

ARGS = {
    'optimizer': optimizer
}
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 int, ndim 0, dtype family int, 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
nested_tensor_bytes_dedup Ran
ran, honoured the contract we drafted
YupengSu/MuonQ/src/train_distributed.py
code served (permissive licence) · get_code("d28738690ca516ef")
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 int, ndim 0, dtype family int, 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

torch.manual_seed(0)

# The function recursively processes nested structures (dicts, lists, tuples)
# containing torch tensors. It tracks unique tensor storage by (data_ptr, nbytes)
# and returns total bytes of deduplicated storage.

# Create some test tensors
tensor1 = torch.randn(2, 4)
tensor2 = torch.randn(3, 5)
tensor3 = tensor1  # Same tensor, will be deduplicated

# Create a nested structure with tensors
obj = {
    'a': tensor1,
    'b': {
        'c': tensor2,
        'd': tensor3,  # Duplicate of tensor1
    },
    'e': [tensor1, tensor2],  # More duplicates
    'f': (tensor3, tensor2),  # Tuple with duplicates
}

ARGS = {
    'obj': obj,
    'seen': 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 int, ndim 0, dtype family int, 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
repeat_kv Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
YupengSu/MuonQ/src/models.py
code served (permissive licence) · get_code("7140f5aa8cd118f3")
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, 6, 5, 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)

# hidden_states: torch.Tensor with shape (B, num_kv_heads, T, head_dim)
# n_rep: int - number of repetitions for grouped-query attention expansion

hidden_states = torch.randn(2, 3, 5, 4)  # B=2, num_kv_heads=3, T=5, head_dim=4
n_rep = 2

ARGS = {
    "hidden_states": hidden_states,
    "n_rep": n_rep,
}
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, 6, 5, 4) — shape (2, 6, 5, 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
rotate_half Ran
ran; our contract draft was wrong, not the code
YupengSu/MuonQ/src/models.py
code served (permissive licence) · get_code("986643c1063af44b")
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)

# The function rotate_half takes a tensor x and rotates its last dimension
# by splitting it in half and swapping the halves with a sign change
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, 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
stochastic_round Ran
ran; our contract draft was wrong, not the code
YupengSu/MuonQ/src/quantize.py
code served (permissive licence) · get_code("3875f410cca8160e")
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 a small tensor with floating point values for stochastic rounding
# Using values between 0 and 1 with fractional parts for meaningful rounding
z = torch.tensor([[0.3, 0.7, 0.2, 0.9],
                   [0.5, 0.1, 0.8, 0.4]], dtype=torch.float32)

ARGS = {
    "z": z
}
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
tokenize Ran
ran, honoured the contract we drafted
YupengSu/MuonQ/src/data_utils.py
code served (permissive licence) · get_code("55ccea02961066a2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 1, dtype family int, shape (4,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

class MockEncoderWithSpecialTokens:
    def __init__(self):
        self._special_tokens = {'<|endoftext|>': 50256}
    
    def encode_ordinary(self, text):
        # Return a small list of token ids (all valid, < 2^16)
        return [100, 101, 102]

class MockEncoderWithEosToken:
    def __init__(self):
        self.eos_token_id = 50256
    
    def encode(self, text, add_special_tokens=False):
        # Return a small list of token ids (all valid, < 2^16)
        return [200, 201, 202]

# Create a document with text
doc = {
    'text': 'hello world this is a test'
}

# Create an encoder with special tokens attribute
enc = MockEncoderWithSpecialTokens()

ARGS = {
    'doc': doc,
    'enc': enc
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family int, shape (4,) — shape (4,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
eval_validation_loss Not yet run
unverified (harvested, no recorded run)
YupengSu/MuonQ/src/train_distributed.py
code served (permissive licence) · get_code("960d9ba31e377812")
How it ran

no invocation recorded.

load_checkpoint Not yet run
unverified (harvested, no recorded run)
YupengSu/MuonQ/src/utils.py
code served (permissive licence) · get_code("47022d80ea729401")
How it ran

no invocation recorded.

load_data_shard Not yet run
unverified (harvested, no recorded run)
YupengSu/MuonQ/src/dataloader.py
code served (permissive licence) · get_code("46952274e9541050")
How it ran

no invocation recorded.

load_model Not yet run
unverified (harvested, no recorded run)
YupengSu/MuonQ/src/model.py
code served (permissive licence) · get_code("e8a2ded649151f29")
How it ran

no invocation recorded.

poweriter1 Not yet run
unverified (harvested, no recorded run)
YupengSu/MuonQ/src/optim/muonq.py
code served (permissive licence) · get_code("8c1b83ae34d6533d")
How it ran

no invocation recorded.

Also present in other papers' code

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

The Muon optimizer has emerged as a compelling alternative to Adam for training large language models, achieving remarkable computational savings through gradient orthogonalization. However, Muon's optimizer state is more sensitive to quantization errors: because the orthogonalization discards the magnitudes of singular values and retains only directional information, even small quantization errors in singular vector directions are amplified in the update. In this work, we propose MuonQ, a low-bit Muon training framework built on the principle of directional fidelity optimization. First, we apply a pre-quantization normalization so that each step introduces quantization errors of the same magnitude, preventing the accumulated error from developing a preferred direction. Second, we introduce a structural decomposition that separately quantizes the dominant singular components via power iteration, ensuring that quantization errors perturb only singular value magnitudes rather than rotating singular vector directions. Third, we adopt µ-law companding quantization to allocate higher resolution to densely packed momentum values, shifting the quantization objective from outlier preservation to dense-region distinguishability. Together, these techniques enable stable 4-bit quantization of Muon's optimizer states. Pre-training experiments on GPT-style and LLaMA-style models demonstrate that MuonQ at 4-bit precision recovers most of full-precision Muon's training loss and downstream accuracy while reducing optimizer-state memory by up to 7.3×, offering a favorable point on the accuracy-memory trade-off. Our code is available at https://github.com/YupengSu/MuonQ.

For agents

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

get_harvested_code_for_paper("2605.11396")
get_code_for_paper("2605.11396")
have("2605.11396")

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

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

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

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

Connect an agent — have() is free.