diff --git a/Sources/BasaltCLI/ComposeFile+Options.swift b/Sources/BasaltCLI/ComposeFile+Options.swift index 87efb2412..f76e04235 100644 --- a/Sources/BasaltCLI/ComposeFile+Options.swift +++ b/Sources/BasaltCLI/ComposeFile+Options.swift @@ -22,6 +22,7 @@ extension ComposeFile.Walk { out.expertCacheGB = number(field["expert_cache_gb"], "\(path).expert_cache_gb") out.kvHeadSplit = number(field["kv_head_split"], "\(path).kv_head_split") out.questTopK = integer(field["quest_top_k"], "\(path).quest_top_k") + out.ropeYarn = number(field["rope_yarn"], "\(path).rope_yarn") spec.experimental = out } diff --git a/Sources/BasaltCLI/KVCacheOptions.swift b/Sources/BasaltCLI/KVCacheOptions.swift index 255c5e16e..6f599eb76 100644 --- a/Sources/BasaltCLI/KVCacheOptions.swift +++ b/Sources/BasaltCLI/KVCacheOptions.swift @@ -28,9 +28,13 @@ struct KVCacheOptions: ParsableArguments { @Option(name: .customLong("moba-top-k"), help: ArgumentHelp("With --attention-backend moba, number of 64-token middle blocks selected per query head alongside sink and recent blocks (1...4096, default 8)")) var mobaTopK: Int = 8 + @Option(name: .customLong("rope-yarn"), help: ArgumentHelp("Extend the context of Qwen 3.5, 3.6 and 3.8 (qwen3_5) with YaRN by this factor (e.g. 2 for about 512K tokens, 4 for about 1M); the model's config is staged with rope_type yarn and original_max_position_embeddings set to its native context. YaRN is static: short prompts pay its small cost too, so use it only for contexts past the native one. Other models, Gemma 4 included, load with their stock RoPE and a warning")) + var ropeYarn: Double? + var zones: KVZones? { KVBitsSetting.zones(zoned, evicting: evict) } func validateCombination() throws { + if let ropeYarn, !(ropeYarn > 1 && ropeYarn <= 64) { throw ValidationError("--rope-yarn takes a factor in (1, 64]") } try KVBitsSetting.validate(zones: zoned, bits: bits, evict: evict) if let headSplit { guard (0.05 ... 1).contains(headSplit) else { throw ValidationError("--kv-head-split takes a share of heads in 0.05...1") } diff --git a/Sources/BasaltCLI/ServeCommand+Compose.swift b/Sources/BasaltCLI/ServeCommand+Compose.swift index 4406f84a8..f72d3d058 100644 --- a/Sources/BasaltCLI/ServeCommand+Compose.swift +++ b/Sources/BasaltCLI/ServeCommand+Compose.swift @@ -59,6 +59,7 @@ extension ServeCommand { if expertStreaming.cacheGB == nil, let cacheGB = exp.expertCacheGB { expertStreaming.cacheGB = cacheGB } if kvCache.headSplit == nil, let split = exp.kvHeadSplit { kvCache.headSplit = split } if kvCache.questTopK == nil, let topK = exp.questTopK { kvCache.questTopK = topK } + if kvCache.ropeYarn == nil, let factor = exp.ropeYarn { kvCache.ropeYarn = factor } } private mutating func applyComposeMCP(_ specMCP: ComposeSpec.MCP) { diff --git a/Sources/BasaltCLI/ServeCommand+Launch.swift b/Sources/BasaltCLI/ServeCommand+Launch.swift index 719640e46..fd4fdde88 100644 --- a/Sources/BasaltCLI/ServeCommand+Launch.swift +++ b/Sources/BasaltCLI/ServeCommand+Launch.swift @@ -84,6 +84,7 @@ extension ServeCommand { speculative.configure(&configuration) (configuration.kvPrecision, configuration.kvZones) = (kvCache.bits?.fixedPrecision, kvCache.zones) (configuration.kvHeadSplit, configuration.questTopK) = (kvCache.headSplit, kvCache.questTopK) + configuration.ropeYarn = kvCache.ropeYarn (configuration.attentionBackend, configuration.mobaTopK) = (kvCache.attentionBackend, kvCache.mobaTopK) configuration.batchSlots = maxConcurrent >= 2 ? batchSlots : 1 configuration.wiresWorkingSet = wiredLimit diff --git a/Sources/BasaltCLI/ServeConfigFile.swift b/Sources/BasaltCLI/ServeConfigFile.swift index 22c0ef872..93e296be7 100644 --- a/Sources/BasaltCLI/ServeConfigFile.swift +++ b/Sources/BasaltCLI/ServeConfigFile.swift @@ -199,6 +199,7 @@ extension ServeConfigFile { "serve.kv.evict": .number("--kv-evict"), "serve.kv.head_split": .number("--kv-head-split"), "serve.kv.quest_top_k": .int("--quest-top-k"), + "serve.rope_yarn": .number("--rope-yarn"), "serve.prompt_cache.mb": .int("--prompt-cache-mb"), "serve.prompt_cache.disk_mb": .int("--prompt-cache-disk-mb"), "serve.prompt_cache.disk_days": .int("--prompt-cache-disk-days"), diff --git a/Sources/BasaltCore/ComposeSchema.swift b/Sources/BasaltCore/ComposeSchema.swift index 1c069bf9e..8274ce31b 100644 --- a/Sources/BasaltCore/ComposeSchema.swift +++ b/Sources/BasaltCore/ComposeSchema.swift @@ -45,7 +45,7 @@ public enum ComposeSchema { Field("telemetry_confidence_every", .integer), Field("adaptive_thinking_budget", .boolean), Field("samplers", .boolean), Field("mtp_draft_head", .boolean), Field("expert_streaming", .boolean), Field("expert_cache_gb", .number), - Field("kv_head_split", .number), Field("quest_top_k", .integer), + Field("kv_head_split", .number), Field("quest_top_k", .integer), Field("rope_yarn", .number), ], "mcp": [ Field("enabled", .boolean), Field("rest", .boolean), Field("research_tools", .boolean), diff --git a/Sources/BasaltCore/ComposeSpec+Options.swift b/Sources/BasaltCore/ComposeSpec+Options.swift index cfc1f348e..04672a38c 100644 --- a/Sources/BasaltCore/ComposeSpec+Options.swift +++ b/Sources/BasaltCore/ComposeSpec+Options.swift @@ -17,6 +17,7 @@ extension ComposeSpec { public var expertCacheGB: Double? public var kvHeadSplit: Double? public var questTopK: Int? + public var ropeYarn: Double? public init() {} } @@ -55,6 +56,9 @@ extension ComposeSpec { issues.append(Issue("experimental.expert_cache_gb", "must be positive")) } } + if let factor = experimental.ropeYarn, !(factor > 1 && factor <= 64) { + issues.append(Issue("experimental.rope_yarn", "must lie in (1, 64]")) + } if let split = experimental.kvHeadSplit, !(0.05 ... 1).contains(split) { issues.append(Issue("experimental.kv_head_split", "must lie between 0.05 and 1")) } @@ -115,6 +119,7 @@ extension ComposeSpec { if let cacheGB = experimental.expertCacheGB { arguments += ["--expert-cache-gb", String(cacheGB)] } if let split = experimental.kvHeadSplit { arguments += ["--kv-head-split", String(split)] } if let topK = experimental.questTopK { arguments += ["--quest-top-k", String(topK)] } + if let factor = experimental.ropeYarn { arguments += ["--rope-yarn", String(factor)] } arguments += mcp.enable.flatMap { ["--mcp-enable", $0] } arguments += mcp.disable.flatMap { ["--mcp-disable", $0] } arguments += mcp.imageDirs.flatMap { ["--image-dir", ($0 as NSString).expandingTildeInPath] } @@ -147,6 +152,7 @@ extension ComposeSpec { "experimental.expert_streaming is bound to the engine configuration at start"), (experimental.kvHeadSplit != next.experimental.kvHeadSplit, "experimental.kv_head_split is bound to the engine configuration at start"), (experimental.questTopK != next.experimental.questTopK, "experimental.quest_top_k is bound to the engine configuration at start"), + (experimental.ropeYarn != next.experimental.ropeYarn, "experimental.rope_yarn is bound to the model load at start"), (mcp != next.mcp, "mcp options are bound to the server transport at start"), ] return checks.first(where: \.0)?.1 diff --git a/Sources/BasaltInference/EngineConfiguration.swift b/Sources/BasaltInference/EngineConfiguration.swift index ff9e98b33..eff250625 100644 --- a/Sources/BasaltInference/EngineConfiguration.swift +++ b/Sources/BasaltInference/EngineConfiguration.swift @@ -34,6 +34,7 @@ public struct EngineConfiguration: Sendable { public var smallMKernel = false public var q3Kernel = false public var kvSharedRow = false + public var ropeYarn: Double? } extension EngineConfiguration { diff --git a/Sources/BasaltInference/MLXInferenceEngine+Loading.swift b/Sources/BasaltInference/MLXInferenceEngine+Loading.swift index 4b5b7c250..4939c1874 100644 --- a/Sources/BasaltInference/MLXInferenceEngine+Loading.swift +++ b/Sources/BasaltInference/MLXInferenceEngine+Loading.swift @@ -148,7 +148,8 @@ extension MLXInferenceEngine { do { try faults.check(.load) if let gpuCacheLimit = configuration.gpuCacheLimit { Memory.cacheLimit = gpuCacheLimit } - let loaded = try await loadContainer(from: directory) + let source = ropeSource(directory, modelType: modelType, modelPath: modelPath) + let loaded = try await loadContainer(from: source) let smallM = configuration.smallMKernel let q3 = configuration.q3Kernel try await loaded.perform { @@ -165,7 +166,7 @@ extension MLXInferenceEngine { profile: ModelProfileRegistry.profile(forModelAt: modelPath), samplingDefaults: SamplingDefaults(generationConfig: ModelCache.generationConfig(at: directory)), controlTokens: ControlTokenGuard(modelDirectory: directory), - fingerprint: promptCacheDisk == nil ? nil : PromptCacheDiskStore.fingerprint(modelDirectory: directory), + fingerprint: promptCacheDisk == nil ? nil : PromptCacheDiskStore.fingerprint(modelDirectory: source), description: modelPath, hasMTPDrafter: drafts, expertReserve: await Self.expertReserve(loaded), capabilities: capabilities ?? .conservative, imageToken: Self.imageToken(in: ModelCache.config(at: directory)), transcribesAudio: transcribes) @@ -251,6 +252,20 @@ extension MLXInferenceEngine { return drafts } + static let ropeStagingRoot = FileManager.default.homeDirectoryForCurrentUser.appending(path: ".basalt/rope-yarn") + + func ropeSource(_ directory: URL, modelType: String?, modelPath: String) -> URL { + guard let factor = configuration.ropeYarn else { return directory } + do throws(RopeYarnStage.Refusal) { + let staged = try RopeYarnStage.stage(directory: directory, modelType: modelType, factor: factor, root: Self.ropeStagingRoot) + logger.info("--rope-yarn \(factor): YaRN over \(staged.nativeContext) native tokens, effective context \(staged.effectiveContext) (config staged at \(staged.directory.path))") + return staged.directory + } catch { + logger.warn("--rope-yarn \(factor) does not apply to \(modelPath): \(error.reason); the model loads with its stock RoPE") + return directory + } + } + func loadMTPDrafter(for loaded: ModelContainer, directory: URL, modelPath: String) async -> Bool { let logger = self.logger, speculativeLookup = configuration.speculativeLookup, draftHead = configuration.mtpDraftHead return await useMTPDrafter(in: loaded) { context in diff --git a/Sources/BasaltInference/RopeYarnStage.swift b/Sources/BasaltInference/RopeYarnStage.swift new file mode 100644 index 000000000..85444e670 --- /dev/null +++ b/Sources/BasaltInference/RopeYarnStage.swift @@ -0,0 +1,95 @@ +import CryptoKit +import Foundation + +enum RopeYarnStage { + struct Refusal: Error, Equatable { + let reason: String + } + + struct Staged: Equatable { + let directory: URL + let nativeContext: Int + let effectiveContext: Int + } + + static let modelTypes: Set = ["qwen3_5", "qwen3_5_text", "qwen3_5_moe", "qwen3_5_moe_text"] + + static func refusal(modelType: String?) -> Refusal? { + guard let modelType else { return Refusal(reason: "config.json names no model_type") } + if modelType.hasPrefix("gemma4") { + return Refusal(reason: "Gemma 4 uses proportional RoPE (p-RoPE) on its global layers and takes no RoPE scaling (#729)") + } + return modelTypes.contains(modelType) ? nil : Refusal(reason: "YaRN is wired for Qwen 3.5, 3.6 and 3.8 (qwen3_5) only, not \(modelType)") + } + + static func rewritten(_ root: [String: Any], factor: Double) throws(Refusal) -> (config: [String: Any], native: Int, effective: Int) { + let nested = root["text_config"] as? [String: Any] + var text = nested ?? root + guard let native = text["max_position_embeddings"] as? Int, native > 0 else { + throw Refusal(reason: "config.json has no max_position_embeddings to scale") + } + if let scaling = text["rope_scaling"], !(scaling is NSNull) { throw Refusal(reason: "config.json already sets rope_scaling") } + var rope = text["rope_parameters"] as? [String: Any] ?? [:] + if let type = (rope["rope_type"] ?? rope["type"]) as? String, type != "default" { + throw Refusal(reason: "rope_parameters already uses rope_type \(type)") + } + for key in ["rope_theta", "partial_rotary_factor"] where rope[key] == nil { rope[key] = text[key] } + rope["rope_type"] = "yarn" + rope["factor"] = factor + rope["original_max_position_embeddings"] = native + let effective = Int((Double(native) * factor).rounded()) + text["rope_parameters"] = rope + text["max_position_embeddings"] = effective + var config = root + if nested != nil { config["text_config"] = text } else { config = text } + return (config, native, effective) + } + + static func stagingDirectory(for directory: URL, factor: Double, root: URL) -> URL { + let digest = SHA256.hash(data: Data(directory.standardizedFileURL.path.utf8)).map { String(format: "%02x", $0) }.joined() + return root.appending(component: "\(digest.prefix(16))-yarn-x\(factor)") + } + + static func stage(directory: URL, modelType: String?, factor: Double, root: URL) throws(Refusal) -> Staged { + if let refusal = refusal(modelType: modelType) { throw refusal } + guard factor > 1, factor <= 64 else { throw Refusal(reason: "the factor must lie in (1, 64], got \(factor)") } + guard let data = try? Data(contentsOf: directory.appending(component: "config.json")), + let root0 = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else { + throw Refusal(reason: "config.json is unreadable") + } + let (config, native, effective) = try rewritten(root0, factor: factor) + let staging = stagingDirectory(for: directory, factor: factor, root: root) + do { + try publish(config: JSONSerialization.data(withJSONObject: config, options: [.sortedKeys]), source: directory, at: staging) + } catch { + throw Refusal(reason: "the staged config could not be written to \(staging.path): \(error.localizedDescription)") + } + return Staged(directory: staging, nativeContext: native, effectiveContext: effective) + } + + static func publish(config: Data, source: URL, at staging: URL) throws { + let fm = FileManager.default + let names = try fm.contentsOfDirectory(atPath: source.path).filter { $0 != "config.json" && !$0.hasPrefix(".") } + if matches(staging, config: config, names: names, source: source) { return } + try fm.createDirectory(at: staging.deletingLastPathComponent(), withIntermediateDirectories: true) + let temporary = staging.deletingLastPathComponent().appending(component: "\(staging.lastPathComponent).\(UUID().uuidString)") + try fm.createDirectory(at: temporary, withIntermediateDirectories: false) + try config.write(to: temporary.appending(component: "config.json")) + for name in names { + try fm.createSymbolicLink(at: temporary.appending(component: name), withDestinationURL: source.appending(component: name).resolvingSymlinksInPath()) + } + guard rename(temporary.path, staging.path) != 0 else { return } + if matches(staging, config: config, names: names, source: source) { + try? fm.removeItem(at: temporary) + } else { + _ = try fm.replaceItemAt(staging, withItemAt: temporary) + } + } + + static func matches(_ staging: URL, config: Data, names: [String], source: URL) -> Bool { + guard (try? Data(contentsOf: staging.appending(component: "config.json"))) == config else { return false } + return names.allSatisfy { name in + staging.appending(component: name).resolvingSymlinksInPath() == source.appending(component: name).resolvingSymlinksInPath() + } + } +} diff --git a/Sources/PerformanceBenchmark/main.swift b/Sources/PerformanceBenchmark/main.swift index 2d75570a7..8a5b14934 100644 --- a/Sources/PerformanceBenchmark/main.swift +++ b/Sources/PerformanceBenchmark/main.swift @@ -64,6 +64,9 @@ struct Benchmark: AsyncParsableCommand { @Option(name: .customLong("quest-top-k"), help: "Experimental: decode attends to sinks, a recent window and this many 64-token blocks between them (Quest)") var questTopK: Int? + @Option(name: .customLong("rope-yarn"), help: "Extend a Qwen 3.5/3.6/3.8 context with YaRN by this factor; other models load with stock RoPE and a warning") + var ropeYarn: Double? + @Flag(name: .customLong("experimental-kv-shared-row"), help: "Experimental: on Gemma 4 K=V global layers, store one 640-value row per KV head instead of 512 keys + 512 values (#645)") var kvSharedRow = false @@ -271,6 +274,7 @@ extension Benchmark { configuration.kvHeadSplit = kvHeadSplit configuration.questTopK = questTopK configuration.kvSharedRow = kvSharedRow + configuration.ropeYarn = ropeYarn configuration.repetitionPenalty = repetitionPenalty (configuration.topK, configuration.minP, configuration.seed) = (topK, minP, seed) (configuration.speculativeLookup, configuration.speculativeRecycling) = (speculativeLookup, speculativeRecycling) diff --git a/Tests/BasaltTests/RopeYarnFlagTests.swift b/Tests/BasaltTests/RopeYarnFlagTests.swift new file mode 100644 index 000000000..3b03133e7 --- /dev/null +++ b/Tests/BasaltTests/RopeYarnFlagTests.swift @@ -0,0 +1,113 @@ +import Foundation +import Testing +@testable import BasaltCore +@testable import BasaltInference + +@Suite("--rope-yarn: staged config, fingerprint split, refusals that keep stock RoPE (#729 P1)") +struct RopeYarnFlagTests { + static var qwen: [String: Any] { [ + "model_type": "qwen3_5", + "text_config": [ + "model_type": "qwen3_5_text", "max_position_embeddings": 262_144, "rope_theta": 10_000_000.0, "partial_rotary_factor": 0.25, + "hidden_size": 64, + ] as [String: Any], + ] } + + static func directory(_ config: [String: Any]) throws -> URL { + let directory = FileManager.default.temporaryDirectory.appending(path: "rope-yarn-\(UUID().uuidString)") + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) + try JSONSerialization.data(withJSONObject: config).write(to: directory.appending(component: "config.json")) + try Data("weights".utf8).write(to: directory.appending(component: "model.safetensors")) + try Data("{}".utf8).write(to: directory.appending(component: "tokenizer.json")) + return directory + } + + @Test("The rewrite sets yarn, the factor and the native context inside text_config, copies rope_theta and partial_rotary_factor into rope_parameters, and scales max_position_embeddings") + func rewrite() throws { + let (config, native, effective) = try RopeYarnStage.rewritten(Self.qwen, factor: 2) + #expect(native == 262_144 && effective == 524_288) + let text = try #require(config["text_config"] as? [String: Any]) + let rope = try #require(text["rope_parameters"] as? [String: Any]) + #expect(rope["rope_type"] as? String == "yarn") + #expect(rope["factor"] as? Double == 2) + #expect(rope["original_max_position_embeddings"] as? Int == 262_144) + #expect(rope["rope_theta"] as? Double == 10_000_000) + #expect(rope["partial_rotary_factor"] as? Double == 0.25) + #expect(text["max_position_embeddings"] as? Int == 524_288) + #expect(config["model_type"] as? String == "qwen3_5") + } + + @Test("A config that already scales its RoPE, or names no native context, is refused") + func rewriteRefusals() throws { + var yarn = Self.qwen + var text = try #require(yarn["text_config"] as? [String: Any]) + text["rope_parameters"] = ["rope_type": "yarn", "factor": 4.0] + yarn["text_config"] = text + #expect(throws: RopeYarnStage.Refusal.self) { try RopeYarnStage.rewritten(yarn, factor: 2) } + #expect(throws: RopeYarnStage.Refusal.self) { try RopeYarnStage.rewritten(["model_type": "qwen3_5_text"], factor: 2) } + } + + @Test("Staging writes the rewritten config beside symlinks to every other file, keyed by the source and factor; an identical staging is reused in place, a stale one is replaced, no temporary directory is left behind, and the fingerprint differs from the source's") + func stagedDirectory() throws { + let source = try Self.directory(Self.qwen) + let root = FileManager.default.temporaryDirectory.appending(path: "rope-yarn-root-\(UUID().uuidString)") + defer { try? FileManager.default.removeItem(at: source); try? FileManager.default.removeItem(at: root) } + let staged = try RopeYarnStage.stage(directory: source, modelType: "qwen3_5", factor: 2, root: root) + #expect(staged.directory == RopeYarnStage.stagingDirectory(for: source, factor: 2, root: root)) + #expect(staged.effectiveContext == 524_288) + let link = try FileManager.default.destinationOfSymbolicLink(atPath: staged.directory.appending(component: "model.safetensors").path) + #expect(URL(fileURLWithPath: link).resolvingSymlinksInPath() == source.appending(component: "model.safetensors").resolvingSymlinksInPath()) + #expect(PromptCacheDiskStore.fingerprint(modelDirectory: staged.directory) != PromptCacheDiskStore.fingerprint(modelDirectory: source)) + let marker = try FileManager.default.attributesOfItem(atPath: staged.directory.path)[.systemFileNumber] as? Int + let again = try RopeYarnStage.stage(directory: source, modelType: "qwen3_5", factor: 2, root: root) + #expect(again.directory == staged.directory) + #expect(try FileManager.default.attributesOfItem(atPath: again.directory.path)[.systemFileNumber] as? Int == marker) + try Data("{}".utf8).write(to: staged.directory.appending(component: "config.json")) + _ = try RopeYarnStage.stage(directory: source, modelType: "qwen3_5", factor: 2, root: root) + #expect(try Data(contentsOf: staged.directory.appending(component: "config.json")) != Data("{}".utf8)) + #expect(try FileManager.default.contentsOfDirectory(atPath: root.path).count == 1) + let text = try #require(JSONSerialization.jsonObject(with: Data(contentsOf: staged.directory.appending(component: "config.json"))) as? [String: Any])["text_config"] as? [String: Any] + #expect((text?["rope_parameters"] as? [String: Any])?["rope_theta"] as? Double == 10_000_000) + } + + @Test("Gemma 4, an unlisted family and a factor outside (1, 64] are refused with the reason, so the engine loads stock RoPE") + func stageRefusals() throws { + let source = try Self.directory(Self.qwen) + defer { try? FileManager.default.removeItem(at: source) } + let root = FileManager.default.temporaryDirectory.appending(path: "rope-yarn-root-\(UUID().uuidString)") + for (type, factor, reason) in [("gemma4", 2.0, "p-RoPE"), ("llama", 2.0, "qwen3_5"), ("qwen3_5", 1.0, "(1, 64]")] { + #expect { + _ = try RopeYarnStage.stage(directory: source, modelType: type, factor: factor, root: root) + } throws: { error in + (error as? RopeYarnStage.Refusal)?.reason.contains(reason) == true + } + } + #expect(!FileManager.default.fileExists(atPath: root.path)) + } + + @Test("The engine without --rope-yarn loads the source directory; with it, an unlisted family keeps the source and warns") + func engineSource() async throws { + let source = try Self.directory(Self.qwen) + defer { try? FileManager.default.removeItem(at: source) } + let plain = MLXInferenceEngine(EngineConfiguration()) + #expect(await plain.ropeSource(source, modelType: "qwen3_5", modelPath: source.path) == source) + var configuration = EngineConfiguration() + configuration.ropeYarn = 2 + let yarn = MLXInferenceEngine(configuration) + #expect(await yarn.ropeSource(source, modelType: "gemma4", modelPath: source.path) == source) + } + + @Test("rope_yarn in a Compose file becomes --rope-yarn and a reload that changes it needs a restart") + func compose() { + var spec = ComposeSpec(name: "yarn", models: ["chat": ComposeSpec.Model(source: .local("org/m"))], answer: "chat") + spec.experimental.ropeYarn = 2 + #expect(spec.optionArguments.contains("--rope-yarn")) + var next = spec + next.experimental.ropeYarn = 4 + #expect(spec.experimentalRestartReason(to: next)?.contains("rope_yarn") == true) + var invalid = spec + invalid.experimental.ropeYarn = 1 + #expect(invalid.experimentalIssues.contains { $0.path == "experimental.rope_yarn" }) + #expect(!spec.experimentalIssues.contains { $0.path == "experimental.rope_yarn" }) + } +} diff --git a/docs/compose.md b/docs/compose.md index 7401c6031..562a579b1 100644 --- a/docs/compose.md +++ b/docs/compose.md @@ -254,9 +254,9 @@ mcp: image_dirs: [./images] ``` -- **`experimental`:** lowers to the matching `serve` flags (`zero_copy_body`, `smallm_kernel`, `q3_kernel`, `kv_shared_row`, `speech_analyzer`, `image_fallback`, `ane_vision_tower`, `telemetry_confidence_every`, `adaptive_thinking_budget`, `samplers`, `mtp_draft_head`, `expert_streaming`, `expert_cache_gb`, `kv_head_split`, `quest_top_k`), validated with exact YAML line numbers (`telemetry_confidence_every` >= 0, `image_fallback` `ocr`, `ane_vision_tower` containing `metadata.json` and `tower.aimodel`, `expert_cache_gb` > 0 with `expert_streaming: true`, `kv_head_split` in `0.05...1`, `quest_top_k` in `1...4096`). Relative paths (`./`, `../`, `~`) resolve against the compose file's folder. +- **`experimental`:** lowers to the matching `serve` flags (`zero_copy_body`, `smallm_kernel`, `q3_kernel`, `kv_shared_row`, `speech_analyzer`, `image_fallback`, `ane_vision_tower`, `telemetry_confidence_every`, `adaptive_thinking_budget`, `samplers`, `mtp_draft_head`, `expert_streaming`, `expert_cache_gb`, `kv_head_split`, `quest_top_k`, `rope_yarn`), validated with exact YAML line numbers (`telemetry_confidence_every` >= 0, `image_fallback` `ocr`, `ane_vision_tower` containing `metadata.json` and `tower.aimodel`, `expert_cache_gb` > 0 with `expert_streaming: true`, `kv_head_split` in `0.05...1`, `quest_top_k` in `1...4096`, `rope_yarn` in `(1, 64]`). Relative paths (`./`, `../`, `~`) resolve against the compose file's folder. - **`mcp`:** configures the MCP stdio transport (`enabled`, `rest`, `research_tools`, `enable`, `disable`, `image_dirs`) using the same group and tool selectors as `--mcp-enable` / `--mcp-disable` (`serving`, `gemma`, `media`, `harness`, `xray`, `surgery`, `research`, `all`, or individual tool names; `disable` always wins). -- **Hot reload vs restart:** `speech_analyzer`, `image_fallback`, `telemetry_confidence_every` and `adaptive_thinking_budget` update live on `compose up` (`POST /v1/compose/apply`, printed under `experimental:`). Engine- and transport-bound flags (`zero_copy_body`, `smallm_kernel`, `q3_kernel`, `kv_shared_row`, `ane_vision_tower`, `samplers`, `mtp_draft_head`, `expert_streaming`, `expert_cache_gb`, `kv_head_split`, `quest_top_k` and `mcp`) report `needs a restart` in `compose diff` and are refused on live `apply`. +- **Hot reload vs restart:** `speech_analyzer`, `image_fallback`, `telemetry_confidence_every` and `adaptive_thinking_budget` update live on `compose up` (`POST /v1/compose/apply`, printed under `experimental:`). Engine- and transport-bound flags (`zero_copy_body`, `smallm_kernel`, `q3_kernel`, `kv_shared_row`, `ane_vision_tower`, `samplers`, `mtp_draft_head`, `expert_streaming`, `expert_cache_gb`, `kv_head_split`, `quest_top_k`, `rope_yarn` and `mcp`) report `needs a restart` in `compose diff` and are refused on live `apply`. ### Benchmarks and Leaderboard Submissions (version 2, `#492`) A `version: 2` compose file may declare a top-level `benchmarks` block with shared `defaults` and named `suites` (either under `suites:` or as shorthand suite keys directly under `benchmarks:`):