| apply_head_mask_to_model |
Ran ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT) |
cenweizhang/MedCore/medcore_pruning/pruning.py code served (permissive licence) · get_code("2d5b4e5ac88130e4") 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 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 torch.nn as nn
import numpy as np
torch.manual_seed(0)
class SimpleAttention(nn.Module):
def __init__(self, hidden_dim=48, num_heads=12):
super().__init__()
self.num_heads = num_heads
self.head_dim = hidden_dim // num_heads
self.qkv = nn.Linear(hidden_dim, hidden_dim * 3)
self.proj = nn.Linear(hidden_dim, hidden_dim)
def forward(self, x):
return self.proj(x)
class SimpleBlock(nn.Module):
def __init__(self, hidden_dim=48):
super().__init__()
self.attn = SimpleAttention(hidden_dim=hidden_dim, num_heads=12)
def forward(self, x):
return self.attn(x)
class SimpleImageEncoder(nn.Module):
def __init__(self, num_blocks=12, hidden_dim=48):
super().__init__()
self.blocks = nn.ModuleList([SimpleBlock(hidden_dim=hidden_dim) for _ in range(num_blocks)])
def forward(self, x):
for block in self.blocks:
x = block(x)
return x
class SimpleModel(nn.Module):
def __init__(self, num_blocks=12, hidden_dim=48):
super().__init__()
self.image_encoder = SimpleImageEncoder(num_blocks=num_blocks, hidden_dim=hidden_dim)
def forward(self, x):
return self.image_encoder(x)
# Create model
num_blocks = 12
num_heads = 12
model = SimpleModel(num_blocks=num_blocks, hidden_dim=48)
# Create valid head mask: binary mask with shape (num_blocks * num_heads,)
head_mask = np.random.randint(0, 2, size=num_blocks * num_heads).astype(np.float32)
ARGS = {
'model': model,
'head_mask': head_mask,
'num_blocks': num_blocks,
'num_heads': num_heads,
}
- 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 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
|
| apply_mlp_mask_to_model |
Ran ran; our contract draft was wrong, not the code |
cenweizhang/MedCore/medcore_pruning/pruning.py code served (permissive licence) · get_code("88b2d46468cf9a33") 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 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 torch.nn as nn
import numpy as np
torch.manual_seed(0)
class MLPModule(nn.Module):
def __init__(self, mlp_dim):
super().__init__()
self.lin1 = nn.Linear(16, mlp_dim)
self.lin2 = nn.Linear(mlp_dim, 16)
def forward(self, x):
x = self.lin1(x)
x = torch.nn.functional.gelu(x)
x = self.lin2(x)
return x
class TransformerBlock(nn.Module):
def __init__(self, mlp_dim):
super().__init__()
self.mlp = MLPModule(mlp_dim)
def forward(self, x):
return self.mlp(x)
class ImageEncoder(nn.Module):
def __init__(self, num_blocks, mlp_dim):
super().__init__()
self.blocks = nn.ModuleList([TransformerBlock(mlp_dim) for _ in range(num_blocks)])
def forward(self, x):
for block in self.blocks:
x = block(x)
return x
class MedSAMModel(nn.Module):
def __init__(self, num_blocks=12, mlp_dim=8):
super().__init__()
self.image_encoder = ImageEncoder(num_blocks, mlp_dim)
def forward(self, x):
return self.image_encoder(x)
num_blocks = 12
mlp_dim = 8
model = MedSAMModel(num_blocks=num_blocks, mlp_dim=mlp_dim)
neuron_mask = np.ones(num_blocks * mlp_dim, dtype=np.float32)
neuron_mask[::2] = 0
ARGS = {
'model': model,
'neuron_mask': neuron_mask,
'num_blocks': num_blocks
}
- 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 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
|
| compute_boundary_f1 |
Ran ran, honoured the contract we drafted |
cenweizhang/MedCore/medcore_pruning/metrics.py code served (permissive licence) · get_code("bbed6d1a723d39a1") 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 float, 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 numpy as np
# Create small binary masks for testing
# pred: predicted mask
pred = np.array([
[0, 0, 1, 1],
[0, 1, 1, 0],
[1, 1, 0, 0],
[1, 0, 0, 0]
], dtype=bool)
# gt: ground truth mask
gt = np.array([
[0, 1, 1, 1],
[0, 1, 1, 0],
[1, 1, 0, 0],
[0, 0, 0, 0]
], dtype=bool)
ARGS = {
"pred": pred,
"gt": gt,
"radius": 2
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type float, 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
|
| compute_cascade_stats |
Ran ran; our contract draft was wrong, not the code |
cenweizhang/MedCore/medcore_pruning/pruning.py code served (permissive licence) · get_code("1faef889488ec091") 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 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 torch.nn as nn
import numpy as np
torch.manual_seed(0)
# Build a minimal model that satisfies the function's usage
class MiniAttention(nn.Module):
def __init__(self, embed_dim, num_heads):
super().__init__()
self.qkv = nn.Linear(embed_dim, 3 * embed_dim)
self.proj = nn.Linear(embed_dim, embed_dim)
class MiniMLP(nn.Module):
def __init__(self, embed_dim, mlp_dim):
super().__init__()
self.lin1 = nn.Linear(embed_dim, mlp_dim)
self.lin2 = nn.Linear(mlp_dim, embed_dim)
class MiniBlock(nn.Module):
def __init__(self, embed_dim, mlp_dim, num_heads):
super().__init__()
self.attn = MiniAttention(embed_dim, num_heads)
self.mlp = MiniMLP(embed_dim, mlp_dim)
class MiniImageEncoder(nn.Module):
def __init__(self, num_blocks, embed_dim, mlp_dim, num_heads):
super().__init__()
self.blocks = nn.ModuleList([
MiniBlock(embed_dim, mlp_dim, num_heads)
for _ in range(num_blocks)
])
class MiniModel(nn.Module):
def __init__(self, num_blocks, embed_dim, mlp_dim, num_heads):
super().__init__()
self.image_encoder = MiniImageEncoder(num_blocks, embed_dim, mlp_dim, num_heads)
# Construct arguments
num_blocks = 12
num_heads = 12
embed_dim = 768
mlp_dim = 3072
img_size = 1024
patch_size = 16
seq_len = (img_size // patch_size) ** 2
# Create model
model = MiniModel(num_blocks, embed_dim, mlp_dim, num_heads)
# Create head_mask: array of shape (num_blocks * num_heads,) with values 0 or 1
head_mask = np.ones(num_blocks * num_heads, dtype=np.int64)
head_mask[::3] = 0 # Prune some heads
# Create neuron_mask: array of shape (num_blocks * mlp_dim,) with values 0 or 1
neuron_mask = np.ones(num_blocks * mlp_dim, dtype=np.int64)
neuron_mask[::5] = 0 # Prune some neurons
ARGS = {
'model': model,
'head_mask': head_mask,
'neuron_mask': neuron_mask,
'num_blocks': num_blocks,
'num_heads': num_heads,
'img_size': img_size,
'patch_size': patch_size,
}
- 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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| compute_cross_fisher |
Ran ran; our contract draft was wrong, not the code |
cenweizhang/MedCore/medcore_pruning/fisher.py code served (permissive licence) · get_code("baf80ae7dc5ccf40") 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 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
torch.manual_seed(0)
# Construct fisher_m: a dictionary of parameter names to fisher information tensors
fisher_m = {
"layer1.weight": torch.randn(4, 3),
"layer1.bias": torch.randn(4),
"layer2.weight": torch.randn(5, 4),
}
# Construct fisher_s: a dictionary of parameter names to fisher information tensors
# Note: it may have fewer entries than fisher_m (the function uses .get() with default)
fisher_s = {
"layer1.weight": torch.randn(4, 3),
"layer2.weight": torch.randn(5, 4),
# Intentionally missing "layer1.bias" to test the .get() with default behavior
}
ARGS = {
"fisher_m": fisher_m,
"fisher_s": fisher_s,
}
- 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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| compute_dice |
Ran ran, honoured the contract we drafted |
cenweizhang/MedCore/medcore_pruning/metrics.py code served (permissive licence) · get_code("26d78e051b3db046") 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 float, 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 numpy as np
# The function compute_dice takes two parameters: pred and gt
# It converts them to numpy arrays of dtype bool
# It computes the Dice coefficient (overlap metric)
# We need to provide two array-like objects that can be converted to boolean arrays
# Create simple binary prediction and ground truth arrays
pred = np.array([True, False, True, True])
gt = np.array([True, True, False, True])
ARGS = {
"pred": pred,
"gt": gt
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type float, 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
|
| compute_head_scores |
Ran ran, honoured the contract we drafted |
cenweizhang/MedCore/medcore_pruning/scoring.py code served (permissive licence) · get_code("390b8ca528024272") 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 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
import numpy as np
torch.manual_seed(0)
# Build a minimal attention module
class MinimalAttention(nn.Module):
def __init__(self, dim, num_heads):
super().__init__()
self.dim = dim
self.num_heads = num_heads
self.head_dim = dim // num_heads
self.qkv = nn.Linear(dim, 3 * dim, bias=True)
self.proj = nn.Linear(dim, dim, bias=False)
def forward(self, x):
return self.proj(x)
# Build a minimal transformer block
class MinimalBlock(nn.Module):
def __init__(self, dim, num_heads):
super().__init__()
self.attn = MinimalAttention(dim, num_heads)
def forward(self, x):
return self.attn(x)
# Build a minimal image encoder
class MinimalImageEncoder(nn.Module):
def __init__(self, num_blocks, num_heads, dim):
super().__init__()
self.blocks = nn.ModuleList([
MinimalBlock(dim, num_heads) for _ in range(num_blocks)
])
def forward(self, x):
for block in self.blocks:
x = block(x)
return x
# Build the model
class MinimalMedSAM(nn.Module):
def __init__(self, num_blocks, num_heads, dim):
super().__init__()
self.image_encoder = MinimalImageEncoder(num_blocks, num_heads, dim)
def forward(self, x):
return self.image_encoder(x)
# Create model with specific dimensions
num_blocks = 12
num_heads = 12
dim = 48 # Must be divisible by num_heads
model = MinimalMedSAM(num_blocks, num_heads, dim)
# Build sam_params dict with all required attention parameters
sam_params = {}
for l in range(num_blocks):
attn = model.image_encoder.blocks[l].attn
dim_val = attn.dim
head_dim = dim_val // num_heads
qkv_w_key = f'blocks.{l}.attn.qkv.weight'
qkv_b_key = f'blocks.{l}.attn.qkv.bias'
proj_w_key = f'blocks.{l}.attn.proj.weight'
# Create SAM parameters (slightly different from model params to test delta)
sam_params[qkv_w_key] = torch.randn(3 * dim_val, dim_val) * 0.1
sam_params[qkv_b_key] = torch.randn(3 * dim_val) * 0.1
sam_params[proj_w_key] = torch.randn(dim_val, dim_val) * 0.1
# Build fisher dict with Fisher information for all parameters
fisher = {}
for l in range(num_blocks):
attn = model.image_encoder.blocks[l].attn
dim_val = attn.dim
qkv_w_key = f'blocks.{l}.attn.qkv.weight'
qkv_b_key = f'blocks.{l}.attn.qkv.bias'
proj_w_key = f'blocks.{l}.attn.proj.weight'
# Fisher is typically positive, so use abs of randn squared
fisher[qkv_w_key] = torch.abs(torch.randn(3 * dim_val, dim_val)) + 0.01
fisher[qkv_b_key] = torch.abs(torch.randn(3 * dim_val)) + 0.01
fisher[proj_w_key] = torch.abs(torch.randn(dim_val, dim_val)) + 0.01
ARGS = {
'model': model,
'sam_params': sam_params,
'fisher': fisher,
'num_blocks': num_blocks,
'num_heads': num_heads,
}
- 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 tuple, ndim 2, 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
|
| compute_iou |
Ran ran, honoured the contract we drafted |
cenweizhang/MedCore/medcore_pruning/metrics.py code served (permissive licence) · get_code("c3ff88b7bf97c76a") 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 float, 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 numpy as np
# compute_iou expects two array-like inputs that will be converted to boolean arrays
# and used for set operations (union, intersection)
# Create two small boolean-like arrays
pred = np.array([[1, 0, 1, 0],
[0, 1, 1, 0]], dtype=np.uint8)
gt = np.array([[1, 0, 0, 1],
[0, 1, 1, 1]], dtype=np.uint8)
ARGS = {
"pred": pred,
"gt": gt
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type float, 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
|
| compute_mlp_neuron_scores |
Ran ran, honoured the contract we drafted |
cenweizhang/MedCore/medcore_pruning/scoring.py code served (permissive licence) · get_code("bcecb71b17db5fe7") 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 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
import numpy as np
torch.manual_seed(0)
# Build a minimal MedSAM-like model structure
class MLPBlock(nn.Module):
def __init__(self, embed_dim, mlp_dim):
super().__init__()
self.lin1 = nn.Linear(embed_dim, mlp_dim)
self.lin2 = nn.Linear(mlp_dim, embed_dim)
class TransformerBlock(nn.Module):
def __init__(self, embed_dim, mlp_dim):
super().__init__()
self.mlp = MLPBlock(embed_dim, mlp_dim)
class ImageEncoder(nn.Module):
def __init__(self, num_blocks, embed_dim, mlp_dim):
super().__init__()
self.blocks = nn.ModuleList([
TransformerBlock(embed_dim, mlp_dim)
for _ in range(num_blocks)
])
class MedSAMModel(nn.Module):
def __init__(self, num_blocks=3, embed_dim=4, mlp_dim=8):
super().__init__()
self.image_encoder = ImageEncoder(num_blocks, embed_dim, mlp_dim)
# Instantiate model
num_blocks = 3
embed_dim = 4
mlp_dim = 8
model = MedSAMModel(num_blocks=num_blocks, embed_dim=embed_dim, mlp_dim=mlp_dim)
# Build SAM params dictionary (reference parameters)
sam_params = {}
for l in range(num_blocks):
mlp = model.image_encoder.blocks[l].mlp
l1w_key = f'blocks.{l}.mlp.lin1.weight'
l1b_key = f'blocks.{l}.mlp.lin1.bias'
l2w_key = f'blocks.{l}.mlp.lin2.weight'
# Store copies of weights as reference
sam_params[l1w_key] = mlp.lin1.weight.data.clone()
sam_params[l1b_key] = mlp.lin1.bias.data.clone()
sam_params[l2w_key] = mlp.lin2.weight.data.clone()
# Build Fisher dictionary (Fisher information matrix estimates)
fisher = {}
for l in range(num_blocks):
mlp = model.image_encoder.blocks[l].mlp
l1w_key = f'blocks.{l}.mlp.lin1.weight'
l1b_key = f'blocks.{l}.mlp.lin1.bias'
l2w_key = f'blocks.{l}.mlp.lin2.weight'
# Fisher info as small positive values (same shape as weights)
fisher[l1w_key] = torch.ones_like(mlp.lin1.weight.data) * 0.1
fisher[l1b_key] = torch.ones(mlp_dim) * 0.1
fisher[l2w_key] = torch.ones_like(mlp.lin2.weight.data) * 0.1
ARGS = {
'model': model,
'sam_params': sam_params,
'fisher': fisher,
'num_blocks': num_blocks,
}
- 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 tuple, ndim 2, 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
|
| file_sha256 |
Ran ran; our contract draft was wrong, not the code |
cenweizhang/MedCore/medcore_pruning/utils.py code served (permissive licence) · get_code("f8aa46dcd86ec93d") 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 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 hashlib
import tempfile
from pathlib import Path
# Create a temporary file with known content
with tempfile.NamedTemporaryFile(mode='wb', delete=False, suffix='.bin') as f:
temp_path = f.name
f.write(b'test content for sha256 hashing' * 100)
ARGS = {
'path': temp_path
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type 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
|
| parse_config |
Ran ran; our contract draft was wrong, not the code |
cenweizhang/MedCore/medcore_pruning/utils.py code served (permissive licence) · get_code("94d3f90f149a1f97") 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 Namespace. 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 json
import tempfile
from pathlib import Path
from argparse import ArgumentParser
# Create a temporary directory and JSON config file
temp_dir = tempfile.TemporaryDirectory()
config_path = Path(temp_dir.name) / "config.json"
# Write a valid JSON config with some default arguments
config_data = {
"learning_rate": 0.001,
"batch_size": 32,
"epochs": 10
}
with config_path.open('w', encoding='utf-8') as f:
json.dump(config_data, f)
# Create an ArgumentParser with the expected arguments
parser = ArgumentParser()
parser.add_argument('--learning_rate', type=float, default=0.01)
parser.add_argument('--batch_size', type=int, default=16)
parser.add_argument('--epochs', type=int, default=5)
# Define argv to test with - explicitly provide --config
argv = ['--config', str(config_path)]
ARGS = {
'parser': parser,
'argv': argv
}
- 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 Namespace — a Namespace output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Namespace 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
|
| save_checkpoint |
Ran ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT) |
cenweizhang/MedCore/medcore_pruning/checkpoints.py code served (permissive licence) · get_code("ec89cd9780053c16") 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 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 torch.nn as nn
from pathlib import Path
import tempfile
torch.manual_seed(0)
# Create a minimal model with the required structure
class MinimalAttention(nn.Module):
def __init__(self, num_heads=2):
super().__init__()
self.num_heads = num_heads
self.linear = nn.Linear(4, 4)
def forward(self, x):
return self.linear(x)
class MinimalMLP(nn.Module):
def __init__(self, in_features=4, out_features=8):
super().__init__()
self.lin1 = nn.Linear(in_features, out_features)
self.lin2 = nn.Linear(out_features, in_features)
def forward(self, x):
return self.lin2(self.lin1(x))
class MinimalBlock(nn.Module):
def __init__(self, num_heads=2, mlp_out=8):
super().__init__()
self.attn = MinimalAttention(num_heads=num_heads)
self.mlp = MinimalMLP(in_features=4, out_features=mlp_out)
def forward(self, x):
return self.mlp(self.attn(x))
class MinimalImageEncoder(nn.Module):
def __init__(self):
super().__init__()
self.blocks = nn.ModuleList([
MinimalBlock(num_heads=2, mlp_out=8),
MinimalBlock(num_heads=3, mlp_out=12),
])
def forward(self, x):
for block in self.blocks:
x = block(x)
return x
class MinimalModel(nn.Module):
def __init__(self):
super().__init__()
self.image_encoder = MinimalImageEncoder()
self._medcore_model_type = 'vit_b'
def forward(self, x):
return self.image_encoder(x)
model = MinimalModel()
# Create binary masks for pruning
# head_mask: total heads = 2 + 3 = 5
head_mask = torch.tensor([1.0, 1.0, 0.0, 1.0, 1.0])
# neuron_mask: total out_features = 8 + 12 = 20
neuron_mask = torch.tensor([1.0] * 15 + [0.0] * 5)
# Create metadata
metadata = {
"description": "test checkpoint",
"version": 1,
"custom_info": 42,
}
# Create temporary directory for checkpoint
temp_dir = tempfile.mkdtemp()
checkpoint_path = Path(temp_dir) / "checkpoint.pt"
ARGS = {
'path': checkpoint_path,
'model': model,
'head_mask': head_mask,
'neuron_mask': neuron_mask,
'metadata': metadata,
}
- 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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| segmentation_logits |
Ran ran, honoured the contract we drafted |
cenweizhang/MedCore/medcore_pruning/training.py code served (permissive licence) · get_code("66d6fd877bf3b503") 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 Tensor, ndim 4, dtype family float, shape (2, 1, 32, 32) 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)
# Stand-in classes for model components
class ImageEncoder(nn.Module):
def forward(self, images):
# images shape: [batch, 3, height, width]
# Return embeddings of shape [batch, embedding_dim, h, w]
batch_size = images.shape[0]
return torch.randn(batch_size, 8, 16, 16)
class PromptEncoder(nn.Module):
def forward(self, points, boxes, masks):
# Return sparse and dense embeddings
# sparse: [batch, num_prompts, embedding_dim]
# dense: [batch, embedding_dim, h, w]
batch_size = boxes.shape[0] if boxes is not None else 2
sparse = torch.randn(batch_size, 4, 12)
dense = torch.randn(batch_size, 8, 16, 16)
return sparse, dense
def get_dense_pe(self):
# Return positional encoding
return torch.randn(1, 8, 16, 16)
class MaskDecoder(nn.Module):
def forward(self, image_embeddings, image_pe, sparse_prompt_embeddings, dense_prompt_embeddings, multimask_output):
# Return logits and masks
batch_size = image_embeddings.shape[0]
logits = torch.randn(batch_size, 1, 32, 32)
masks = torch.randn(batch_size, 1, 32, 32)
return logits, masks
class SegmentationModel(nn.Module):
def __init__(self):
super().__init__()
self.image_encoder = ImageEncoder()
self.prompt_encoder = PromptEncoder()
self.mask_decoder = MaskDecoder()
# Create the model
model = SegmentationModel()
# Create batch with proper structure
batch = {
'image': torch.randn(2, 3, 64, 64), # batch_size=2, channels=3
'bbox': torch.tensor([[10.0, 20.0, 50.0, 60.0], [15.0, 25.0, 55.0, 65.0]]) # [batch, 4]
}
device = 'cpu'
ARGS = {
'model': model,
'batch': batch,
'device': device
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 4, dtype family float, shape (2, 1, 32, 32) — shape (2, 1, 32, 32) 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
|
| segmentation_loss |
Ran ran; our contract draft was wrong, not the code |
cenweizhang/MedCore/medcore_pruning/training.py code served (permissive licence) · get_code("3326ff201e710fe5") 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 Tensor, 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 torch
import torch.nn as nn
torch.manual_seed(0)
# Create small tensors for logits and target
# logits: model output, shape (batch, channels, height, width)
# target: ground truth binary mask, same shape as logits
batch_size = 2
channels = 1
height = 4
width = 3
logits = torch.randn(batch_size, channels, height, width)
target = torch.randint(0, 2, (batch_size, channels, height, width)).float()
ARGS = {
"logits": logits,
"target": target,
}
- 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 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
|
| validate_device |
Ran ran; our contract draft was wrong, not the code |
cenweizhang/MedCore/medcore_pruning/utils.py code served (permissive licence) · get_code("11b435db8e74e9a2") 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 device. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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)
ARGS = {
'name': 'cpu'
}
- 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 device — a device output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a device 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
|
| compute_boundary_sampling_weights |
Not yet run unverified (harvested, no recorded run) |
cenweizhang/MedCore/medcore_pruning/evaluation.py code served (permissive licence) · get_code("dd312e008248930c") How it ran |
| compute_diagonal_fisher_boundary_aware |
Not yet run unverified (harvested, no recorded run) |
cenweizhang/MedCore/medcore_pruning/fisher.py code served (permissive licence) · get_code("97de9bfe5b3e05f1") How it ran |
| eval_all |
Not yet run unverified (harvested, no recorded run) |
cenweizhang/MedCore/medcore_pruning/evaluation.py code served (permissive licence) · get_code("94c2f9d0ac628556") How it ran |
| export_compact_model |
Not yet run unverified (harvested, no recorded run) |
cenweizhang/MedCore/medcore_pruning/compact.py code served (permissive licence) · get_code("aa3f8bc40bbfd638") How it ran |
| load_checkpoint |
Not yet run unverified (harvested, no recorded run) |
cenweizhang/MedCore/medcore_pruning/checkpoints.py code served (permissive licence) · get_code("43f2aa47c9481875") How it ran |
| load_compact_checkpoint |
Not yet run unverified (harvested, no recorded run) |
cenweizhang/MedCore/medcore_pruning/compact.py code served (permissive licence) · get_code("17dadc3fb49927f7") How it ran |
| load_sam_encoder_params |
Not yet run unverified (harvested, no recorded run) |
cenweizhang/MedCore/medcore_pruning/scoring.py code served (permissive licence) · get_code("32a9ca5d937d9531") How it ran |
| run_epoch |
Not yet run unverified (harvested, no recorded run) |
cenweizhang/MedCore/medcore_pruning/training.py code served (permissive licence) · get_code("858e877d2f3108c4") How it ran |
| save_compact_checkpoint |
Not yet run unverified (harvested, no recorded run) |
cenweizhang/MedCore/medcore_pruning/compact.py code served (permissive licence) · get_code("ae45b1e40594e114") How it ran |