Skip to content

Resolve compiled assets in diffusion loaders and fail fast on missing files - #252

Draft
stikves wants to merge 1 commit into
apple:mainfrom
stikves:fix-diffusion-compiled-assets-230
Draft

stikves wants to merge 1 commit into
apple:mainfrom
stikves:fix-diffusion-compiled-assets-230

Conversation

@stikves

@stikves stikves commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #230.

Flux2 built the text encoder and full-mode VAE encoder URLs from the raw
metadata.json name, bypassing the .aimodel.aimodelc fallback used for the
other components. On a compiled iOS bundle those paths point at a missing asset;
AIModel(contentsOf:) then stalls without returning or throwing, so the pipeline
hangs at load. The unchecked encoder also let supportsImageToImage report true
for an absent file.

  • CoreAIDiffusionModelFunction checks the asset exists before loading and throws
    modelFileNotFound, so a missing component surfaces a clear error instead of
    hanging. This covers every diffusion pipeline.
  • Flux2 resolves the text encoder via ModelBundle.resolveAssetURL and reports a
    missing text encoder up front; the optional encoder is resolved and
    existence-checked so supportsImageToImage is accurate.
  • Wan resolves its components through ModelBundle.resolveAssetURL.
  • Tests for the missing-file guard and the .aimodel.aimodelc fallback.

Verified with swift test. On-device verification against a compiled FLUX.2 Klein
bundle is still pending.

…oaders

Flux2 loaded the text encoder and full-mode VAE encoder from the raw
metadata.json name, bypassing the .aimodel -> .aimodelc fallback. On a
compiled iOS bundle those URLs point at a missing file, and
AIModel(contentsOf:) neither returns nor throws, so the app hangs at 0%
CPU. The unchecked full-mode encoder also made supportsImageToImage
report true for a missing file.

- Guard CoreAIDiffusionModelFunction.loadResources/hasFunction with a
  file-existence check that throws instead of hanging (covers all
  diffusion pipelines).
- Flux2: resolve the text encoder via ModelBundle.resolveAssetURL and
  report a missing component up front; resolve + existence-check the
  optional encoder so supportsImageToImage is truthful.
- Wan: resolve components via ModelBundle.resolveAssetURL.
- Tests for the missing-file guard and the .aimodel -> .aimodelc fallback.
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.

Flux2Pipeline loader ignores compiled assets for the text encoder, decoder and optional encoder, and hangs on AOT bundles

1 participant