From fb20a471205e3f473ead73c81f7a5537176f7c40 Mon Sep 17 00:00:00 2001 From: Sukru Tikves Date: Sat, 10 Oct 2026 16:15:34 -0700 Subject: [PATCH] Bind additionalStates on the pipelined constrained-generation path The pipelined engine's constrained-encode step built its async state views with only the growing key/value cache and omitted additionalStates, so bundles that declare more than two states (e.g. Muse Glimmer's sliding-ring key/value pair) failed the first constrained encode with "Missing state view". Bind additionalStates the same way the plain-decode and prefill paths do. It is a no-op for standard two-state models, so existing bundles are unaffected. Fixes #316. --- .../InferenceEngines/CoreAIPipelinedEngine.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift b/swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift index 8acb75ca..0fa7e213 100644 --- a/swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift +++ b/swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift @@ -1562,6 +1562,9 @@ private struct EngineImpl: ~Copyable { var asyncStates = InferenceFunction.AsyncMutableViews() asyncStates.insert(&keyState, for: keyCacheName) asyncStates.insert(&valState, for: valueCacheName) + // Non-growing states (e.g. sliding-ring caches) are bound here too, like + // the plain-decode and prefill paths; nil for standard two-state bundles. + additionalStates?.bind(into: &asyncStates) // Safe: constrained loop awaits each token before encoding the next step, so logits are consumed before overwrite. let logitsBuffer = logits.metalBuffer