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

1 month 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 about 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
  1. Transformers v5.19.0 adds EmbeddingGemma 2. It's a multimodal embedding model from Google, built on the Gemma 4 architecture.

    Slide text
    01 02 03 04 05 06 EmbeddingGemma 2
    huggingface/transformers · GitHub release v5.19.0 · Transformers docs · EmbeddingGemma 2
    Hugging Face

    Transformers v5.19.0 adds EmbeddingGemma 2

    Multimodal embeddings From Google Gemma 4 architecture
  2. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 EmbeddingGemma 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
  3. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 EmbeddingGemma 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

  4. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 EmbeddingGemma 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.

  5. Expert parallelism.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Expert parallelism
    huggingface/transformers · GitHub release v5.19.0
    02
    Expert parallelism
  6. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Expert 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.

  7. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Expert 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.

  8. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Expert parallelism
    huggingface/transformers · GitHub release v5.19.0

    More of the stack works with model parallelism

    Trainer works with expert parallelism
    Separate plans tensor-parallel and expert-parallel plans decoupled, with dense and expert device meshes
    PEFT adapters the docs now cover tensor parallelism for adapters
  9. Continuous batching.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Continuous batching
    huggingface/transformers · GitHub release v5.19.0
    03
    Continuous batching
  10. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Continuous batching
    huggingface/transformers · pull request #49101 · huggingface/transformers · pull request #49112

    SDPA and flash attention handle continuous batching directly

    paged|sdpa paged|flash the paged prefix is deprecated for these two
    Eager attention still requires the paged|eager prefix
  11. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Continuous 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.

  12. The cache.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Cache
    huggingface/transformers · GitHub release v5.19.0
    04
    Cache
  13. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Cache
    huggingface/transformers · pull request #48178

    Each cache layer is built from its own layer config

    Sliding window Attention chunk size Conv states Attention heads
  14. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Cache
    huggingface/transformers · pull request #48700

    Two quantized cache bugs fixed

    generate no longer edits the cache_config you pass in
    Beam search reordering a quantized cache works again
  15. Outputs that change.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Changed outputs
    huggingface/transformers · GitHub release v5.19.0
    05
    Changed outputs
  16. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Changed outputs
    huggingface/transformers · pull request #48920

    Every MoE model that computes router logits now returns them

    Llama 4 DeepSeek-V3 Gemma 4 GLM-4-MoE +21 more
  17. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Changed 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
  18. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Changed outputs
    huggingface/transformers · GitHub release v5.19.0

    Three fixes you may have hit

    Data collator DataCollatorForLanguageModeling honors seed=0
    Pipelines deprecated tasks redirect; removed tasks raise
    Trainer subclasses declare whether their loss is already scaled for gradient accumulation
  19. 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.

    Slide text
    Transformers v5.19.0
    01 02 03 04 05 06 Release 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

What happened in AI today, in your inbox

One short email each evening. Read it and you’re caught up.

Built with ❤️ in New York