Skip to content

fix(export): preserve both RoPE scaling schemas - #742

Open
Boreas618 wants to merge 2 commits into
sgl-project:mainfrom
Boreas618:agent/dual-rope-export
Open

fix(export): preserve both RoPE scaling schemas#742
Boreas618 wants to merge 2 commits into
sgl-project:mainfrom
Boreas618:agent/dual-rope-export

Conversation

@Boreas618

Copy link
Copy Markdown
Contributor

What changed

  • Mirrors non-default rope_parameters and legacy rope_scaling schemas after HF or SGLang export when serialization keeps only one form.
  • Preserves top-level rope_theta when constructing the modern representation.
  • Leaves default RoPE and already-compatible configs untouched.
  • Adds CPU tests for modern-to-legacy, legacy-to-modern, and no-op behavior.

Why

Transformers 5 serializes the modern schema, while older Transformers and serving stacks may read only rope_scaling. Losing YaRN metadata makes a long-context draft silently fall back to unscaled RoPE and can collapse acceptance beyond the original context.

The original fix lived in the removed legacy DSpark trainer. This PR moves the safeguard to the current export boundary, where runtime checkpoints become loadable model directories.

Impact

Exported long-context drafts remain readable across current and legacy consumers without changing default-RoPE checkpoints.

Validation

  • python -m unittest tests.test_runtime.test_export.TestRoPEConfigCompatibility
  • pre-commit run --files specforge/export/checkpoint_io.py specforge/export/to_hf.py specforge/export/to_sglang.py tests/test_runtime/test_export.py
  • git diff --check upstream/main...HEAD

The existing GPU exporter round-trip suite was also launched in this CUDA-enabled checkout; the focused compatibility tests above are the deterministic coverage added by this PR.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@Boreas618
Boreas618 force-pushed the agent/dual-rope-export branch from 4f275cd to 0412328 Compare August 1, 2026 17:32
transformers 5.x save_pretrained keeps only the new rope_parameters schema and drops legacy rope_scaling. Serving stacks and older transformers that read only the legacy key then silently lose YaRN on long-context checkpoints (the draft falls back to unscaled RoPE at serve time — accept length collapses beyond the original context). Mirror whichever schema survives into the other at save time; default (non-scaled) RoPE configs are left untouched.
@Boreas618
Boreas618 force-pushed the agent/dual-rope-export branch from 0412328 to 108eda3 Compare August 1, 2026 18:52
@Boreas618
Boreas618 marked this pull request as ready for review August 1, 2026 18:52
@Boreas618
Boreas618 requested a review from FrankLeeeee as a code owner August 1, 2026 18:52
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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