| FasterSinkhornRouter |
Ran ran on a synthesized input |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("d4d2e3c796705330") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 torch
import math
# Mock the triton and sinkhorn functions that are called but not defined
class MockTriton:
@staticmethod
def next_power_of_2(x):
return 1 << (x - 1).bit_length()
triton = MockTriton()
def sinkhorn_reference(logits, n_iter, temperature, inverse_update):
"""Mock reference implementation"""
batch, n_point, n_mode = logits.shape
u = torch.zeros(batch, n_point, device=logits.device, dtype=logits.dtype)
v = torch.zeros(batch, n_mode, device=logits.device, dtype=logits.dtype)
for _ in range(n_iter):
u = -torch.logsumexp(logits / temperature + v.unsqueeze(1), dim=2)
v = -torch.logsumexp(logits / temperature + u.unsqueeze(2), dim=1)
score_encode = u
score_decode = v
return score_encode, score_decode
def _sinkhorn_triton_forward(logits, n_iter, temperature, inverse_update):
"""Mock forward implementation"""
score_encode, score_decode = sinkhorn_reference(logits, n_iter, temperature, inverse_update)
return score_encode, score_decode, None, None
def _sinkhorn_triton_backward(logits, u_history, v_history, grad_score_encode, grad_score_decode, temperature):
"""Mock backward implementation"""
return torch.zeros_like(logits)
def _num_warps(block_size):
if block_size >= 4096:
return 16
if block_size >= 1024:
return 8
return 4
class _FasterSinkhornFunction(torch.autograd.Function):
@staticmethod
def forward(ctx, logits, n_iter, temperature, inverse_update):
ctx.n_iter = int(n_iter)
ctx.temperature = float(temperature)
ctx.inverse_update = bool(inverse_update)
score_encode, score_decode, u_history, v_history = _sinkhorn_triton_forward(logits, n_iter=ctx.n_iter, temperature=ctx.temperature, inverse_update=ctx.inverse_update)
if u_history is None:
ctx.reference_backward = True
ctx.save_for_backward(logits)
else:
ctx.reference_backward = False
ctx.save_for_backward(logits, u_history, v_history)
return (score_encode, score_decode)
@staticmethod
def backward(ctx, grad_score_encode, grad_score_decode):
if not ctx.reference_backward:
logits, u_history, v_history = ctx.saved_tensors
if grad_score_encode is None:
grad_score_encode = torch.zeros_like(logits)
if grad_score_decode is None:
grad_score_decode = torch.zeros_like(logits)
return (_sinkhorn_triton_backward(logits, u_history, v_history, grad_score_encode.contiguous(), grad_score_decode.contiguous(), temperature=ctx.temperature), None, None, None)
logits, = ctx.saved_tensors
create_graph = torch.is_grad_enabled()
with torch.enable_grad():
work_logits = logits.detach().requires_grad_(True)
score_encode, score_decode = sinkhorn_reference(work_logits, n_iter=ctx.n_iter, temperature=ctx.temperature, inverse_update=ctx.inverse_update)
if grad_score_encode is None:
grad_score_encode = torch.zeros_like(score_encode)
if grad_score_decode is None:
grad_score_decode = torch.zeros_like(score_decode)
grad_logits = torch.autograd.grad(outputs=(score_encode, score_decode), inputs=work_logits, grad_outputs=(grad_score_encode, grad_score_decode), create_graph=create_graph)[0]
return (grad_logits, None, None, None)
INIT_ARGS = {}
ARGS = {
'logits': torch.randn(2, 4, 3),
'n_iter': 5,
'temperature': 1.0,
'inverse_update': False,
}
if __name__ == '__main__':
result = _FasterSinkhornFunction.apply(
ARGS['logits'],
ARGS['n_iter'],
ARGS['temperature'],
ARGS['inverse_update'],
)
print("Forward pass result:", result)
print("Result shapes:", result[0].shape, result[1].shape)
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| MONOAttentionBlock |
Ran ran on a synthesized input |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("f6a7146a16c75597") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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
INIT_ARGS = {
"n_dim": 4,
"n_head": 2,
"act": torch.nn.GELU(),
"drop_rate": 0.1,
"mlp_expand_rate": 4.0,
}
ARGS = {
"y": torch.randn(2, 3, 4),
}
class MONOSelfAttention(torch.nn.Module):
"""
Explicit multi-head self-attention used by MONO.
This is intentionally the non-fused attention path of the reference model.
"""
def __init__(self, n_dim, n_head, drop_rate=0.0):
super().__init__()
self.n_head = n_head
self.scale = (n_dim // n_head) ** (-0.5)
self.fused_attn = False
self.attn_drop = torch.nn.Dropout(drop_rate)
self.Wq = torch.nn.Linear(n_dim, n_dim)
self.Wk = torch.nn.Linear(n_dim, n_dim)
self.Wv = torch.nn.Linear(n_dim, n_dim)
self.proj = torch.nn.Linear(n_dim, n_dim)
def forward(self, x):
batch, tokens, dim = x.size()
q = self.Wq(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3)
k = self.Wk(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3)
v = self.Wv(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3)
q = q * self.scale
attn = q @ k.transpose(-2, -1)
attn = attn.softmax(dim=-1)
attn = self.attn_drop(attn)
out = attn @ v
out = out.permute(0, 2, 1, 3).contiguous().view(batch, tokens, dim)
return self.proj(out)
class MONOAttentionBlock(torch.nn.Module):
"""Pre-normalized self-attention block followed by a residual MLP."""
def __init__(self, n_dim, n_head, act, drop_rate=0.0, mlp_expand_rate=4.0):
super().__init__()
self.self_attn = MONOSelfAttention(n_dim, n_head, drop_rate=drop_rate)
self.ln1 = torch.nn.LayerNorm(n_dim)
self.ln2 = torch.nn.LayerNorm(n_dim)
self.drop = torch.nn.Dropout(drop_rate)
self.mlp = torch.nn.Sequential(torch.nn.Linear(n_dim, int(n_dim * mlp_expand_rate)), act, torch.nn.Linear(int(n_dim * mlp_expand_rate), n_dim))
def forward(self, y):
y = y + self.drop(self.self_attn(self.ln1(y)))
y = y + self.mlp(self.ln2(y))
return y
if __name__ == "__main__":
model = MONOAttentionBlock(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: {ARGS['y'].shape}")
assert output.shape == ARGS['y'].shape, "Output shape mismatch"
print("Success!")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| MONOLatentStack |
Ran ran on a synthesized input |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("dd5ed7cfd1fe8c3c") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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
# Define the classes (copied from the problem statement)
class MONOSelfAttention(torch.nn.Module):
"""
Explicit multi-head self-attention used by MONO.
This is intentionally the non-fused attention path of the reference model.
"""
def __init__(self, n_dim, n_head, drop_rate=0.0):
super().__init__()
self.n_head = n_head
self.scale = (n_dim // n_head) ** (-0.5)
self.fused_attn = False
self.attn_drop = torch.nn.Dropout(drop_rate)
self.Wq = torch.nn.Linear(n_dim, n_dim)
self.Wk = torch.nn.Linear(n_dim, n_dim)
self.Wv = torch.nn.Linear(n_dim, n_dim)
self.proj = torch.nn.Linear(n_dim, n_dim)
def forward(self, x):
batch, tokens, dim = x.size()
q = self.Wq(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3)
k = self.Wk(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3)
v = self.Wv(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3)
q = q * self.scale
attn = q @ k.transpose(-2, -1)
attn = attn.softmax(dim=-1)
attn = self.attn_drop(attn)
out = attn @ v
out = out.permute(0, 2, 1, 3).contiguous().view(batch, tokens, dim)
return self.proj(out)
class MONOAttentionBlock(torch.nn.Module):
"""Pre-normalized self-attention block followed by a residual MLP."""
def __init__(self, n_dim, n_head, act, drop_rate=0.0, mlp_expand_rate=4.0):
super().__init__()
self.self_attn = MONOSelfAttention(n_dim, n_head, drop_rate=drop_rate)
self.ln1 = torch.nn.LayerNorm(n_dim)
self.ln2 = torch.nn.LayerNorm(n_dim)
self.drop = torch.nn.Dropout(drop_rate)
self.mlp = torch.nn.Sequential(torch.nn.Linear(n_dim, int(n_dim * mlp_expand_rate)), act, torch.nn.Linear(int(n_dim * mlp_expand_rate), n_dim))
def forward(self, y):
y = y + self.drop(self.self_attn(self.ln1(y)))
y = y + self.mlp(self.ln2(y))
return y
class MONOLatentStack(torch.nn.Module):
"""Stack multiple attention blocks in the mode/latent space."""
def __init__(self, n_block, n_dim, n_head, act, drop_rate=0.0):
super().__init__()
self.blocks = torch.nn.Sequential(*[MONOAttentionBlock(n_dim, n_head, act, drop_rate=drop_rate, mlp_expand_rate=4.0) for _ in range(n_block)])
def forward(self, latent):
return self.blocks(latent)
# Setup arguments
INIT_ARGS = {
'n_block': 2,
'n_dim': 4,
'n_head': 2,
'act': torch.nn.GELU(),
'drop_rate': 0.1,
}
ARGS = {
'latent': torch.randn(2, 3, 4),
}
# Construct and call
model = MONOLatentStack(**INIT_ARGS)
output = model(**ARGS)
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| MONOMLP |
Ran ran on a synthesized input |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("84eb0ed48136b5fb") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 3) 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
INIT_ARGS = {
'input_dim': 4,
'hidden_dim': 8,
'output_dim': 3,
'n_layer': 2,
'act': nn.ReLU(),
'row_normalized_output': True,
'row_norm_scale_init': 3.0,
'drop_rate': 0.1,
}
ARGS = {
'x': torch.randn(2, 4),
}
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| MONORowNormalizedLinear |
Ran ran on a synthesized input |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("354e43b346c9f5e4") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 3) 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 math
import torch
import torch.nn.functional as F
class MONORowNormalizedLinear(torch.nn.Module):
"""
Bias-free linear projection with row-normalized weights and one learnable
global scale shared by all output rows.
"""
def __init__(self, in_features, out_features, scale_init=3.0, eps=1e-12):
super().__init__()
if in_features <= 0:
raise ValueError('in_features must be positive.')
if out_features <= 0:
raise ValueError('out_features must be positive.')
if eps <= 0:
raise ValueError('eps must be positive.')
self.in_features = in_features
self.out_features = out_features
self.eps = eps
self.weight = torch.nn.Parameter(torch.empty(out_features, in_features))
self.global_scale = torch.nn.Parameter(torch.tensor(float(scale_init)))
self.reset_parameters()
def reset_parameters(self):
torch.nn.init.kaiming_uniform_(self.weight, a=math.sqrt(5))
def forward(self, x):
direction = F.normalize(self.weight, p=2, dim=1, eps=self.eps)
effective_weight = direction * self.global_scale
return F.linear(x, effective_weight)
INIT_ARGS = {
'in_features': 4,
'out_features': 3,
'scale_init': 3.0,
'eps': 1e-12
}
ARGS = {
'x': torch.randn(2, 4)
}
if __name__ == '__main__':
model = MONORowNormalizedLinear(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Output: {output}")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| MONOSelfAttention |
Ran ran on a synthesized input |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("d8db85837f8d35c5") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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
INIT_ARGS = {
"n_dim": 4,
"n_head": 2,
"drop_rate": 0.1,
}
ARGS = {
"x": torch.randn(2, 3, 4),
}
if __name__ == "__main__":
attention = torch.nn.Module()
attention.__class__ = type('MONOSelfAttention', (torch.nn.Module,), {
'__init__': lambda self, n_dim, n_head, drop_rate=0.0: (
torch.nn.Module.__init__(self),
setattr(self, 'n_head', n_head),
setattr(self, 'scale', (n_dim // n_head) ** (-0.5)),
setattr(self, 'fused_attn', False),
setattr(self, 'attn_drop', torch.nn.Dropout(drop_rate)),
setattr(self, 'Wq', torch.nn.Linear(n_dim, n_dim)),
setattr(self, 'Wk', torch.nn.Linear(n_dim, n_dim)),
setattr(self, 'Wv', torch.nn.Linear(n_dim, n_dim)),
setattr(self, 'proj', torch.nn.Linear(n_dim, n_dim)),
)[-1],
'forward': lambda self, x: (
lambda batch, tokens, dim: (
lambda q, k, v: (
lambda attn: (
lambda out: self.proj(out.permute(0, 2, 1, 3).contiguous().view(batch, tokens, dim))
)(attn @ v)
)(self.attn_drop((q @ k.transpose(-2, -1)).softmax(dim=-1)))
)(
(self.Wq(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3) * self.scale),
self.Wk(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3),
self.Wv(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3),
)
)(*x.size())
})
attention = type('MONOSelfAttention', (torch.nn.Module,), {
'__init__': lambda self, n_dim, n_head, drop_rate=0.0: (
torch.nn.Module.__init__(self),
setattr(self, 'n_head', n_head),
setattr(self, 'scale', (n_dim // n_head) ** (-0.5)),
setattr(self, 'fused_attn', False),
setattr(self, 'attn_drop', torch.nn.Dropout(drop_rate)),
setattr(self, 'Wq', torch.nn.Linear(n_dim, n_dim)),
setattr(self, 'Wk', torch.nn.Linear(n_dim, n_dim)),
setattr(self, 'Wv', torch.nn.Linear(n_dim, n_dim)),
setattr(self, 'proj', torch.nn.Linear(n_dim, n_dim)),
)[-1],
'forward': lambda self, x: (
lambda batch, tokens, dim: self.proj(
(self.attn_drop(
(self.Wq(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3) * self.scale
) @ self.Wk(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3).transpose(-2, -1)
).softmax(dim=-1)) @ self.Wv(x).view(batch, tokens, self.n_head, dim // self.n_head).permute(0, 2, 1, 3)
).permute(0, 2, 1, 3).contiguous().view(batch, tokens, dim)
)(*x.size())
})(**INIT_ARGS)
output = attention(ARGS["x"])
print(f"Output shape: {output.shape}")
print(f"Expected shape: {ARGS['x'].shape}")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| TimeProjector |
Ran ran on a synthesized input |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("a58b0c7175fd1107") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 math
import torch
import torch.nn.functional as F
class MONORowNormalizedLinear(torch.nn.Module):
"""
Bias-free linear projection with row-normalized weights and one learnable
global scale shared by all output rows.
"""
def __init__(self, in_features, out_features, scale_init=3.0, eps=1e-12):
super().__init__()
if in_features <= 0:
raise ValueError('in_features must be positive.')
if out_features <= 0:
raise ValueError('out_features must be positive.')
if eps <= 0:
raise ValueError('eps must be positive.')
self.in_features = in_features
self.out_features = out_features
self.eps = eps
self.weight = torch.nn.Parameter(torch.empty(out_features, in_features))
self.global_scale = torch.nn.Parameter(torch.tensor(float(scale_init)))
self.reset_parameters()
def reset_parameters(self):
torch.nn.init.kaiming_uniform_(self.weight, a=math.sqrt(5))
def forward(self, x):
direction = F.normalize(self.weight, p=2, dim=1, eps=self.eps)
effective_weight = direction * self.global_scale
return F.linear(x, effective_weight)
class MONOMLP(torch.nn.Module):
"""Residual MLP used by feature, routing, and output projectors."""
def __init__(self, input_dim, hidden_dim, output_dim, n_layer, act, row_normalized_output=False, row_norm_scale_init=3.0, drop_rate=0.0):
super().__init__()
self.input = torch.nn.Linear(input_dim, hidden_dim)
self.hidden = torch.nn.ModuleList([torch.nn.Linear(hidden_dim, hidden_dim) for _ in range(n_layer)])
if row_normalized_output:
self.output = MONORowNormalizedLinear(hidden_dim, output_dim, scale_init=row_norm_scale_init)
else:
self.output = torch.nn.Linear(hidden_dim, output_dim)
self.act = act
self.drop = torch.nn.Dropout(drop_rate)
def forward(self, x):
hidden = self.act(self.input(x))
for layer in self.hidden:
hidden = hidden + self.drop(self.act(layer(hidden)))
return self.output(hidden)
def timestep_embedding(timesteps, dim, max_period=10000):
"""Build sinusoidal timestep embeddings."""
half = dim // 2
freqs = torch.exp(-math.log(max_period) * torch.arange(start=0, end=half, dtype=torch.float32, device=timesteps.device) / half)
args = timesteps[:, None].float() * freqs[None]
embedding = torch.cat([torch.cos(args), torch.sin(args)], dim=-1)
if dim % 2:
embedding = torch.cat([embedding, torch.zeros_like(embedding[:, :1])], dim=-1)
return embedding
class TimeProjector(torch.nn.Module):
"""Project a scalar timestep and broadcast it to every input point."""
def __init__(self, n_dim, n_layer, act):
super().__init__()
self.projector = MONOMLP(n_dim, n_dim, n_dim, n_layer, act)
self.n_dim = n_dim
def forward(self, t, n_point):
if t.dim() > 1:
t = t.reshape(t.shape[0])
time_feature = timestep_embedding(t, self.n_dim)
time_feature = self.projector(time_feature)
return time_feature.unsqueeze(1).expand(-1, n_point, -1)
INIT_ARGS = {
'n_dim': 4,
'n_layer': 2,
'act': torch.nn.ReLU()
}
ARGS = {
't': torch.tensor([0, 5], dtype=torch.long),
'n_point': 3
}
if __name__ == '__main__':
model = TimeProjector(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: (2, 3, 4)")
assert output.shape == (2, 3, 4), f"Shape mismatch: {output.shape}"
print("Success!")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| _num_warps |
Ran ran, honoured the contract we drafted |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("df26f6fd01f5074c") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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 _num_warps takes a single parameter: block_size
# It's an integer that determines the number of warps based on thresholds
# We'll test with a value that exercises the logic
ARGS = {
"block_size": 2048
}
- 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 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
|
| faster_sinkhorn |
Ran ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT) |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("53551df2ff1a0807") How it ranRan 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 4, 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 signature from the class method is:
# forward(ctx, logits, n_iter, temperature, inverse_update)
# We need to construct arguments for the forward method
# Create small tensors
batch_size = 2
n_point = 4
n_mode = 3
# logits: [batch, n_point, n_mode] tensor
logits = torch.randn(batch_size, n_point, n_mode, dtype=torch.float32)
# n_iter: number of iterations (int)
n_iter = 5
# temperature: temperature parameter (float)
temperature = 1.0
# inverse_update: boolean flag
inverse_update = False
ARGS = {
"logits": logits,
"n_iter": n_iter,
"temperature": temperature,
"inverse_update": inverse_update,
}
- 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 4, 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
|
| sinkhorn_reference |
Ran ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT) |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("52a5326a185d2f2e") How it ranRan 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 4, 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)
# Construct valid arguments for sinkhorn_reference
# The function expects:
# - logits: tensor of shape (batch, n_point, n_mode)
# - n_iter: int (number of iterations)
# - temperature: float (scaling temperature)
# - inverse_update: bool (whether to use inverse update order)
batch = 2
n_point = 4
n_mode = 3
logits = torch.randn(batch, n_point, n_mode)
n_iter = 8
temperature = 1.0
inverse_update = False
ARGS = {
"logits": logits,
"n_iter": n_iter,
"temperature": temperature,
"inverse_update": inverse_update,
}
- 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 4, 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
|
| timestep_embedding |
Ran ran; our contract draft was wrong, not the code |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("dd00f566fa6273b0") How it ranRan 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
import math
torch.manual_seed(0)
# Create timesteps tensor - batch size 2
timesteps = torch.tensor([0, 5], dtype=torch.int64)
# Embedding dimension - must be even for this example
dim = 4
# Max period parameter
max_period = 10000
ARGS = {
"timesteps": timesteps,
"dim": dim,
"max_period": max_period,
}
- 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
|
| CoTAP |
Not yet run unverified (harvested, no recorded run) |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("d0d18d797125c749") How it ran |
| MONO |
Not yet run unverified (harvested, no recorded run) |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("21e1084161c31d72") How it ran |
| MONOInitialProjectorEMA |
Not yet run unverified (harvested, no recorded run) |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("7fd66c5975318dde") How it ran |
| MONOMultiLevelStage |
Not yet run unverified (harvested, no recorded run) |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("034ca02d01b82807") How it ran |
| _FasterSinkhornFunction |
Not yet run unverified (harvested, no recorded run) |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("fd32a7d4006bd8b5") How it ran |
| _sinkhorn_triton_backward |
Not yet run unverified (harvested, no recorded run) |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("eab2c0f5ac14deb5") How it ran |
| _sinkhorn_triton_forward |
Not yet run unverified (harvested, no recorded run) |
ZijiangY1116/MoNo/utils/models/mono.py code served (permissive licence) · get_code("d6db6c174a3a6e5c") How it ran |