[PR #2950] [CLOSED] fix(setup): reject invalid RoPE scaling factors #4354

Closed
opened 2026-11-07 15:35:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2950
Author: @j-luwierski
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: codex/validate-rope-scale


📝 Commits (1)

  • ca288c8 fix(setup): reject invalid RoPE scaling factors

📊 Changes

2 files changed (+20 additions, -3 deletions)

View changed files

📝 setup.py (+5 -3)
📝 tools/test_setup_rope.py (+15 -0)

📄 Description

Summary

Setup's resolve_rope() accepts an explicit --rope-scale nan, inf, or a value below 1 and forwards it into the saved engine arguments. The engine rejects these values: rope_scaling_invalid() requires a finite factor >= 1.

Reject invalid explicit factors during setup's RoPE resolution, before configuration is saved, with a message naming the flag and its valid range.

What changed

  • setup.py: validate explicit factors using math.isfinite() and the engine's >= 1 lower bound; document the range in --help.
  • tools/test_setup_rope.py: cover NaN, both infinities, negative, zero and fractional factors below 1 across contexts below, at and above 262144, with omitted/none/linear/yarn methods. Confirm valid explicit factors remain unchanged, including factors smaller than the context-derived ratio.

Automatic scaling, valid explicit overrides, model inference and backend code are unchanged. This does not change YaRN quality or enforce a context-covering factor.

Validation

Based on upstream 477ac13cbe8e582c20484871ce459d20d82df09d, Linux, Python 3; no GPU or model downloads.

  • The new invalid-factor regression fails against the original resolver (72 failing subcases) and passes with this change.
  • python3 -m unittest tools.test_setup_rope tools.test_setup_choices tools.test_setup_configs tools.test_setup_config -q: 89 tests pass.
  • Compared original and changed setup over all 5 golden hardware profiles x 5 model selections x 2 answer modes (--yes and Enter): 50/50 comparisons match for exit code, normalized serialized configuration and questions.
  • Adding tools.test_setup_golden runs 93 tests with 8 Unsloth golden subcase failures. The same 8 subcases fail with the original upstream setup; golden files were not regenerated.
  • git diff --check passes.

No CUDA/HIP/SYCL source or build file changes; backend builds and on-model inference were not run.

Searched open issues/PRs for rope-scale, resolve_rope, RoPE validation and non-finite factors; no matching setup-validation fix found. Existing cache migration (#1698) and Metal RoPE support (#2819) address separate behavior.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2950 **Author:** [@j-luwierski](https://github.com/j-luwierski) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex/validate-rope-scale` --- ### 📝 Commits (1) - [`ca288c8`](https://github.com/Niko1221/Strata/commit/ca288c8998b345e9c9a152a73f873987c0315020) fix(setup): reject invalid RoPE scaling factors ### 📊 Changes **2 files changed** (+20 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `setup.py` (+5 -3) 📝 `tools/test_setup_rope.py` (+15 -0) </details> ### 📄 Description ## Summary Setup's `resolve_rope()` accepts an explicit `--rope-scale nan`, `inf`, or a value below 1 and forwards it into the saved engine arguments. The engine rejects these values: `rope_scaling_invalid()` requires a finite factor >= 1. Reject invalid explicit factors during setup's RoPE resolution, before configuration is saved, with a message naming the flag and its valid range. ## What changed - `setup.py`: validate explicit factors using `math.isfinite()` and the engine's >= 1 lower bound; document the range in `--help`. - `tools/test_setup_rope.py`: cover NaN, both infinities, negative, zero and fractional factors below 1 across contexts below, at and above 262144, with omitted/none/linear/yarn methods. Confirm valid explicit factors remain unchanged, including factors smaller than the context-derived ratio. Automatic scaling, valid explicit overrides, model inference and backend code are unchanged. This does not change YaRN quality or enforce a context-covering factor. ## Validation Based on upstream `477ac13cbe8e582c20484871ce459d20d82df09d`, Linux, Python 3; no GPU or model downloads. - The new invalid-factor regression fails against the original resolver (72 failing subcases) and passes with this change. - `python3 -m unittest tools.test_setup_rope tools.test_setup_choices tools.test_setup_configs tools.test_setup_config -q`: **89 tests pass**. - Compared original and changed setup over all 5 golden hardware profiles x 5 model selections x 2 answer modes (`--yes` and Enter): **50/50 comparisons match** for exit code, normalized serialized configuration and questions. - Adding `tools.test_setup_golden` runs 93 tests with 8 Unsloth golden subcase failures. The same 8 subcases fail with the original upstream setup; golden files were not regenerated. - `git diff --check` passes. No CUDA/HIP/SYCL source or build file changes; backend builds and on-model inference were not run. ## Related work Searched open issues/PRs for `rope-scale`, `resolve_rope`, RoPE validation and non-finite factors; no matching setup-validation fix found. Existing cache migration (#1698) and Metal RoPE support (#2819) address separate behavior. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:35:06 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4354
No description provided.