Skip to content

Default missing deepseek_yarn original_max_position_embeddings instead of raising - #4653

Open
JessicaJiang-123 wants to merge 1 commit into
ROCm:mainfrom
JessicaJiang-123:fix-deepseek-yarn-rope-scaling-default
Open

Default missing deepseek_yarn original_max_position_embeddings instead of raising#4653
JessicaJiang-123 wants to merge 1 commit into
ROCm:mainfrom
JessicaJiang-123:fix-deepseek-yarn-rope-scaling-default

Conversation

@JessicaJiang-123

Copy link
Copy Markdown
Contributor

Motivation

AITER's deepseek_yarn RoPE path requires rope_scaling["original_max_position_embeddings"] and raises KeyError when the key is missing.

This breaks GLM-4.7-Flash loading on ROCm with SGLANG_USE_AITER=1:

python3 -m sglang.launch_server --model-path zai-org/GLM-4.7-Flash --trust-remote-code --tp 1
  File "sglang/srt/models/glm4_moe_lite.py", line 544, in __init__
    self.self_attn = DeepseekV2AttentionMLA(
  File "sglang/srt/models/deepseek_v2.py", line 1717, in __init__
    self.rotary_emb = get_rope_wrapper(
  File "sglang/srt/layers/rotary_embedding/factory.py", line 437, in get_rope_wrapper
    return wrapper(
  File "aiter/rotary_embedding.py", line 1872, in get_rope
    original_max_position = rope_scaling["original_max_position_embeddings"]
KeyError: 'original_max_position_embeddings'

GLM-4.7-Flash does not define YaRN parameters in its config, but SGLang relabels the generated rope_scaling dict as deepseek_yarn. SGLang's own RoPE implementation already handles this case by defaulting original_max_position_embeddings to max_position; AITER does not.

Technical Details

This PR ports SGLang's _get_rope_param() fallback to AITER and uses it for original_max_position_embeddings in the deepseek_yarn branch. SGLang added the fallback in sgl-project/sglang#17784.

Related code:

  1. factory.py::_get_rope_param()
  2. factory.py::deepseek_yarn

Test Plan

MI355X / gfx950 / ROCm 7.2.

  1. Test deepseek_yarn with and without original_max_position_embeddings.
  2. Launch GLM-4.7-Flash with SGLang and AITER enabled.
  3. Run GLM-4.7-Flash RL training on 4x MI355X.

Test Result

case before after
missing original_max_position_embeddings KeyError fallback applied
DeepSeek-style config with the key present works unchanged
GLM-4.7-Flash serving fails during model loading server starts and serves
GLM-4.7-Flash RL training cannot start completes

RL validation completed with TP2 / PP2 / EP2, EAGLE speculative decoding, and MTP.

Submission Checklist

@JessicaJiang-123
JessicaJiang-123 requested review from a team and a lite review from Copilot August 10, 2026 04:47
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 4653 --add-label <label>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes AITER’s deepseek_yarn RoPE configuration handling more robust by defaulting a missing rope_scaling["original_max_position_embeddings"] to max_position (with a warning) instead of raising a KeyError, aligning behavior with SGLang and unblocking GLM-4.7-Flash loading when SGLang relabels RoPE scaling as deepseek_yarn.

Changes:

  • Add _get_rope_param() helper to fetch rope_scaling parameters with a warning-and-default fallback.
  • Use the helper in the deepseek_yarn branch to avoid KeyError when original_max_position_embeddings is absent.
  • Wire in aiter.logger for consistent logging.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@JessicaJiang-123

Copy link
Copy Markdown
Contributor Author

Hi @junhaha666, could you please help review this PR when you get a chance? This is currently blocking the Miles CI for GLM-4.7-Flash on ROCm. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants