SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.05527 · 2024

GEAR: An Efficient KV Cache Compression Recipe for Near-Lossless Generative Inference of LLM

arXiv · PDF · Open in the Atlas

Code that ran

18 of 22 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 1 violated it and 1 has no contract verdict; 14 failures of our instrument; 4 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, 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/2403.05527.json · badge: /api/ran/2403.05527.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
haokang-timmy/gear canonical (classifier label)
classifier basis: census
15 ran · 4 no recorded run
opengear-project/gear community (classifier label)
classifier basis: plan_row
3 ran · 0 no recorded run
FunctionStatusWhere it lives
repeat_kv Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
opengear-project/gear/GenerationBench/GenerationTest/GEARLM/Simulated/modeling_llama_ablation.py
code served (permissive licence) · get_code("30d7eec482ebf6b1")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-04T23:09:20Z). 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 tensor with shape (batch, num_key_value_heads, seqlen, head_dim)
# Using distinct sizes: batch=2, num_key_value_heads=3, seqlen=5, head_dim=4
hidden_states = torch.randn(2, 3, 5, 4)

# n_rep is the repetition factor
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
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
apply_rotary_pos_emb Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
opengear-project/gear/GenerationBench/GenerationTest/GEARLM/Simulated/modeling_llama_ablation.py
code served (permissive licence) · get_code("d61c483a3c2b3156")
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) 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 tiny tensors for the function
batch_size = 2
seq_len = 3
num_heads = 4
head_dim = 8

# Query and key tensors: [batch_size, num_heads, seq_len, head_dim]
q = torch.randn(batch_size, num_heads, seq_len, head_dim)
k = torch.randn(batch_size, num_heads, seq_len, head_dim)

# Cosine and sine embeddings: [seq_len, head_dim]
# These will be indexed by position_ids
cos = torch.randn(seq_len, head_dim)
sin = torch.randn(seq_len, head_dim)

# Position IDs: [batch_size, seq_len]
position_ids = torch.tensor([[0, 1, 2], [0, 1, 2]], dtype=torch.long)

# unsqueeze_dim parameter
unsqueeze_dim = 1

ARGS = {
    "q": q,
    "k": k,
    "cos": cos,
    "sin": sin,
    "position_ids": position_ids,
    "unsqueeze_dim": unsqueeze_dim,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
calculate_zeros_width Ran
ran, honoured the contract we drafted
haokang-timmy/gear/cuda_supported_gear/quant/qmodule.py
code served (permissive licence) · get_code("fd8719af3db2c5ae")
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 numpy as np

torch.manual_seed(0)

# Analyze the function:
# calculate_zeros_width takes:
# - in_features: an integer (used in arithmetic operations)
# - group_size: an integer with default 128 (used in conditionals and arithmetic)
# - pack_num: an integer with default 8 (used in arithmetic)
# 
# The function performs integer arithmetic and conditional logic.
# No objects or methods are called, just arithmetic operations.

ARGS = {
    "in_features": 256,
    "group_size": 128,
    "pack_num": 8,
}
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 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
dequant_weight Ran
ran; our contract draft was wrong, not the code
haokang-timmy/gear/cuda_supported_gear/quant/gemv.py
code served (permissive licence) · get_code("a9baefdb784da628")
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, 6) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Analyze the function:
# - w: tensor that supports .half(), .view(), and has .shape attribute
# - scale: tensor that supports .unsqueeze(-1) and multiplication
# - mn: tensor that supports .unsqueeze(-1) and addition
# - gs: integer used for division and indexing

# The function does:
# 1. w.half().view(w.shape[0], w.shape[1] // gs, gs)
#    So w needs shape (d0, d1) where d1 is divisible by gs
# 2. w_fp * scale.unsqueeze(-1) + mn.unsqueeze(-1)
#    After first view, w_fp has shape (d0, d1//gs, gs)
#    So scale and mn should have shape (d0, d1//gs) to broadcast correctly

# Create tensors with distinct sizes for clarity
gs = 2
w = torch.randint(0, 256, (4, 6), dtype=torch.uint8)  # shape: (4, 6), 6 divisible by gs=2
scale = torch.randn(4, 3)  # shape: (4, 3) where 3 = 6//2
mn = torch.randn(4, 3)     # shape: (4, 3)

ARGS = {
    "w": w,
    "scale": scale,
    "mn": mn,
    "gs": gs,
}
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, 6) — shape (4, 6) 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
dequant_weight_outer Ran
ran; our contract draft was wrong, not the code
haokang-timmy/gear/cuda_supported_gear/quant/gemv.py
code served (permissive licence) · get_code("4d4c20e8d1e678ef")
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
import torch.nn as nn

torch.manual_seed(0)

# Analyze the function:
# - w: tensor with shape (w.shape[0], w.shape[1], w.shape[2])
#   gets reshaped to (w.shape[0], w.shape[1], w.shape[2] // gs, gs)
#   so w.shape[2] must be divisible by gs
# - scale: tensor that gets unsqueezed and multiplied with w_fp
#   should have shape compatible with (w.shape[0], w.shape[1], w.shape[2] // gs)
# - mn: tensor that gets unsqueezed and added to w_fp
#   should have shape compatible with (w.shape[0], w.shape[1], w.shape[2] // gs)
# - gs: scalar (group size)

# Let's set up small tensors with distinct dimensions
gs = 2

# w needs shape (d0, d1, d2) where d2 is divisible by gs
# Using distinct sizes: 2, 3, 4
d0, d1, d2 = 2, 3, 4

w = torch.randint(0, 256, (d0, d1, d2), dtype=torch.uint8)

# scale and mn should have shape (d0, d1, d2 // gs) = (2, 3, 2)
scale = torch.randn(d0, d1, d2 // gs)
mn = torch.randn(d0, d1, d2 // gs)

ARGS = {
    "w": w,
    "scale": scale,
    "mn": mn,
    "gs": gs,
}
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, 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
evaluate_pred_answer Ran
ran; our contract draft was wrong, not the code
haokang-timmy/gear/GenerationBench/GenerationTest/evaluation_gsm8k.py
code served (permissive licence) · get_code("b6a8148f2f12adc9")
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 re

def evaluate_pred_answer(pred_str, ans_str):
    pattern = '\\d*\\.?\\d+'
    pred_str, ans_str = (pred_str.replace(',', ''), ans_str.replace(',', ''))
    pred_list = re.findall(pattern, pred_str)
    gold_list = re.findall(pattern, ans_str)
    if len(pred_list) >= 1:
        pred = float(pred_list[-1])
        gold = float(gold_list[-1])
        is_pred_true = pred == gold
    else:
        is_pred_true = False
        pred = None
        gold = float(gold_list[-1])
    return (is_pred_true, pred, pred_list, gold, gold_list)

ARGS = {
    'pred_str': 'The answer is 42.5',
    'ans_str': 'The correct answer is 42.5'
}
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 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
extract_ans Ran
ran; our contract draft was wrong, not the code
haokang-timmy/gear/GenerationBench/GenerationTest/evaluation_bbh_cot.py
code served (permissive licence) · get_code("3bbfc4445eea20a9")
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 str. 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 numpy as np

torch.manual_seed(0)

# Test case 1: multiple_choice mode with answer in format (X)
ans_1 = "The answer is (B) correct"
mode_1 = "multiple_choice"

# Test case 2: free_form mode with trailing period
ans_2 = "The answer is 42."
mode_2 = "free_form"

# Test case 3: multiple_choice with option found
ans_3 = "I think the answer is (C) for sure"
mode_3 = "multiple_choice"

# Test case 4: free_form without period
ans_4 = "The answer is hello world"
mode_4 = "free_form"

# Test case 5: answer with question split
ans_5 = "Some text\n\nQ: Another question"
mode_5 = "multiple_choice"

# Test case 6: multiple_choice with letter in parentheses at start
ans_6 = "(A) is the correct answer"
mode_6 = "multiple_choice"

ARGS = {
    "ans": ans_1,
    "mode": mode_1
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
extract_ans_mmlu Ran
ran; our contract draft was wrong, not the code
haokang-timmy/gear/GenerationBench/GenerationTest/evaluation_aqua_cot.py
code served (permissive licence) · get_code("fdbcb8662fd149ba")
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 1, 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)

def extract_ans_mmlu(ans_model):
    ans_model = ans_model.split('\n')
    ans = []
    residual = []
    for li, al in enumerate(ans_model):
        ans.append(al)
        if 'answer is' in al:
            break
    residual = list(ans_model[li + 1:])
    ans = '\n'.join(ans)
    residual = '\n'.join(residual)
    return (ans, residual)

ARGS = {
    'ans_model': "The question is about biology.\nThe answer is A.\nExplanation follows here.\nMore details."
}
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 1, 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
extract_bbh_ans Ran
ran; our contract draft was wrong, not the code
haokang-timmy/gear/GenerationBench/GenerationTest/evaluation_aqua_cot.py
code served (permissive licence) · get_code("b96dbfc20b18beb7")
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 str. 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

# Test case 1: multiple_choice mode with answer containing option
ans_1 = "The answer is (B) the correct option.\nQuestion: Next question"
mode_1 = "multiple_choice"

# Test case 2: free_form mode with answer ending in period
ans_2 = "The answer is 42.\nQuestion: Another question"
mode_2 = "free_form"

# Test case 3: multiple_choice mode with no clear option format
ans_3 = "The answer is some text without option markers"
mode_3 = "multiple_choice"

# Test case 4: free_form mode without period
ans_4 = "The answer is just text"
mode_4 = "free_form"

ARGS = {
    "ans": ans_1,
    "mode": mode_1
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
if_not_then_None Ran
ran; our contract draft was wrong, not the code
haokang-timmy/gear/cuda_supported_gear/modeling_llamagear.py
code served (permissive licence) · get_code("3e8b5053d14e5887")
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 str. 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 if_not_then_None attempts to access a variable
# and catches NameError if it's not defined, setting it to None.
# We need to pass a variable that exists (so no NameError is raised).
# The function simply returns the variable as-is if it exists.

test_variable = "test_value"

ARGS = {
    "variable": test_variable
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
make_divisible Ran
ran, honoured the contract we drafted
haokang-timmy/gear/cuda_supported_gear/quant/qmodule.py
code served (permissive licence) · get_code("ad85b288e9acb9c2")
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

ARGS = {
    "c": 10,
    "divisor": 3
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type 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
quant_and_pack_kcache Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
haokang-timmy/gear/cuda_supported_gear/quant/new_pack.py
code served (permissive licence) · get_code("901a3668958c9deb")
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)

# Create a small k tensor with shape (B, nh, T, D)
# B=2 (batch), nh=3 (num heads), T=8 (sequence length), D=4 (dimension)
k = torch.randn(2, 3, 8, 4)

# group_size must divide T
group_size = 4

# bits must be in [2, 4, 8]
bits = 4

ARGS = {
    "k": k,
    "group_size": group_size,
    "bits": bits,
}
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
quant_and_pack_vcache Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
haokang-timmy/gear/cuda_supported_gear/quant/new_pack.py
code served (permissive licence) · get_code("95a9c97f6ea7d050")
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)

# Create a small 4D tensor for v parameter
# Shape: (batch=2, seq=3, head=4, dim=8)
v = torch.randn(2, 3, 4, 8, dtype=torch.float32)

# group_size must divide the last dimension (8)
# Valid choices: 1, 2, 4, 8
group_size = 2

# bits must be in [2, 4, 8]
bits = 4

ARGS = {
    "v": v,
    "group_size": group_size,
    "bits": bits,
}
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
reindent Ran
ran; our contract draft was wrong, not the code
haokang-timmy/gear/cuda_supported_gear/quant/timeit_v2.py
code served (permissive licence) · get_code("c6b9d9348efc20dc")
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 str. 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

# Analyze the function: reindent(src, indent)
# - src: a string that may contain newlines, gets replaced with '\n' + spaces
# - indent: an integer representing the number of spaces to add

ARGS = {
    "src": "def hello():\n    pass\n    return 42",
    "indent": 4
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
repeat Ran
ran on a synthesized input
haokang-timmy/gear/cuda_supported_gear/quant/timeit_v2.py
code served (permissive licence) · get_code("b9bb89598a35cb87")
How it ran

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

# The Timer class needs:
# - stmt: a string or callable representing the statement to time
# - setup: a string or callable for setup
# - finish: a string (optional, defaults to 'pass')
# - timer: a callable that returns elapsed time
# - globals: a namespace dict (optional)

ARGS = {
    'stmt': 'x = 1 + 1',
    'setup': 'x = 0',
    'finish': 'pass',
    'timer': time.perf_counter,
    'globals': None,
    'repeat': 5,
    'number': 1000
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
rotate_half Ran
ran; our contract draft was wrong, not the code
opengear-project/gear/GenerationBench/GenerationTest/GEARLM/Simulated/modeling_llama_ablation.py
code served (permissive licence) · get_code("b99eea6376d1e212")
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) 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 single parameter 'x' which is a tensor
# It accesses x.shape[-1] to get the last dimension
# It uses indexing with [..., :] slicing notation
# It calls torch.cat() to concatenate tensors

# Create a small tensor with shape (2, 4) - batch size 2, hidden dim 4
x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
test_answer Ran
ran, violated the contract we drafted
haokang-timmy/gear/GenerationBench/GenerationTest/evaluation_gsm8k.py
code served (permissive licence) · get_code("b6065f749757a201")
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 bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def test_answer(pred_str, ans_str):
    pattern = '\\d*\\.?\\d+'
    pred = re.findall(pattern, pred_str)
    if len(pred) >= 1:
        print('#####\n Pred string:', pred_str, '\n pred_list', pred)
        pred = float(pred[-1].replace(',', ''))
        gold = re.findall(pattern, ans_str)
        print('\n Gold_answer', ans_str, '\n gold_list', gold)
        gold = float(gold[-1].replace(',', ''))
        print('\n result', gold, pred, gold == pred)
        return pred == gold
    else:
        return False


ARGS = {
    'pred_str': 'The answer is 42.5',
    'ans_str': 'The correct answer is 42.5'
}
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 bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
test_answer_mmlu_ Ran
ran; our contract draft was wrong, not the code
haokang-timmy/gear/GenerationBench/GenerationTest/evaluation_bbh_cot.py
code served (permissive licence) · get_code("c119c70eed02c785")
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 1, 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

# Construct valid arguments for test_answer_mmlu_
pred_str = "the answer is (a) based on my analysis"
ans = "A"

ARGS = {
    "pred_str": pred_str,
    "ans": ans
}
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 1, 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_model_tokenizer Not yet run
unverified (harvested, no recorded run)
haokang-timmy/gear/GenerationBench/GenerationTest/evaluation_aqua_cot.py
code served (permissive licence) · get_code("eb8e4a7084fe84dc")
How it ran

no invocation recorded.

parse_pred_ans Not yet run
unverified (harvested, no recorded run)
haokang-timmy/gear/GenerationBench/GenerationTest/evaluation_gsm8k.py
code served (permissive licence) · get_code("d93eb10d932ff2c8")
How it ran

no invocation recorded.

timeit Not yet run
unverified (harvested, no recorded run)
haokang-timmy/gear/cuda_supported_gear/quant/timeit_v2.py
code served (permissive licence) · get_code("c743c02d9c56ac78")
How it ran

no invocation recorded.

unpack_and_dequant_kcache Not yet run
unverified (harvested, no recorded run)
haokang-timmy/gear/cuda_supported_gear/quant/new_pack.py
code served (permissive licence) · get_code("e493c68ae46ac587")
How it ran

no invocation recorded.

Also present in other papers' code

Of 22 samples lifted from this paper's linked repositories, 22 carry a function identity and 0 do not. Of the 22 distinct functions with an identity, 13 are also present in other papers whose code we hold (10 with at least one paper dated earlier, 3 the same month, 8 later) and 9 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
rotate_half 360 other papers
94 dated earlier, 8 the same month, 249 later, 6 same year, order not determinable, 3 undated · 30 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
and 357 more not named here
repeat_kv 243 other papers
53 dated earlier, 4 the same month, 182 later, 2 same year, order not determinable, 2 undated · 22 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
2305.17888 (2023-05)
LLM-QAT: Data-Free Quantization Aware Training for Large Language Models
and 240 more not named here
apply_rotary_pos_emb 75 other papers
15 dated earlier, 3 the same month, 57 later · 2 only as an assembly brick
2309.11499 (2023-09)
DreamLLM: Synergistic Multimodal Comprehension and Creation
2312.02051 (2023-12)
TimeChat: A Time-sensitive Multimodal Large Language Model for Long Video Understanding
2312.03414 (2023-12)
Compressed Context Memory For Online Language Model Interaction
and 72 more not named here
calculate_zeros_width 3 other papers
2 dated earlier, 1 later
2402.02750 (2024-02)
KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache
2402.10631 (2024-02)
BitDistiller: Unleashing the Potential of Sub-4-Bit LLMs via Self-Distillation
make_divisible 3 other papers
2 dated earlier, 1 later
2402.02750 (2024-02)
KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache
2402.10631 (2024-02)
BitDistiller: Unleashing the Potential of Sub-4-Bit LLMs via Self-Distillation
dequant_weight 1 other paper
1 dated earlier
2402.02750 (2024-02)
KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache
dequant_weight_outer 1 other paper
1 dated earlier
2402.02750 (2024-02)
KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache
evaluate_pred_answer 1 other paper
1 later
2411.05282 (2024-11)
MicroScopiQ: Accelerating Foundational Models through Outlier-Aware Microscaling Quantization
parse_pred_ans 1 other paper
1 later
2411.05282 (2024-11)
MicroScopiQ: Accelerating Foundational Models through Outlier-Aware Microscaling Quantization
quant_and_pack_kcache 1 other paper
1 dated earlier
2402.02750 (2024-02)
KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache
quant_and_pack_vcache 1 other paper
1 dated earlier
2402.02750 (2024-02)
KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache
test_answer 1 other paper
1 later
2411.05282 (2024-11)
MicroScopiQ: Accelerating Foundational Models through Outlier-Aware Microscaling Quantization
unpack_and_dequant_kcache 1 other paper
1 dated earlier
2402.02750 (2024-02)
KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache

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

Key-value (KV) caching has become the de-facto to accelerate generation speed for large language models (LLMs) inference. However, the growing cache demand with increasing sequence length has transformed LLM inference to be a memory bound problem, significantly constraining the system throughput. Existing methods rely on dropping unimportant tokens or quantizing all entries uniformly. Such methods, however, often incur high approximation errors to represent the compressed matrices. The autoregressive decoding process further compounds the error of each step, resulting in critical deviation in model generation and deterioration of performance. To tackle this challenge, we propose GEAR, an efficient KV cache compression framework that achieves near-lossless high-ratio compression. GEAR first applies quantization to majority of entries of similar magnitudes to ultra-low precision. It then employs a low rank matrix to approximate the quantization error, and a sparse matrix to remedy individual errors from outlier entries. By adeptly integrating three techniques, GEAR is able to fully exploit their synergistic potentials. Our experiments demonstrate that compared to alternatives, GEAR achieves near-lossless 4-bit KV cache compression with up to 2.38x throughput improvement, while reducing peak-memory size up to 2.29x. Our code is publicly available at https://github.com/HaoKang-Timmy/GEAR.

For agents

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

get_harvested_code_for_paper("2403.05527")
get_code_for_paper("2403.05527")
have("2403.05527")

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

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

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

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

Connect an agent — have() is free.