Skip to content

feat(rope): expose active YaRN rope/effective_context on /v1/models*, hot-swap warnings on /v1/models/load, and context-overflow warning (#729 P1) - #784

Merged
goodmai merged 1 commit into
mainfrom
feat/729-p1-rope-rest-and-overflow
Nov 25, 2026

Conversation

@goodmai

@goodmai goodmai commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Part of #729 (completes remaining P1 items after #736).

Summary

  • Sources/BasaltCore/ModelRoPEStatus.swift: pure value core holding active YaRN factor, native/effective context, and load warnings; formats ropeLabel (yarn ×2, yarn ×2.5, or nil for stock RoPE) and computes one-shot contextOverflowWarning(promptTokens:maxTokens:).
  • Sources/BasaltCore/InferenceEngine.swift & ModelOrchestrating.swift: added var ropeStatus: ModelRoPEStatus { get async } (default .empty) forwarded by ModelOrchestratorActor.
  • Sources/BasaltInference/EngineState.swift, RopeYarnStage.swift, MLXInferenceEngine+Loading.swift, MLXInferenceEngine+Request.swift:
    • Records ModelRoPEStatus inside epoch-scoped ModelFacts (automatically cleared on unload, #300 race-free).
    • When --rope-yarn does not apply (e.g. Gemma 4 p-RoPE or non-qwen3_5), loads stock RoPE, logs once, and retains the warning in ropeStatus.loadWarnings.
    • Emits one logger.warn(...) in launching(...) when prompt + max_tokens exceeds effective native context (max_position_embeddings for stock, factor × original for YaRN).
    • Verified open question ci: bump actions/upload-artifact from 4 to 7 #2: both ~/.basalt/model-probes/<fingerprint>.json and ~/.basalt/head-scores/<name>-<fingerprint>-...json already key by fingerprint from the staged directory.
  • Sources/BasaltServer/REST/ModelsController.swift:
    • Reports "rope": "yarn ×F" and "effective_context" on the loaded entry in GET /v1/models, GET /v1/models/current, and POST /v1/models/load when YaRN is active, omitting "rope" on stock RoPE / Gemma 4 fallback.
    • Returns "warnings": [...] in POST /v1/models/load when a hot swap falls back to stock RoPE.
  • Tests/BasaltTests/RopeYarnRESTAndOverflowTests.swift: value-core formatting & overflow tests, MLXInferenceEngine.ropeSourceWithStatus (stock, YaRN ×2, Gemma 4 p-RoPE fallback), and full REST router tests across /v1/models, /v1/models/current, and /v1/models/load.

Local Verification

Gate Result
swift build -Xswiftc -warnings-as-errors PASS (154s, 0 warnings)
swift build -c release -Xswiftc -warnings-as-errors PASS (214.20s, 0 warnings)
Targeted tests (RopeYarnFlagTests|RopeYarnRESTAndOverflowTests|RESTServerTests) PASS (38/38, 0.231s)
5× repetition (RopeYarnRESTAndOverflowTests) PASS (15/15, 0.081–0.084s)
check_changed_coverage.swift origin/main PASS (85.2%, 104/122, min 60%)
check_no_new_comments.swift origin/main PASS (0 comments added)
check_concurrency_hatches.swift PASS (0 hatches outside allowlist)
check_size_limits.swift origin/main --impact PASS (max CCN 15, 0 limits exceeded)

… hot-swap warnings on /v1/models/load, and context-overflow warning (#729 P1)
@goodmai
goodmai merged commit 927f1f3 into main Nov 25, 2026
8 checks passed
@goodmai
goodmai deleted the feat/729-p1-rope-rest-and-overflow branch November 25, 2026 01:44
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