Skip to content

feat(rope): --rope-yarn stages a YaRN config for Qwen 3.5/3.6/3.8, warns elsewhere (#729 P1) - #736

Merged
goodmai merged 4 commits into
mainfrom
feat/729-rope-yarn-flag
Nov 23, 2026
Merged

goodmai merged 4 commits into
mainfrom
feat/729-rope-yarn-flag

Conversation

@goodmai

@goodmai goodmai commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

#729 P1. The owner chose a plain flag, not an experimental one.

  • Options: --rope-yarn FACTOR in serve and bench, serve.rope_yarn in the serve config, and rope_yarn in Compose. Compose keeps every engine option in its experimental section, plain flags like kv_head_split included, so rope_yarn goes there too. A Compose reload that changes it needs a restart.

  • For qwen3_5*: the engine stages ~/.basalt/rope-yarn/<hash>-yarn-xF with a rewritten config.json:

    • rope_parameters gets rope_type: yarn, the factor and original_max_position_embeddings = the native context;
    • rope_theta and partial_rotary_factor are copied into rope_parameters;
    • max_position_embeddings is multiplied by the factor;
    • every other file is a symlink.

    The model and the prompt-cache fingerprint come from that staged directory, so caches split by RoPE config.

  • Everything else, Gemma 4 and REST hot swaps included: loads with stock RoPE and logs one warning that names the reason (owner's decision).

  • Not done yet: a rope field in GET /v1/models, and a warning when a prompt exceeds the effective context.

Review fixes:

  • Staging no longer deletes a directory another process may be reading:
    • an identical staging (same config.json bytes, same symlink targets) is reused in place;
    • otherwise the staging is built in a sibling temporary directory and published with rename;
    • if the rename meets a staging someone else just wrote with the same contents, the temporary directory is dropped; a stale staging is replaced with replaceItemAt.
  • The test uses #require instead of as!, and its fixture is a computed property under strict concurrency.
  • New checks: an identical staging keeps its inode, a stale one is replaced, and no temporary directory is left behind.

Verified locally: strict build; RopeYarnFlagTests|ServeConfigFile|ComposeSchema|ComposeSpec|YarnRoPETests|ComposeProfilesMatrix (18 tests) pass; comment and size gates clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh

@goodmai

goodmai commented Nov 23, 2026

Copy link
Copy Markdown
Owner Author

Review (#729 P1)

Very clean end-to-end wiring (CLI, Compose, ServeConfigFile, PerformanceBenchmark, fingerprint split, Gemma 4 p-RoPE refusal). One Must fix and one Nice to have:

  1. [Must fix] Concurrent processes racing on the shared staging directory (Sources/BasaltInference/RopeYarnStage.swift:233-238).
    • Case: Two concurrent basalt serve (or basalt bench + basalt serve) runs with the same model and --rope-yarn factor target the same deterministic path ~/.basalt/rope-yarn/<sha16>-yarn-x<factor>. The second process runs try? fm.removeItem(at: staging) while the first is still reading config.json / symlinks → ENOENT at load.
    • Fix: Stage into a sibling temp dir (staging.path + ".\(UUID().uuidString)") and atomically swap, or reuse staging in-place without deleting when config.json already matches byte-for-byte and all symlinks resolve.
  2. [Nice to have] Tests/BasaltTests/RopeYarnFlagTests.swift:315 uses force-unwrap yarn["text_config"] as! [String: Any] — prefer try #require(...).

@goodmai
goodmai marked this pull request as ready for review November 23, 2026 12:51
@goodmai
goodmai merged commit 97d2ed7 into main Nov 23, 2026
8 checks passed
@goodmai
goodmai deleted the feat/729-rope-yarn-flag branch November 23, 2026 14:32
goodmai added a commit that referenced this pull request Nov 23, 2026
…g safety, DSpark config guards, compiled 1-row rewind, HF-aligned YaRN factor (#750)

* fix(rope,inkling): staging follows its source's file set and sweeps abandoned temporaries; MTP drafter from the staged config; DSpark block_size within the conv rewind, strictly increasing taps, null mtp_config; compiled 1-row steps keep conv windows; chunked drafter prefill (review)

* chore(fork): pin e9feb1e — HF-aligned YaRN attention factor, exact-trim precondition; test the attention-factor rules (review)
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.

1 participant