Transformers adds Reflection AI’s Beam and loads models on PyTorch 2.7 again

1 hour ago

Transformers v5.20.1 and v5.20.2: Reflection AI's Beam model, from_pretrained working again on PyTorch 2.7, generate fixes for vision-language and encoder-decoder models, and real expert gradients in bfloat16 MoE training. https://github.com/huggingface/transformers/releases/tag/v5.20.1 https://github.com/huggingface/transformers/releases/tag/v5.20.2 https://huggingface.co/docs/transformers/main/en/model_doc/beam

Ask

Ask about this presentation

Answers are generated from this presentation.

Chapters

  1. 0:00Beam
  2. 0:16Beam hardware
  3. 0:33Reasoning effort
  4. 0:49PyTorch 2.7
  5. 1:06generate across devices
  6. 1:22Vision-language models
  7. 1:40Expert gradients
  8. 1:57Smaller fixes
  9. 2:15Release notes
Show transcript

Beam

Transformers
010203New model
huggingface/transformers · release v5.20.1 · PR #49664

Transformers now runs Beam, Reflection AI’s open-weight model

501B parameters23B active per tokenCoding and agents
Beam by Reflection AI, the image from the v5.20.1 release notes

Transformers now runs Beam, the first open-weight model from Reflection AI. It's a mixture of experts with 501 billion parameters, 23 billion of them active per token, built for coding, reasoning and agent work.

Beam hardware

Transformers
010203New model
Transformers docs · Beam model page · PR #49664

Beam needs eight GPUs and about a terabyte

torchrun --nproc-per-node 8 script.py
DistributedConfig(tp_size=8, ep_size=8)

The BF16 checkpoint is about a terabyte. The examples shard it across eight GPUs with expert parallelism, which puts whole experts on each device. That beats device_map auto, which can run out of memory while loading.

Reasoning effort

Transformers
010203New model
Transformers docs · Beam model page · PR #49664

You set how long Beam thinks

minimal8
low32
medium64
high128
xhigh256
max512 · default

Text only · a token limit hit mid-reasoning returns thinking and no answer

Beam reasons before every answer, and a reasoning effort setting in the chat template controls how much. It runs from minimal up to max, the default. If the token limit runs out mid-reasoning, you get thinking and no answer.

PyTorch 2.7

Transformers
010203Fixed
huggingface/transformers · release v5.20.1 · PRs #49652, #49657

from_pretrained works on PyTorch 2.7 again

ModuleNotFoundError: No module named
'torch.distributed.checkpoint.hf_storage'
Tensor-parallel loading fixed on 2.6 and 2.7Distributed checkpointing needs 2.8

On PyTorch 2.7, every from_pretrained call in 5.20.0 failed with this missing module error. Loading works again, and so does tensor-parallel loading on 2.6 and 2.7. Distributed checkpointing now needs PyTorch 2.8.

generate across devices

Transformers
010203Fixed
huggingface/transformers · release v5.20.2 · PR #49731 · issue #49699

generate stops crashing when inputs sit on another device

Encoder-decoder modelsencoder outputs lost their type
Vision-language modelspassing multimodal encoder outputs

Since 5.20.0, generate crashed for encoder-decoder models and some vision-language models whenever the input IDs sat on a different device from the model. It was rebuilding their encoder outputs as plain dictionaries. It keeps their type now.

Vision-language models

Transformers
010203Fixed
huggingface/transformers · release v5.20.2 · PR #49677

Eight vision-language models now take generate’s image path

Exaone 4.5GLM-5 NextMuse GlimmerMuse SparkQwen3.5Qwen3.5-MoEQwen4-ExpStep3p7

Still waiting: Aria, Inkling and PaddleOCR-VL need their own fix

Eight vision-language models, including Qwen3.5 and Muse Spark, declared text as their only input, so generate treated them as text-only. They take the multimodal path now. Aria, Inkling and PaddleOCR-VL have the same bug and still need their own fix.

Expert gradients

Transformers
010203Fixed
huggingface/transformers · release v5.20.2 · PR #49688

Mixture-of-experts layers train again in bfloat16

Who it hitexpert parallelism under FSDP2, expert group smaller than the FSDP group
What happenedevery expert gradient came back as zero

With expert parallelism under FSDP2, and an expert group smaller than the FSDP group, bfloat16 expert gradients came back as zero, so the experts never learned. They get real gradients now.

Smaller fixes

Transformers
010203Fixed
huggingface/transformers · release v5.20.1, v5.20.2 · PRs #49557, #49428, #49684

Fixes for HunYuan-VL, DeepSeek-V4 and Gemma 4 audio

HunYuan-VLeach beam gets its own image in batched generation
DeepSeek-V4 on Mega MoEruns under expert parallelism instead of failing on the first forward pass
Gemma 4 audiomasks stop forcing a GPU sync, which broke vLLM’s tests

HunYuan-VL gives each beam its own image in batched generation. DeepSeek V4 with the DeepGEMM Mega MoE kernel runs under expert parallelism instead of failing on its first forward pass. And Gemma 4 audio stops forcing a GPU sync on every mask.

Release notes

Transformers
010203Release notes
huggingface/transformers · release v5.20.1 · release v5.20.2

Which PyTorch version is your training setup pinned to?

Full list: the Transformers v5.20.1 and v5.20.2 release notes on GitHub

The full list of fixes is in the release notes for 5.20.1 and 5.20.2 on GitHub. Which PyTorch version is your training setup pinned to?