| ISAB |
Ran ran on a synthesized input |
aripakman/amortized_community_detection/acp/models/acp_model.py code served (permissive licence) · get_code("13661bd18e3c4a52") 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, 6, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
class MAB(nn.Module):
def __init__(self, dim_X, dim_Y, dim, num_heads=4, ln=False, p=None, residual=True):
super().__init__()
self.num_heads = num_heads
self.fc_q = nn.Linear(dim_X, dim)
self.fc_k = nn.Linear(dim_Y, dim)
self.fc_v = nn.Linear(dim_Y, dim)
self.fc_o = nn.Linear(dim, dim)
self.ln1 = nn.LayerNorm(dim) if ln else nn.Identity()
self.ln2 = nn.LayerNorm(dim) if ln else nn.Identity()
self.dropout1 = nn.Dropout(p=p) if p is not None else nn.Identity()
self.dropout2 = nn.Dropout(p=p) if p is not None else nn.Identity()
self.residual = residual
def forward(self, X, Y, mask=None):
Q, K, V = (self.fc_q(X), self.fc_k(Y), self.fc_v(Y))
Q_ = torch.cat(Q.chunk(self.num_heads, -1), 0)
K_ = torch.cat(K.chunk(self.num_heads, -1), 0)
V_ = torch.cat(V.chunk(self.num_heads, -1), 0)
A_logits = Q_ @ K_.transpose(-2, -1) / math.sqrt(Q.shape[-1])
if mask is not None:
mask = torch.stack([mask] * Q.shape[-2], -2)
mask = torch.cat([mask] * self.num_heads, 0)
A_logits.masked_fill_(mask == 0, -float('inf'))
A = torch.softmax(A_logits, -1)
A = A.masked_fill(torch.isnan(A), 0.0)
else:
A = torch.softmax(A_logits, -1)
attn = torch.cat((A @ V_).chunk(self.num_heads, 0), -1)
if self.residual:
O = self.ln1(Q + self.dropout1(attn))
O = self.ln2(O + self.dropout2(F.relu(self.fc_o(O))))
else:
O = self.ln1(self.dropout1(attn))
O = self.ln2(O + self.dropout2(F.relu(self.fc_o(O))))
return O
class PMA(nn.Module):
def __init__(self, dim_X, dim, num_inds, **kwargs):
super().__init__()
self.I = nn.Parameter(torch.Tensor(num_inds, dim))
nn.init.xavier_uniform_(self.I)
self.mab = MAB(dim, dim_X, dim, **kwargs)
def forward(self, X, mask=None):
I = self.I if X.dim() == 2 else self.I.repeat(X.shape[0], 1, 1)
return self.mab(I, X, mask=mask)
class ISAB(nn.Module):
def __init__(self, dim_X, dim, num_inds, **kwargs):
super().__init__()
self.pma = PMA(dim_X, dim, num_inds, **kwargs)
self.mab = MAB(dim_X, dim, dim, **kwargs)
def forward(self, X, mask=None):
return self.mab(X, self.pma(X, mask=mask))
INIT_ARGS = {
'dim_X': 5,
'dim': 8,
'num_inds': 3,
'num_heads': 2,
'ln': False,
'p': None,
'residual': True,
}
ARGS = {
'X': torch.randn(2, 6, 5),
'mask': None,
}
if __name__ == '__main__':
model = ISAB(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: (2, 6, 8)")
- 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, 6, 8) — shape (2, 6, 8) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| MAB |
Ran ran on a synthesized input |
aripakman/amortized_community_detection/acp/models/acp_model.py code served (permissive licence) · get_code("5068848cf579a326") 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, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
class MAB(nn.Module):
def __init__(self, dim_X, dim_Y, dim, num_heads=4, ln=False, p=None, residual=True):
super().__init__()
self.num_heads = num_heads
self.fc_q = nn.Linear(dim_X, dim)
self.fc_k = nn.Linear(dim_Y, dim)
self.fc_v = nn.Linear(dim_Y, dim)
self.fc_o = nn.Linear(dim, dim)
self.ln1 = nn.LayerNorm(dim) if ln else nn.Identity()
self.ln2 = nn.LayerNorm(dim) if ln else nn.Identity()
self.dropout1 = nn.Dropout(p=p) if p is not None else nn.Identity()
self.dropout2 = nn.Dropout(p=p) if p is not None else nn.Identity()
self.residual = residual
def forward(self, X, Y, mask=None):
Q, K, V = (self.fc_q(X), self.fc_k(Y), self.fc_v(Y))
Q_ = torch.cat(Q.chunk(self.num_heads, -1), 0)
K_ = torch.cat(K.chunk(self.num_heads, -1), 0)
V_ = torch.cat(V.chunk(self.num_heads, -1), 0)
A_logits = Q_ @ K_.transpose(-2, -1) / math.sqrt(Q.shape[-1])
if mask is not None:
mask = torch.stack([mask] * Q.shape[-2], -2)
mask = torch.cat([mask] * self.num_heads, 0)
A_logits.masked_fill_(mask == 0, -float('inf'))
A = torch.softmax(A_logits, -1)
A = A.masked_fill(torch.isnan(A), 0.0)
else:
A = torch.softmax(A_logits, -1)
attn = torch.cat((A @ V_).chunk(self.num_heads, 0), -1)
if self.residual:
O = self.ln1(Q + self.dropout1(attn))
O = self.ln2(O + self.dropout2(F.relu(self.fc_o(O))))
else:
O = self.ln1(self.dropout1(attn))
O = self.ln2(O + self.dropout2(F.relu(self.fc_o(O))))
return O
INIT_ARGS = {
'dim_X': 5,
'dim_Y': 7,
'dim': 8,
'num_heads': 2,
'ln': True,
'p': 0.1,
'residual': True
}
ARGS = {
'X': torch.randn(2, 3, 5),
'Y': torch.randn(2, 4, 7),
'mask': None
}
if __name__ == '__main__':
mab = MAB(**INIT_ARGS)
output = mab(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: (2, 3, 8)")
assert output.shape == (2, 3, 8), f"Shape mismatch: {output.shape}"
print("Test passed!")
- 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, 8) — shape (2, 3, 8) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| PMA |
Ran ran on a synthesized input |
aripakman/amortized_community_detection/acp/models/acp_model.py code served (permissive licence) · get_code("adbf1620f21b495a") 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, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
class MAB(nn.Module):
def __init__(self, dim_X, dim_Y, dim, num_heads=4, ln=False, p=None, residual=True):
super().__init__()
self.num_heads = num_heads
self.fc_q = nn.Linear(dim_X, dim)
self.fc_k = nn.Linear(dim_Y, dim)
self.fc_v = nn.Linear(dim_Y, dim)
self.fc_o = nn.Linear(dim, dim)
self.ln1 = nn.LayerNorm(dim) if ln else nn.Identity()
self.ln2 = nn.LayerNorm(dim) if ln else nn.Identity()
self.dropout1 = nn.Dropout(p=p) if p is not None else nn.Identity()
self.dropout2 = nn.Dropout(p=p) if p is not None else nn.Identity()
self.residual = residual
def forward(self, X, Y, mask=None):
Q, K, V = (self.fc_q(X), self.fc_k(Y), self.fc_v(Y))
Q_ = torch.cat(Q.chunk(self.num_heads, -1), 0)
K_ = torch.cat(K.chunk(self.num_heads, -1), 0)
V_ = torch.cat(V.chunk(self.num_heads, -1), 0)
A_logits = Q_ @ K_.transpose(-2, -1) / math.sqrt(Q.shape[-1])
if mask is not None:
mask = torch.stack([mask] * Q.shape[-2], -2)
mask = torch.cat([mask] * self.num_heads, 0)
A_logits.masked_fill_(mask == 0, -float('inf'))
A = torch.softmax(A_logits, -1)
A = A.masked_fill(torch.isnan(A), 0.0)
else:
A = torch.softmax(A_logits, -1)
attn = torch.cat((A @ V_).chunk(self.num_heads, 0), -1)
if self.residual:
O = self.ln1(Q + self.dropout1(attn))
O = self.ln2(O + self.dropout2(F.relu(self.fc_o(O))))
else:
O = self.ln1(self.dropout1(attn))
O = self.ln2(O + self.dropout2(F.relu(self.fc_o(O))))
return O
class PMA(nn.Module):
def __init__(self, dim_X, dim, num_inds, **kwargs):
super().__init__()
self.I = nn.Parameter(torch.Tensor(num_inds, dim))
nn.init.xavier_uniform_(self.I)
self.mab = MAB(dim, dim_X, dim, **kwargs)
def forward(self, X, mask=None):
I = self.I if X.dim() == 2 else self.I.repeat(X.shape[0], 1, 1)
return self.mab(I, X, mask=mask)
INIT_ARGS = {
'dim_X': 5,
'dim': 8,
'num_inds': 3,
'num_heads': 2,
'ln': True,
'p': 0.1,
'residual': True
}
ARGS = {
'X': torch.randn(2, 7, 5),
'mask': None
}
if __name__ == '__main__':
model = PMA(**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 3, dtype family float, shape (2, 3, 8) — shape (2, 3, 8) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| get_ATUS |
Ran ran; our contract draft was wrong, not the code |
aripakman/amortized_community_detection/acp/models/acp_model.py code served (permissive licence) · get_code("df22064be55eea2e") 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 tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
torch.manual_seed(0)
# The function expects:
# - clusters: list[int] or Tensor of cluster sizes
# - device: optional device specification
# Create a small example with 3 clusters of sizes 2, 3, 2
clusters = torch.tensor([2, 3, 2], dtype=torch.int64)
ARGS = {
"clusters": clusters,
"device": None,
}
- 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 — 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
|
| get_ATUS_batch |
Ran ran, violated the contract we drafted |
aripakman/amortized_community_detection/acp/models/acp_model.py code served (permissive licence) · get_code("b7481fd09f5acee5") 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 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
torch.manual_seed(0)
# batch_clusters is a list of lists/tensors where each element contains cluster sizes
# For a batch of 2 samples with different numbers of clusters
batch_clusters = [
torch.LongTensor([2, 3, 1]), # First sample: 3 clusters with sizes 2, 3, 1 (total 6 points)
torch.LongTensor([4, 2]) # Second sample: 2 clusters with sizes 4, 2 (total 6 points)
]
ARGS = {
"batch_clusters": batch_clusters,
"device": None
}
- 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 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
|
| load_module |
Ran ran; our contract draft was wrong, not the code |
aripakman/amortized_community_detection/acp/train_acp.py code served (permissive licence) · get_code("b1050fb2a277612d") 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 tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import os
import sys
from unittest.mock import MagicMock
torch.manual_seed(0)
# Create a temporary module file in memory for testing
# We'll mock the import system to avoid actual file I/O
# The function takes a filename parameter
# It extracts the module name from the filename
# It then imports the module using importlib.import_module
# For testing, we need to provide a valid filename that can be imported
# We'll create a mock module and register it in sys.modules
mock_module = MagicMock()
mock_module.__name__ = 'test_module'
sys.modules['test_module'] = mock_module
# Now we can construct valid arguments
# The filename should be a path that when processed will result in a valid module name
filename = 'test_module.py'
ARGS = {
'filename': filename
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- numpy, 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
|
| load_module |
Ran ran on a synthesized input |
aripakman/attentive_clustering_processes/acp/train_acp.py code served (permissive licence) · get_code("8f772e11e7c48dd5") 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 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 os
import importlib
import sys
from types import ModuleType
# Create a mock module to import
mock_module = ModuleType('test_module')
mock_module.some_function = lambda: "test"
sys.modules['test_module'] = mock_module
# The function expects a filename string
# Since the function uses os.path.splitext and os.path.basename,
# and then tries to import it, we need to provide a valid filename
# that can be imported. The safest approach is to use an actual
# importable module name formatted as a path.
filename = 'test_module.py'
ARGS = {
'filename': filename
}
- 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, 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
|
| relabel |
Ran ran on a synthesized input |
aripakman/attentive_clustering_processes/acp/models/acp_sampler.py code served (permissive licence) · get_code("b45ce271447069e5") 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 list, ndim 1, dtype family int; 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 numpy as np
torch.manual_seed(0)
# Analyze the function:
# - Takes parameter 'cs'
# - Calls cs.copy() - so cs needs to be a copyable object
# - Iterates over len(cs) - so cs needs __len__
# - Accesses cs[i] - so cs needs __getitem__
# - Sets cs[i] = value - so cs needs __setitem__
# - Checks if j not in d - j is used as a dict key
# - Returns cs
# This suggests cs should be a list or array-like of hashable values
# Create a small test case with duplicate values that will be relabeled
cs = [0, 1, 0, 2, 1, 2, 0]
ARGS = {
"cs": cs
}
- 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 list, ndim 1, dtype family int — 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
|
| ACP_Model |
Not yet run unverified (harvested, no recorded run) |
aripakman/amortized_community_detection/acp/models/acp_model.py code served (permissive licence) · get_code("35a8aab4074ebc23") How it ran |