{ "model": "sam2.1-hiera-tiny (512 encoder/decoder split)", "upstream": { "model": "facebook/sam2.1-hiera-tiny", "revision": "de431c4043854a71d8101e17995dfe596bf101a5", "official": true, "license": "Apache-2.0", "files": { "model.safetensors": { "sha256": "48c14467e5cf9e51870511feb72c89688e82dd74523142c0538b663e193ac2a7" } }, "note": "transformers Sam2Model port published by the SAM 2 authors on the Hub" }, "versions": { "python": "3.12.15+meta", "torch": "2.14.1+cpu", "torchao": "0.18.0+cpu", "executorch": "1.5.1+cpu", "executorch_git": "3b60683923245cf472b7323426920e15623ba361", "transformers": "5.19.0", "huggingface_hub": "2.2.0" }, "export": { "api": "torch.export.export(strict=False) -> to_edge_transform_and_lower(partitioner=[WebGPUPartitioner()]) -> to_executorch(), one program per module", "partitioner": "executorch.backends.webgpu.partitioner.WebGPUPartitioner() (default compile options; wraps VulkanPartitioner)", "model_code": "transformers Sam2Model; attention through torch.ops.et_vk.sdpa (transformers attention backend, recipes/sam2-hiera-tiny.py:et_vk_attention); config image_size overridden 1024 -> 512", "programs": { "sam2_encoder.pte": { "method": "forward", "inputs": [ { "name": "pixels", "shape": [ 1, 3, 512, 512 ], "dtype": "float32" } ], "outputs": [ { "name": "image_embeddings", "shape": [ 1, 256, 32, 32 ], "dtype": "float32", "note": "no_memory_embedding added" }, { "name": "hr0", "shape": [ 1, 256, 128, 128 ], "dtype": "float32", "note": "before mask_decoder.conv_s0" }, { "name": "hr1", "shape": [ 1, 256, 64, 64 ], "dtype": "float32", "note": "before mask_decoder.conv_s1" } ] }, "sam2_decoder.pte": { "method": "forward", "prompt_tokens": 3, "inputs": [ { "name": "image_embeddings", "shape": [ 1, 256, 32, 32 ], "dtype": "float32" }, { "name": "image_pe", "shape": [ 1, 256, 32, 32 ], "dtype": "float32" }, { "name": "sparse", "shape": [ 1, 1, 3, 256 ], "dtype": "float32" }, { "name": "dense", "shape": [ 1, 256, 32, 32 ], "dtype": "float32" }, { "name": "hr0", "shape": [ 1, 256, 128, 128 ], "dtype": "float32" }, { "name": "hr1", "shape": [ 1, 256, 64, 64 ], "dtype": "float32" } ], "outputs": [ { "name": "masks", "shape": [ 1, 3, 128, 128 ], "dtype": "float32", "note": "logits, mask tokens 1..3" }, { "name": "iou_scores", "shape": [ 1, 1, 3 ], "dtype": "float32" }, { "name": "object_score_logits", "shape": [ 1, 1, 1 ], "dtype": "float32" } ] } }, "prompt_tables": { "prompt_gaussian.bin": { "shape": [ 2, 128 ], "dtype": "float32 little-endian" }, "prompt_point_embed_bg.bin": { "shape": [ 256 ], "dtype": "float32 little-endian" }, "prompt_point_embed_fg.bin": { "shape": [ 256 ], "dtype": "float32 little-endian" }, "prompt_box_tl.bin": { "shape": [ 256 ], "dtype": "float32 little-endian" }, "prompt_box_br.bin": { "shape": [ 256 ], "dtype": "float32 little-endian" }, "prompt_not_a_point.bin": { "shape": [ 256 ], "dtype": "float32 little-endian" }, "prompt_img_pos.bin": { "shape": [ 1, 256, 32, 32 ], "dtype": "float32 little-endian" }, "prompt_dense.bin": { "shape": [ 1, 256, 32, 32 ], "dtype": "float32 little-endian" } }, "prompt_table_sources": { "prompt_gaussian.bin": "shared_image_embedding.positional_embedding", "prompt_point_embed_bg.bin": "prompt_encoder.point_embed.weight[0]", "prompt_point_embed_fg.bin": "prompt_encoder.point_embed.weight[1]", "prompt_box_tl.bin": "prompt_encoder.point_embed.weight[2]", "prompt_box_br.bin": "prompt_encoder.point_embed.weight[3]", "prompt_not_a_point.bin": "prompt_encoder.not_a_point_embed.weight[0]", "prompt_img_pos.bin": "Sam2Model.get_image_wide_positional_embeddings() with image_size=512", "prompt_dense.bin": "prompt_encoder.no_mask_embed.weight broadcast to [1,256,32,32]" }, "graph_rewrites": [ "Hiera q-pooling of windowed tensors [nW,h,w,C] done as one batch-1 max_pool2d over the windows stacked along H (exact: h is a multiple of the stride); keeps all pools in the delegate", "attention via torch.ops.et_vk.sdpa (same math as torch SDPA; checked in validation.json)", "decoder: a not-a-point token directly after another one gets an additive -1e9 key bias in every attention (computed in-graph from the sparse input), so padding up to the fixed token count does not change the result", "Hiera position embedding (bicubic pos_embed resize + tiled window embedding) for the fixed input size computed in eager and stored as a constant" ], "differences_from_upstream_pipeline": [ "input 512x512 instead of 1024x1024 (masks 128x128 instead of 256x256)", "fixed 3 prompt tokens per decode: points, box corners, one not-a-point pad, then padding pads that the decoder masks out (exactly upstream's prompt for any prompt that fits; larger prompts are composed by the site)", "no mask prompt input (dense = no_mask_embed)" ], "preprocessing_outside_graph": "RGB, resize to 512x512 without keeping aspect, /255, ImageNet mean/std", "dtype": "float32", "quantization": "none (fp32)" }, "files": { "prompt_box_br.bin": { "bytes": 1024, "sha256": "a0df40a29af4a9b65d390ae46913d4170762a306fc8061ea87f1d8f4a4a1b0d5" }, "prompt_box_tl.bin": { "bytes": 1024, "sha256": "96c208c44e95f7044bc480951be257c415cfa9c91db907e4575ae3c92d09e6b7" }, "prompt_dense.bin": { "bytes": 1048576, "sha256": "52cece57b549dc81439c1156a07a25ff02db8cb81329e8eefb68c90457a884f3" }, "prompt_gaussian.bin": { "bytes": 1024, "sha256": "c37a6a9361886286fc3e868dd279dfa4703919e3fee65c07a07e5a75e980d84f" }, "prompt_img_pos.bin": { "bytes": 1048576, "sha256": "89dc4182ee4ac6a366dbfd0e9b825e4d7b6e88ded91b2ab06604eb5139e1cc2c" }, "prompt_not_a_point.bin": { "bytes": 1024, "sha256": "19771c067b922d9d652e6f3dd1f6e2976c68abb8e6fd9db571255ae37687ea50" }, "prompt_point_embed_bg.bin": { "bytes": 1024, "sha256": "91c432d10fcef8e32ce561eb4820beb6a772a61a3a937d7c2af8597061759cfa" }, "prompt_point_embed_fg.bin": { "bytes": 1024, "sha256": "2e037dab5bee002d94bdb12d3141ab952cfe2315f0c9feb53a7c78a7e656ed33" }, "sam2_decoder.pte": { "bytes": 16949252, "sha256": "57b91034acc71be2ce1835ea546a174295daee1046e40db0743e0238ef11e278" }, "sam2_decoder_portable.pte": { "bytes": 16968388, "sha256": "cac19779cd445105fdfed5599bf4f6ed041fbc4d006c931be8bc2c3cdf3c4655", "note": "CPU-only validation artifact (portable kernels, no delegate; torch SDPA instead of et_vk.sdpa); not for release" }, "sam2_encoder.pte": { "bytes": 115248512, "sha256": "30f9fb469b779558b6b5c7c3eb995c50e1213ffbe082e31430c929ba2b3ffe20" }, "sam2_encoder_portable.pte": { "bytes": 115320192, "sha256": "b18fc39b847470555f8b69401a2acc67a39f635124ce5ac9c2d6e25917fe44f7", "note": "CPU-only validation artifact (portable kernels, no delegate; torch SDPA instead of et_vk.sdpa); not for release" } }, "graph": { "sam2_encoder": { "non_delegated_kernels": {}, "delegates": [ { "id": "VulkanBackend", "ops": { "et_vk.prepack.default": 2, "aten.convolution.default": 5, "aten.clone.default": 32, "aten.permute_copy.default": 83, "aten.add.Tensor": 27, "aten.native_layer_norm.default": 24, "aten.constant_pad_nd.default": 9, "aten.view_copy.default": 114, "aten.linear.default": 51, "aten.slice_copy.Tensor": 46, "aten.squeeze_copy.dims": 36, "et_vk.sdpa.default": 12, "aten.gelu.default": 12, "aten.max_pool2d_with_indices.default": 6, "aten.upsample_nearest2d.vec": 1 }, "inputs": 1, "outputs": 3 } ], "io": { "methods": [ "forward" ], "inputs": [ { "shape": [ 1, 3, 512, 512 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] } ], "outputs": [ { "shape": [ 1, 256, 32, 32 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] }, { "shape": [ 1, 256, 128, 128 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] }, { "shape": [ 1, 256, 64, 64 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] } ] }, "io_contract": "matches the previous export (shapes, fp32, contiguous dim order, single forward method)" }, "sam2_decoder": { "non_delegated_kernels": {}, "delegates": [ { "id": "VulkanBackend", "ops": { "et_vk.prepack.default": 13, "aten.sub.Tensor": 2, "aten.abs.default": 1, "aten.sum.dim_IntList": 1, "aten.mul.Tensor": 3, "aten.relu.default": 15, "aten.slice_copy.Tensor": 5, "aten.full.default": 1, "aten.clone.default": 23, "aten.cat.default": 4, "aten.unsqueeze_copy.default": 16, "aten.convolution.default": 4, "aten.repeat.default": 1, "aten.add.Tensor": 25, "aten.view_copy.default": 57, "aten.permute_copy.default": 36, "aten.squeeze_copy.dims": 34, "aten.linear.default": 47, "aten.expand_copy.default": 7, "et_vk.sdpa.default": 7, "aten.native_layer_norm.default": 10, "aten.bmm.default": 4, "aten.select_copy.int": 7, "aten.gelu.default": 2, "aten.sigmoid.default": 1 }, "inputs": 6, "outputs": 3 } ], "io": { "methods": [ "forward" ], "inputs": [ { "shape": [ 1, 256, 32, 32 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] }, { "shape": [ 1, 256, 32, 32 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] }, { "shape": [ 1, 1, 3, 256 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] }, { "shape": [ 1, 256, 32, 32 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] }, { "shape": [ 1, 256, 128, 128 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] }, { "shape": [ 1, 256, 64, 64 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] } ], "outputs": [ { "shape": [ 1, 3, 128, 128 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2, 3 ] }, { "shape": [ 1, 1, 3 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2 ] }, { "shape": [ 1, 1, 1 ], "dtype": "FLOAT", "dim_order": [ 0, 1, 2 ] } ] }, "io_contract": "matches the previous export (shapes, fp32, contiguous dim order, single forward method)" } }, "command": "python recipes/sam2-hiera-tiny.py --out out/sam2.1-hiera-tiny" }