Skip to content

DBRX: rope_theta from attn_config is ignored in v5 (RoPE uses 10000 instead of 500000) #51709

Backlog

Description

@Sylvan-Luo

System Info

  • transformers version: 5.26.0
  • Platform: macOS-27.2.1-arm64-arm-64bit
  • Python version: 3.11.18
  • Huggingface_hub version: 2.5.0
  • Safetensors version: 0.8.0
  • Accelerate version: 1.16.0
  • Accelerate config: not found
  • DeepSpeed version: not installed
  • PyTorch version (accelerator?): 2.15.0 (MPS)
  • Using distributed or parallel set-up in script?: No

Who can help?

@ArthurZucker @Cyrilvallez @vasqu

Reproduction

DBRX stores rope_theta inside attn_config (500000 for databricks/dbrx-instruct and dbrx-base). In v5 the model builds its rotary embedding from config.rope_parameters["rope_theta"], which falls back to the default 10000, so the published checkpoints run with the wrong RoPE base.

import torch, transformers
from transformers import AutoConfig
from transformers.models.dbrx.modeling_dbrx import DbrxRotaryEmbedding

cfg = AutoConfig.from_pretrained("alpindale/dbrx-instruct")  # public copy of databricks/dbrx-instruct's config (gated)
print("transformers", transformers.__version__)
print("attn_config.rope_theta =", cfg.attn_config.rope_theta)
print("rope_parameters =", cfg.rope_parameters)
rot = DbrxRotaryEmbedding(cfg)
dim = cfg.d_model // cfg.n_heads
for theta in (cfg.attn_config.rope_theta, 10000.0):
    ref = 1.0 / (theta ** (torch.arange(0, dim, 2, dtype=torch.int64).float() / dim))
    print(f"inv_freq matches theta={theta:g}:", torch.allclose(rot.inv_freq.float(), ref))

Output on 5.26.0:

transformers 5.26.0
attn_config.rope_theta = 500000
rope_parameters = {'rope_theta': 10000.0, 'rope_type': 'default'}
inv_freq matches theta=500000: False
inv_freq matches theta=10000: True

In v4.57.6 the attention layer passed attn_config.rope_theta to the rotary embedding (self.rope_theta = attn_config.rope_theta, then base=self.rope_theta). In v5, modeling_dbrx.py still reads attn_config.rope_theta into self.rope_theta in the attention layer, but DbrxRotaryEmbedding.compute_default_rope_parameters uses config.rope_parameters["rope_theta"].

On a reduced random-weight model built from the official config (2 layers, 64 tokens), the current behaviour (base 10000) and the intended one (base 500000) give logits that differ by 8.4e-2 relative, with top-1 agreement on 82.8% of positions. mlx-lm and llama.cpp both use 500000 for this config.

Written with Claude

Expected behavior

For DBRX configs, rope_parameters["rope_theta"] should come from attn_config.rope_theta (as in v4), so the rotary embedding uses 500000 for the published checkpoints.

Activity

  1. akhil9tiet commented on Dec 4, 2026

    @akhil9tiet

    I'd like to work on this — please assign it to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions