embeddinggemma-2 on Tenstorrent p150

Derived from google/embeddinggemma-2 (Google DeepMind), with unmodified weights downloaded from that repository. Official code: the embedding_gemma2 model of Hugging Face transformers and sentence-transformers. This is a third-party port, not affiliated with or endorsed by Google. See the original model card for training details, the evaluation and the Gemma Prohibited Use Policy.

EmbeddingGemma 2 maps text (100+ languages and code), images, video, audio and interleaved mixtures of them into one 768-dimensional embedding space for retrieval, classification, clustering and similarity; vectors can be truncated to 512, 256 or 128 dimensions (Matryoshka) and re-normalized. A 24-layer bidirectional Gemma-4 encoder (hidden size 512, per-layer embeddings, 270 M parameters with the token table) reads the text tokens and the soft tokens of a 16-layer vision tower (images at 70 to 1120 tokens, video at one frame per second) and a 12-layer conformer audio tower (25 tokens per second), and the token outputs are mean-pooled and L2-normalized, exactly SentenceTransformer.encode. On the device every stage runs in tt-nn operations with one trace per shape bucket; the sequences of a batch are packed end to end (no padding) with block-diagonal attention. Tokenization, image resizing, the log-mel front end, the token-table lookup and the final normalization run on the host CPU and are bit-exact with the official processors. The server speaks the OpenAI embeddings API for text and a native API for every modality, and merges concurrent requests into shared device launches.

Runs on Tenstorrent p150 (mesh P150).

Packaged and published with tt-model-manager 0.1.0 (manifest schema 5.1).

At a glance

Hardware p150
License apache-2.0

Intended use

Embedding text, code, images, video and audio on one Tenstorrent p150 for multimodal semantic search, retrieval-augmented generation, classification, clustering and similarity, from single low-latency queries to batches of documents.

Prerequisites

  • The Tenstorrent CLI, tt: uv tool install tenstorrent (or use tt-model alone, see the Quickstart)
  • Docker
  • Tenstorrent hardware: p150
  • About 1.6 GB of free disk for the weights (fetched once into the Hugging Face cache), plus the container image
  • Time for the first start: it compiles about 2,200 device kernels (18 min measured on a busy 8-core host, less on an idle one); they are cached, and later starts are ready in about 1 minute

Quickstart

tt serve changh95/embeddinggemma-2

tt serve downloads the Docker image and the google/embeddinggemma-2 at f9972ac22e696a105c482202646979e33e4b5a1e weights (into your HF cache; they are not in the image), then starts the model's own HTTP server on port 20000 (or the next free port, if that one is busy). The first start compiles kernels for your device, which takes several minutes; the server is ready when it logs Application startup complete.

Without tt-cli: tt-model serve changh95/embeddinggemma-2.

On the port tt serve reported:

curl -s localhost:20000/v1/embeddings -H 'Content-Type: application/json' \
  -d '{"input": ["What causes the northern lights?"], "prompt_name": "SearchQuery", "dimensions": 256}' | head -c 300
IMG=$(base64 -w0 photo.jpg)
curl -s localhost:20000/embed -H 'Content-Type: application/json' \
  -d "{\"inputs\": [{\"image\": \"$IMG\"}, {\"text\": \"a photo of a cat\"}]}" | head -c 300

Capabilities

This package exposes the model's own HTTP server on port 20000, not an OpenAI-compatible chat API โ€” its request and response shapes are the model's own. See the author's notes for the payload it expects.

POST /v1/embeddings is OpenAI-compatible for text (input, model, encoding_format float | base64, dimensions 768 | 512 | 256 | 128, user; extensions prompt_name / prompt); POST /embed takes every modality; POST /similarity scores targets against source; GET /health, GET /info (engines, device, configuration, limits, the 20 task prompts), GET /v1/models.

The model is trained with task prefixes for text: queries task: search result | query: ... (prompt_name: SearchQuery), documents title: none | text: ... (Document), and Classification, Clustering, SentenceSimilarity, QuestionAnswering, FactChecking, CodeRetrieval, ... (GET /info lists all). Images, video and audio are sent without a prefix.

request field (/embed) values default meaning
inputs list of up to EMBGEMMA_MAX_INPUTS inputs: a string, or an object with text, image (base64 file), audio (base64 WAV, or {"array": [...], "sampling_rate": sr}), video ({"frames": [base64 images], "fps": f}) keys (lists allowed; key order = sequence order), or {"content": [{"type": "text", "text"}, {"type": "image", "image"}, ...]} required one embedding per input; placeholders <|image|> / <|audio|> / <|video|> in the text place the media
prompt_name / prompt a task name / any text none task prefix
dimensions 768, 512, 256, 128 768 Matryoshka truncation, re-normalized
normalize true, false true false: the model's normalized 768-d output truncated without re-normalization
output sentence, tokens sentence tokens: one 768-d vector per token
max_length, truncate 3 .. EMBGEMMA_MAX_SEQ_LEN; right, error max; right text-only inputs longer than max_length keep their first tokens (+ <eos>); media inputs are never cut (400)
image_tokens 70, 140, 280 (560, 1120 when enabled) 280 soft tokens per image (resolution)
video_fps, video_max_frames, video_tokens > 0; 1 .. 32; 70 .. 280 1, 32, 140 frame sampling and per-frame budget
encoding_format float, base64 float base64: little-endian float32
  • Errors: 400 with the reason, 413 too many inputs / body above EMBGEMMA_MAX_BODY_MB, 422 unknown fields, 429 when EMBGEMMA_QUEUE_DEPTH launches wait, 503 if start-up failed or while shutting down, 500 on a device failure. The port accepts connections once the server is ready (tt serve waits for that).
  • Images with transparency (RGBA, LA, palette) are composited onto white, like the official processor.
  • A Python API with the same options (tt_embgemma.api.EmbeddingGemma2.embed) is described in code/PYTHON.md; it needs a tt-metal build with the two patches in patches/.

Configuration

The server compiles and traces its device programs when it starts: the first start compiles about 2,200 device kernels (18 min measured on a busy 8-core host), which are cached, so later starts take about 1 minute. Change these with environment variables in the container's launch command. GET /info reports them. Batch size, sequence length, image size and audio length are not configuration: every request runs at its real size on the compiled buckets.

item environment variable values default
modalities loaded EMBGEMMA_MODALITIES subset of text,image,video,audio (text always) all
engine of every stage (text, vision, audio) EMBGEMMA_TEXT_ENGINE ttnn, cpu (float32 reference, no device) ttnn
vision attention of one-image launches EMBGEMMA_VISION_ATTN sdpa (tt-nn), mk (custom attention kernel) sdpa
sequences per text launch EMBGEMMA_MAX_BATCH 1 .. 32 32
inputs per request EMBGEMMA_MAX_INPUTS 1 .. 65536 2048
images + video frames per request EMBGEMMA_MAX_IMAGES 1 .. 4096 (~8 MB of host memory each) 64
tokens per input EMBGEMMA_MAX_SEQ_LEN 32 .. 8192 2048
largest image budget EMBGEMMA_IMAGE_TOKENS_MAX 70, 140, 280, 560, 1120 280
video frames EMBGEMMA_VIDEO_MAX_FRAMES 1 .. 64 32
audio length cap EMBGEMMA_AUDIO_MAX_SECONDS 0.5 .. 30 30
buckets EMBGEMMA_TEXT_BUCKETS, EMBGEMMA_LONG_BUCKETS, EMBGEMMA_AUDIO_BUCKETS multiples of 32 (128 for audio frames) 32,...,2048; 1024,2048; 512,1024,2048,3072
weights, matmul fidelity EMBGEMMA_WEIGHTS, EMBGEMMA_FIDELITY bf16; HiFi4, HiFi3, HiFi2 bf16, HiFi4
default text prompt of /v1/embeddings EMBGEMMA_DEFAULT_PROMPT a prompt name none
merging window, queue EMBGEMMA_BATCH_WINDOW_MS, EMBGEMMA_QUEUE_DEPTH, EMBGEMMA_QUEUE_TIMEOUT_S ms, launches, s 2, 256, 120

Example output

EmbeddingGemma 2 on a Tenstorrent p150: cosine similarities of 8 text queries against 8 images drawn for this demo

Cross-modal retrieval, served by this package's container on a p150. Eight images drawn by code for this demo (above the columns) and eight text queries are each embedded in one POST /embed request (the images at the default 280 soft tokens, the queries with "prompt_name": "SearchQuery"); the cells are cosine similarities of the 768-d vectors. Every query finds its own image (8 of 8): matched pairs score 0.760 on average, the other pairs 0.582.

EmbeddingGemma 2 on a Tenstorrent p150: cosine similarities of 8 text queries against 8 audio clips

The same with eight audio clips: four synthetic speech clips made with changh95/Qwen3-TTS, queried with their transcripts in their own language, and four synthetic sounds, queried with a description. Seven of eight queries find their clip; "a clock ticking" scores the white-noise clip above the clicks.

clip what it is query best match (cosine)
WAV synthetic speech, English Hello! I'm Ryan, one of the nine preset voices. Every word you hear was generated on a single accelerator card, faster than real time. this clip (0.908)
WAV synthetic speech, Chinese ไฝ ๅฅฝ๏ผŒๆˆ‘ๆ˜ฏ่–‡่–‡ๅฎ‰ใ€‚่ฟ™ๆฎต่ฏญ้Ÿณๆ˜ฏๅœจไธ€ๅผ ๅŠ ้€ŸๅกไธŠๅฎžๆ—ถ็”Ÿๆˆ็š„ใ€‚ this clip (0.773; next: the English speech clip, 0.751)
WAV synthetic speech, Korean ์•ˆ๋…•ํ•˜์„ธ์š”, ์ €๋Š” ์†Œํฌ์˜ˆ์š”. ์ด ๋ชฉ์†Œ๋ฆฌ๋Š” ํ…์Šคํ† ๋ ŒํŠธ ์นด๋“œ์—์„œ ์‹ค์‹œ๊ฐ„์œผ๋กœ ๋งŒ๋“ค์–ด์กŒ์–ด์š”. this clip (0.851)
WAV synthetic speech, English (a cloned voice) This voice was cloned from a seven second reference clip, and now it reads a sentence it has never heard before. this clip (0.898)
WAV 880 Hz sine, 2 s a steady high-pitched beep this clip (0.726)
WAV a harmonic tone sweeping 650-1450 Hz, 5 s a wailing siren this clip (0.725; next: the beep, 0.706)
WAV clicks, two per second, 5 s a clock ticking the white-noise clip (0.689; this clip 0.651)
WAV Gaussian white noise, 2 s white noise this clip (0.678)

With "dimensions" 512, 256 or 128 in the same requests (Matryoshka truncation), every image query keeps its best match at every size; the audio queries keep 7 of 8 at 512 and 6 of 8 at 256 and 128, where "a wailing siren" moves to the beep. The official sentence-transformers model in float32 on the CPU picks the same best match for every query, including the ticking clip's miss; no score differs from it by more than 0.002 for the images and 0.0035 for the audio clips, and the lowest embedding cosine to float32 is 0.99996 for the images and 0.9996 for the audio clips (the click track; 0.9998 or more for the others). One text query sent alone to /v1/embeddings took 16.8 ms on loopback (p50 of 20 requests; 10.2 ms in the server), one image 108 ms (102 ms in the server, including the image decoding and resizing on the host) and the 9.8 s English speech clip 92 ms (79 ms), on a shared 8-core host. The exact requests, scores and timings are in media/demos.json; media/make_demo.py draws the images, synthesises the sounds and repeats the requests against a running server.

Expected performance

Agreement with the official sentence-transformers float32 code on the CPU (same weights and inputs; embedding cosine to float32), next to the official model run in bfloat16:

eval this package official bfloat16
Text, 40 inputs of 2 to 2,047 tokens (task prompts, code, 6 languages, emoji): lowest / mean 1 - cosine 0.99992 / 4.1e-5 0.99991 / 3.8e-5
Retrieval, 8 queries x 24 documents: top-1 agreement, largest similarity change 8/8, 0.0025 8/8, 0.0020
Matryoshka 512 / 256 / 128 dimensions: retrieval top-1 agreement 8/8 at every size 8/8
Images, 8 at 70 / 140 / 280 tokens: lowest / mean 1 - cosine 0.99972 / 9.1e-5 0.99980 / 7.1e-5 (4 images)
Image vs caption similarity: top-1, largest change 6/6, 0.0010 3/3, 0.0011 (measured on 3 images)
Audio, 10 clips of 0.1 to 52.8 s: lowest / mean 1 - cosine 0.99991 / 3.7e-5 0.99981 / 5.5e-5 (5 clips)
Audio vs transcript similarity: top-1, largest change 9/9, 0.0018 5/5, 0.0015 (measured on 5 clips)
Video (2 clips) / interleaved text + images (2): lowest cosine 0.99991 / 0.99991 0.99997 / 0.99992
Same input alone vs packed with other inputs in one device launch, lowest cosine (300 random packings; every packed result stays within the float32 gate, lowest 0.99985) 0.99979 0.99988 (padded batch)
100 repeated runs per modality bitwise identical -
speed (warm, traced; engine call incl. host packing and readback) ms
text, 1 input of 16 / 32 / 128 / 512 tokens 5.6 / 5.5 / 8.0 / 12.9
text, 1 input of 1,024 / 2,048 tokens 28.7 / 68.1
text, 32 inputs x 16 tokens / 32 x 64 / 8 x 256 12.4 (2,570 inputs/s) / 41.2 (777/s) / 36.8 (218/s)
image encoder, 70 / 140 / 280 tokens 15.5 / 28.0 / 61.5
4 images x 70 tokens in one launch 41.1
audio encoder, 1 / 5 / 10 / 30 s 16.7 / 16.5 / 25.1 / 60.4
served /v1/embeddings, one query, client round trip on loopback (p50) 15.7

Measured with code/scripts/bench.py and code/tt_embgemma/server/smoke_test.py on one p150 with ETH dispatch (12 x 10 grid); an image or audio request adds the text pass over its soft tokens and host preprocessing (image resize ~30 ms for a 1600 x 900 photo, log-mel ~60 ms for 30 s).

Limitations

  • The official pipeline never truncates; this package caps an input at EMBGEMMA_MAX_SEQ_LEN tokens (2,048 by default, up to the model's 8,192 context). Audio is truncated at 30 s per clip like the official feature extractor; video keeps at most 32 frames (1 frame per second by default).
  • Video files need PyAV, which the container does not include: send decoded frames ({"frames": [...], "fps"}).
  • Image budgets 560 and 1120 tokens are opt-in (EMBGEMMA_IMAGE_TOKENS_MAX): they cost 2.6 and 7.4 TFLOP per image and large attention buffers.
  • Precision: bfloat16 weights and activations with float32 accumulation and float32 softmax; embeddings differ from the float32 model about as much as the official bfloat16 run does (table above). A result also depends slightly on what else shares its device launch (lowest cosine 0.99979 between an input alone and packed with others), like the official bfloat16 model's padding (0.99988).
  • Up to 32 sequences share one text launch; larger and concurrent requests are split / merged automatically. One p150 only (ETH dispatch).
  • The text path in this version is the tt-nn engine: the 24-layer text encoder runs as ~700 traced tt-nn operations, so a short query is bound by operation count, not by arithmetic. Measured (warm, traced): 5.6 ms for one input of 16 tokens, 5.5 ms at 32, 8.0 ms at 128, 12.9 ms at 512, 28.7 ms at 1,024 and 68.1 ms at 2,048 tokens; 12.4 ms for 32 inputs of 16 tokens. A single-program text encoder (megakernel) is planned for a later version; it is not part of this one.
  • Every other stage also runs in tt-nn operations under traces; a custom attention kernel for one-image vision launches is opt-in (EMBGEMMA_VISION_ATTN=mk, 7 % faster at 280 tokens).

Licensing

  • Weights (not redistributed here; tt serve downloads them at this commit), Apache-2.0 per the model card: google/embeddinggemma-2 f9972ac2. Use is subject to the Gemma Prohibited Use Policy referenced by the card. Notices: code/tt_embgemma/licenses/NOTICE.md.
  • This package is a derivative work: the inference code is written anew (tokenizer framing, image / audio / video front ends, the three encoders, pooling and normalization follow the official code's behaviour), and the weights are loaded unmodified.
  • Port, server and scripts (code/) and the tt-metal patches in patches/: Apache-2.0.
  • The demo in media/ (figures, audio clips, demos.json, make_demo.py): Apache-2.0. Its images and sounds were generated by code for this package, its speech clips are synthetic speech made with changh95/Qwen3-TTS (Qwen3-TTS weights, Apache-2.0; no recording of a person), and its queries were written for this package. Attributions: media/ATTRIBUTION.md.

Related packages

Feedback

Questions or problems with this package: open a discussion at https://huggingface.co/changh95/embeddinggemma-2/discussions โ€” that is what reaches its author. A problem with the tt tooling itself: tt report issue (collects your environment and opens a prefilled issue against tenstorrent/tt-cli). Product feedback: support@tenstorrent.com.

Provenance

The exact sources the image was built from โ€” code/ in this repo is byte-identical to the model code inside the image:

component built from
tt-metal 44d66500520fda9f2c7060c0f6b41ec48f7ab37e (dirty tree โ€” the image includes uncommitted changes)
code/ digest 6d7ca0f18a248ea5 (sha256, first 16 hex digits)
built 2026-12-01T02:46:55+00:00 by tt-model 0.1.0
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for changh95/embeddinggemma-2

Finetuned
(209)
this model

Collection including changh95/embeddinggemma-2