Transformers v5.19.0: EmbeddingGemma 2 and token-dispatch expert parallelism

5 days ago

Transformers v5.19.0 release notes: EmbeddingGemma 2, token-dispatch expert parallelism, continuous batching in SDPA and flash attention, per-layer cache config, and changed MoE and OWLv2 outputs. https://github.com/huggingface/transformers/releases/tag/v5.19.0 https://huggingface.co/docs/transformers/main/en/model_doc/embedding_gemma2

Ask

Ask about this presentation

Answers are generated from this presentation.

Chapters

  1. 0:00EmbeddingGemma 2 arrives
  2. 0:10One vector space for every input
  3. 0:21Shorter embeddings
  4. 0:37Load only the towers you need
  5. 0:48Expert parallelism
  6. 0:50Token dispatch
  7. 1:03Default for Qwen3 MoE
  8. 1:14Trainer and PEFT
  9. 1:27Continuous batching
  10. 1:28Regular attention runs continuous batching
  11. 1:41Fused cache update
  12. 1:53Cache
  13. 1:54Per-layer cache config
  14. 2:07Quantized cache fixes
  15. 2:17Changed outputs
  16. 2:19Router logits from every MoE model
  17. 2:31OWLv2 query by objectness
  18. 2:46Fixes you may have hit
  19. 3:00Release notes
Show transcript

EmbeddingGemma 2 arrives

010203040506EmbeddingGemma 2
huggingface/transformers · GitHub release v5.19.0 · Transformers docs · EmbeddingGemma 2
Hugging Face

Transformers v5.19.0 adds EmbeddingGemma 2

Multimodal embeddingsFrom GoogleGemma 4 architecture

Transformers v5.19.0 adds EmbeddingGemma 2. It's a multimodal embedding model from Google, built on the Gemma 4 architecture.

One vector space for every input

Transformers v5.19.0
010203040506EmbeddingGemma 2
huggingface/transformers · GitHub release v5.19.0

Text, images, audio and video land in one vector space

768 dimensions, for retrieval, similarity, clustering and classification across media

EmbeddingGemma 2 diagram: text, code, images, video and audio encoded into one embedding space

It encodes text, images, audio and video, one at a time or mixed in a single input, into one shared space. So a text query and a photo can be compared directly.

Shorter embeddings

Transformers v5.19.0
010203040506EmbeddingGemma 2
Transformers docs · EmbeddingGemma 2

Cut each embedding from 768 to 512, 256 or 128 dimensions

Matryoshka Representation Learning: truncate, re-normalize, minimal quality loss

Embeddings come out at 768 dimensions. Because it's trained with Matryoshka Representation Learning, you can keep just the first 512, 256 or 128, and the docs report minimal quality loss.

Load only the towers you need

Transformers v5.19.0
010203040506EmbeddingGemma 2
Transformers docs · EmbeddingGemma 2

Text-only? Leave the vision and audio towers unloaded

Less memory for single-modality deployments. Image and video token budgets are tunable too.

Embedding only text? You can disable the vision or audio tower at load time to save memory. The token budget per image or video frame is configurable as well.

Expert parallelism

Transformers v5.19.0
010203040506Expert parallelism
huggingface/transformers · GitHub release v5.19.0
02
Expert parallelism

Expert parallelism.

Token dispatch

Transformers v5.19.0
010203040506Expert parallelism
huggingface/transformers · pull request #48865

Expert-parallel size no longer has to equal tensor-parallel size

Token dispatch: each GPU keeps its own tokens and sends only the routed ones to the experts that own them.

Expert parallelism gets a second mode, token dispatch. Each rank keeps its own tokens and sends only routed tokens to the experts' owners, so expert and tensor parallel sizes become independent.

Default for Qwen3 MoE

Transformers v5.19.0
010203040506Expert parallelism
huggingface/transformers · GitHub release v5.19.0 · huggingface/transformers · pull request #48865

Token dispatch is now the default for Qwen3 MoE and Mellum

The older masked expert parallelism stays available through the expert-parallel plan.

Token dispatch is now the default for Qwen3 MoE and Mellum. The older masked mode, where every rank sees every token, is still there if your plan selects it.

Trainer and PEFT

Transformers v5.19.0
010203040506Expert parallelism
huggingface/transformers · GitHub release v5.19.0

More of the stack works with model parallelism

Trainerworks with expert parallelism
Separate planstensor-parallel and expert-parallel plans decoupled, with dense and expert device meshes
PEFT adaptersthe docs now cover tensor parallelism for adapters

The Trainer now works with expert parallelism. Tensor and expert parallel plans are decoupled, each with its own device mesh. And the docs now cover tensor parallelism for PEFT adapters.

Continuous batching

Transformers v5.19.0
010203040506Continuous batching
huggingface/transformers · GitHub release v5.19.0
03
Continuous batching

Continuous batching.

Regular attention runs continuous batching

Transformers v5.19.0
010203040506Continuous batching
huggingface/transformers · pull request #49101 · huggingface/transformers · pull request #49112

SDPA and flash attention handle continuous batching directly

paged|sdpa paged|flashthe paged prefix is deprecated for these two
Eager attentionstill requires the paged|eager prefix

The standard SDPA and flash attention functions now support continuous batching themselves. So the paged prefix on those two is deprecated. Eager attention still needs its paged prefix.

Fused cache update

Transformers v5.19.0
010203040506Continuous batching
huggingface/transformers · pull request #49088

One cache update call for both continuous-batching paths

The index path and the block-table path now share a single update. Custom code that called them separately is affected.

Inside continuous batching, the index path and block table path now update the cache in one fused call. Custom code that called those update paths separately will need changes.

Cache

Transformers v5.19.0
010203040506Cache
huggingface/transformers · GitHub release v5.19.0
04
Cache

The cache.

Per-layer cache config

Transformers v5.19.0
010203040506Cache
huggingface/transformers · pull request #48178

Each cache layer is built from its own layer config

Sliding windowAttention chunk sizeConv statesAttention heads

DynamicCache and StaticCache used to reuse one set of settings for every layer. Now each layer reads its own sliding window, chunk size, conv states and head counts, which suits models with mixed layers.

Quantized cache fixes

Transformers v5.19.0
010203040506Cache
huggingface/transformers · pull request #48700

Two quantized cache bugs fixed

generateno longer edits the cache_config you pass in
Beam searchreordering a quantized cache works again

Generate used to edit the cache config you passed, so a second model could inherit the first one's settings. And beam search now reorders quantized cache states correctly.

Changed outputs

Transformers v5.19.0
010203040506Changed outputs
huggingface/transformers · GitHub release v5.19.0
05
Changed outputs

Outputs that change.

Router logits from every MoE model

Transformers v5.19.0
010203040506Changed outputs
huggingface/transformers · pull request #48920

Every MoE model that computes router logits now returns them

Llama 4DeepSeek-V3Gemma 4GLM-4-MoE+21 more

Ask for router logits, and every mixture of experts model whose router computes them now returns them, the way Qwen3 MoE already did. With the flag off, the defaults are unchanged.

OWLv2 query by objectness

Transformers v5.19.0
010203040506Changed outputs
huggingface/transformers · pull request #49200

OWLv2 picks its image query by objectness

Top: the old pick boxes the whole image. Bottom: the new pick boxes the lemon.

OWLv2 image-guided detection with a lemon query, before and after

OWLv2 image-guided detection now picks the query box with the highest objectness, as the original OWLv2 notebook does. Here, the old pick boxed the whole lemon photo. Expect detections to differ from earlier releases.

Fixes you may have hit

Transformers v5.19.0
010203040506Changed outputs
huggingface/transformers · GitHub release v5.19.0

Three fixes you may have hit

Data collatorDataCollatorForLanguageModeling honors seed=0
Pipelinesdeprecated tasks redirect; removed tasks raise
Trainersubclasses declare whether their loss is already scaled for gradient accumulation

The language modeling data collator no longer ignores a seed of zero. Deprecated pipeline tasks now redirect. And Trainer subclasses can declare whether their loss is already scaled for gradient accumulation.

Release notes

Transformers v5.19.0
010203040506Release notes
huggingface/transformers · GitHub release v5.19.0

The full list is in the v5.19.0 release notes

github.com/huggingface/transformers › Releases › v5.19.0

The full list of changes is in the Transformers v5.19.0 release notes on GitHub. That's Transformers 5.19: EmbeddingGemma 2, and token dispatch for expert parallelism.