SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.09827 · 2024

FastSAM3D: An Efficient Segment Anything Model for 3D Volumetric Medical Images

arXiv · PDF · Open in the Atlas

Code that ran

5 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 2 failures of our instrument; 7 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2403.09827.json · badge: /api/ran/2403.09827.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
arcadelab/fastsam3d canonical (classifier label)
classifier basis: census
5 ran · 7 no recorded run
FunctionStatusWhere it lives
batch_forward Ran
ran on a synthesized input
arcadelab/fastsam3d/val_2d.py
code served (permissive licence) · get_code("77e28e9382f984ce")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. 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
import torch.nn as nn
import torch.nn.functional as F

torch.manual_seed(0)

class PromptEncoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.dense_pe_embed = nn.Parameter(torch.randn(1, 256, 64, 64))
    
    def forward(self, points=None, boxes=None, masks=None):
        # Return sparse and dense embeddings
        sparse_embeddings = torch.randn(2, 1, 256)
        dense_embeddings = torch.randn(2, 256, 64, 64)
        return sparse_embeddings, dense_embeddings
    
    def get_dense_pe(self):
        return self.dense_pe_embed

class MaskDecoder(nn.Module):
    def __init__(self):
        super().__init__()
    
    def forward(self, image_embeddings, image_pe, sparse_prompt_embeddings, dense_prompt_embeddings, multimask_output=False):
        # Return low_res_masks and iou_predictions
        low_res_masks = torch.randn(2, 1, 64, 64, 64)
        iou_predictions = torch.randn(2, 1)
        return low_res_masks, iou_predictions

class SAMModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.prompt_encoder = PromptEncoder()
        self.mask_decoder = MaskDecoder()

# Construct the SAM model
sam_model = SAMModel()

# Construct image embedding (batch=2, channels=256, depth=64, height=64, width=64)
image_embedding = torch.randn(2, 256, 64, 64, 64)

# Construct gt3D (ground truth 3D, batch=2, channels=1, depth=32, height=32, width=32)
gt3D = torch.randn(2, 1, 32, 32, 32)

# Construct low_res_masks (batch=2, channels=1, depth=64, height=64, width=64)
low_res_masks = torch.randn(2, 1, 64, 64, 64)

# Construct points (can be None or a tensor)
points = None

# Device (CPU only)
device = 'cpu'

ARGS = {
    'sam_model': sam_model,
    'image_embedding': image_embedding,
    'gt3D': gt3D,
    'low_res_masks': low_res_masks,
    'points': points,
    '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 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
compute_dice Ran
ran, honoured the contract we drafted
arcadelab/fastsam3d/validation_student.py
code served (permissive licence) · get_code("615905eb1431bc23")
How it ran

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

# Examine the function:
# - mask_gt: needs .sum() method and & operator (bitwise AND)
# - mask_pred: needs .sum() method and & operator (bitwise AND)
# Both appear to be numpy arrays or similar array-like objects that support logical operations

# Create two small binary masks (2D arrays for ground truth and prediction)
torch.manual_seed(0)

# Ground truth mask: 4x3 array with some True values
mask_gt = np.array([
    [True, False, True],
    [False, True, False],
    [True, True, False],
    [False, False, True]
], dtype=bool)

# Predicted mask: 4x3 array with some True values (different from gt)
mask_pred = np.array([
    [True, True, False],
    [False, True, True],
    [True, False, False],
    [False, True, True]
], dtype=bool)

ARGS = {
    'mask_gt': mask_gt,
    'mask_pred': mask_pred
}
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 float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
arcadelab/fastsam3d/val_2d.py
code served (permissive licence) · get_code("04b1148082a2d310")
How it ran

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

# Create sample binary masks for semantic segmentation
# These should be boolean arrays or arrays that can be converted to boolean

# Ground truth semantic segmentation mask (4x3 array)
gt_semantic_seg = np.array([
    [True, False, True],
    [False, True, False],
    [True, True, False],
    [False, False, True]
], dtype=bool)

# Predicted mask (4x3 array, same shape as gt)
pred_mask = np.array([
    [True, True, False],
    [False, True, True],
    [True, False, False],
    [False, False, True]
], dtype=bool)

ARGS = {
    'pred_mask': pred_mask,
    'gt_semantic_seg': gt_semantic_seg
}
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 float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
get_next_click3D_torch Ran
ran; our contract draft was wrong, not the code
arcadelab/fastsam3d/utils/click_method.py
code served (permissive licence) · get_code("5319e20cdab18b32")
How it ran

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

import torch
import numpy as np

torch.manual_seed(0)
np.random.seed(0)

# Create small 3D tensors for testing
# prev_seg: predicted segmentation masks (batch_size, depth, height, width)
# Shape: (2, 4, 3, 5) - batch=2, depth=4, height=3, width=5
prev_seg = torch.rand(2, 4, 3, 5)

# gt_semantic_seg: ground truth semantic segmentation (batch_size, depth, height, width)
# Shape: (2, 4, 3, 5) - same spatial dims as prev_seg
gt_semantic_seg = torch.rand(2, 4, 3, 5)

# Make some values clearly positive/negative for interesting test case
prev_seg[0, 0:2, 0:2, 0:2] = 0.8  # High predicted values
gt_semantic_seg[0, 1:3, 1:2, 1:3] = 0.8  # Different location for ground truth
prev_seg[1, 2:4, 1:3, 2:4] = 0.2  # Low predicted values
gt_semantic_seg[1, 0:2, 0:2, 0:2] = 0.9  # Different location for ground truth

ARGS = {
    "prev_seg": prev_seg,
    "gt_semantic_seg": gt_semantic_seg,
}
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 — 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_next_click3D_torch_2 Ran
ran; our contract draft was wrong, not the code
arcadelab/fastsam3d/utils/click_method.py
code served (permissive licence) · get_code("6a7640b1cb51d789")
How it ran

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

import torch
import numpy as np

torch.manual_seed(0)

# Create small sample tensors for the function
# prev_seg: predicted segmentation (batch_size=2, channels=1, depth=4, height=3, width=3)
prev_seg = torch.rand(2, 1, 4, 3, 3) * 0.8  # Values between 0 and 0.8

# gt_semantic_seg: ground truth semantic segmentation (same shape as prev_seg)
gt_semantic_seg = torch.randint(0, 2, (2, 1, 4, 3, 3)).float()

# Ensure there are some True values in both masks to avoid empty argwhere
prev_seg[0, 0, 0, 0, 0] = 0.7  # positive prediction
gt_semantic_seg[0, 0, 0, 0, 0] = 1  # positive ground truth
prev_seg[1, 0, 1, 1, 1] = 0.3  # negative prediction
gt_semantic_seg[1, 0, 2, 2, 2] = 1  # positive ground truth (false negative)

ARGS = {
    "prev_seg": prev_seg,
    "gt_semantic_seg": gt_semantic_seg,
}
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 — 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
build_sam3D_vit_b Not yet run
unverified (harvested, no recorded run)
arcadelab/fastsam3d/segment_anything/build_ls_sam3d.py
code served (permissive licence) · get_code("509d016b2e10d39d")
How it ran

no invocation recorded.

build_sam3D_vit_h Not yet run
unverified (harvested, no recorded run)
arcadelab/fastsam3d/segment_anything/build_ls_sam3d.py
code served (permissive licence) · get_code("794cf331a94c228b")
How it ran

no invocation recorded.

build_sam3D_vit_l Not yet run
unverified (harvested, no recorded run)
arcadelab/fastsam3d/segment_anything/build_ls_sam3d.py
code served (permissive licence) · get_code("a4b3c8964f3dca03")
How it ran

no invocation recorded.

build_sam_vit_b Not yet run
unverified (harvested, no recorded run)
arcadelab/fastsam3d/segment_anything/build_sam.py
code served (permissive licence) · get_code("8ceb13577d0726d6")
How it ran

no invocation recorded.

build_sam_vit_h Not yet run
unverified (harvested, no recorded run)
arcadelab/fastsam3d/segment_anything/build_sam.py
code served (permissive licence) · get_code("49ef6e492e9adbf9")
How it ran

no invocation recorded.

build_sam_vit_l Not yet run
unverified (harvested, no recorded run)
arcadelab/fastsam3d/segment_anything/build_sam.py
code served (permissive licence) · get_code("3cd7bd07d3ca22b8")
How it ran

no invocation recorded.

postprocess_masks Not yet run
unverified (harvested, no recorded run)
arcadelab/fastsam3d/validation_student.py
code served (permissive licence) · get_code("1116cff8750c3e55")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 7 are also present in other papers whose code we hold (7 with at least one paper dated earlier, 0 the same month, 0 later) and 5 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
build_sam3D_vit_b 1 other paper
1 dated earlier
2310.15161 (2023-10)
SAM-Med3D: Towards General-purpose Segmentation Models for Volumetric Medical Images
build_sam3D_vit_h 1 other paper
1 dated earlier
2310.15161 (2023-10)
SAM-Med3D: Towards General-purpose Segmentation Models for Volumetric Medical Images
build_sam3D_vit_l 1 other paper
1 dated earlier
2310.15161 (2023-10)
SAM-Med3D: Towards General-purpose Segmentation Models for Volumetric Medical Images
build_sam_vit_b 1 other paper
1 dated earlier
2310.15161 (2023-10)
SAM-Med3D: Towards General-purpose Segmentation Models for Volumetric Medical Images
build_sam_vit_h 1 other paper
1 dated earlier
2310.15161 (2023-10)
SAM-Med3D: Towards General-purpose Segmentation Models for Volumetric Medical Images
build_sam_vit_l 1 other paper
1 dated earlier
2310.15161 (2023-10)
SAM-Med3D: Towards General-purpose Segmentation Models for Volumetric Medical Images
get_next_click3D_torch 1 other paper
1 dated earlier
2310.15161 (2023-10)
SAM-Med3D: Towards General-purpose Segmentation Models for Volumetric Medical Images

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Segment anything models (SAMs) are gaining attention for their zero-shot generalization capability in segmenting objects of unseen classes and in unseen domains when properly prompted. Interactivity is a key strength of SAMs, allowing users to iteratively provide prompts that specify objects of interest to refine outputs. However, to realize the interactive use of SAMs for 3D medical imaging tasks, rapid inference times are necessary. High memory requirements and long processing delays remain constraints that hinder the adoption of SAMs for this purpose. Specifically, while 2D SAMs applied to 3D volumes contend with repetitive computation to process all slices independently, 3D SAMs suffer from an exponential increase in model parameters and FLOPS. To address these challenges, we present FastSAM3D which accelerates SAM inference to 8 milliseconds per 128*128*128 3D volumetric image on an NVIDIA A100 GPU. This speedup is accomplished through 1) a novel layer-wise progressive distillation scheme that enables knowledge transfer from a complex 12-layer ViT-B to a lightweight 6-layer ViT-Tiny variant encoder without training from scratch; and 2) a novel 3D sparse flash attention to replace vanilla attention operators, substantially reducing memory needs and improving parallelization. Experiments on three diverse datasets reveal that FastSAM3D achieves a remarkable speedup of 527.38x compared to 2D SAMs and 8.75x compared to 3D SAMs on the same volumes without significant performance decline. Thus, FastSAM3D opens the door for low-cost truly interactive SAM-based 3D medical imaging segmentation with commonly used GPU hardware. Code is available at https://github.com/arcadelab/FastSAM3D.

For agents

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

get_harvested_code_for_paper("2403.09827")
get_code_for_paper("2403.09827")
have("2403.09827")

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

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

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

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

Connect an agent — have() is free.