Skip to content

Fix guided generation refused after engine load on static-shape engines - #248

Merged
stikves merged 3 commits into
apple:mainfrom
stikves:sukru/fix-guided-generation-static-engine
Sep 14, 2026
Merged

stikves merged 3 commits into
apple:mainfrom
stikves:sukru/fix-guided-generation-static-engine

Conversation

@stikves

@stikves stikves commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

isGuidedGenerationSupported checked loadedEngineIsConstrainedCapable first and returned immediately once non-nil, so the loadedEngineSupportsLogits fallback never ran after an engine loaded.

StaticShapeEngine supports logits but isn't ConstrainedGenerationCapable, so guided generation was reported unsupported after the first request even though the executor's guard would have allowed it.

Moved the check into InferenceEngine.supportsGuidedGeneration, used by both the executor guard and capability reporting.

Fixes #247

isGuidedGenerationSupported checked loadedEngineIsConstrainedCapable first
and returned immediately once non-nil, so the loadedEngineSupportsLogits
fallback never ran after an engine loaded. StaticShapeEngine (chunked-static
iOS exports) supports logits but isn't ConstrainedGenerationCapable, so
guided generation was reported unsupported after the first request even
though the executor's guard would have allowed it.

Moved the check into InferenceEngine.supportsGuidedGeneration, used by both
the executor guard and capability reporting.

Fixes apple#247
Comment thread swift/Tests/LanguageModelsTests/ModelResourcesTests.swift
stikves and others added 2 commits September 14, 2026 11:06
Covers the second operand of the capability OR: an engine that is
ConstrainedGenerationCapable with supportsLogits == false must still
report guided generation supported. Reuses MockConstrainedEngine.
@stikves
stikves marked this pull request as ready for review September 14, 2026 19:40
@stikves stikves self-assigned this Sep 14, 2026
@stikves
stikves merged commit 3e172fb into apple:main Sep 14, 2026
3 checks passed
@stikves
stikves deleted the sukru/fix-guided-generation-static-engine branch September 14, 2026 20:45
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.

Guided generation refused for every chunked-static (iOS) export after the first request

3 participants