Skip to content

Conversation

@schmatz
Copy link
Contributor

@schmatz schmatz commented Jan 29, 2026

See #269 for motivation and details.

Add #if arch(arm64) guard around Float16 usage in SortformerModelInference.swift.

Float16 is only available on Apple Silicon, not Intel, regardless of macOS version. The existing #available check only guards OS version, not CPU architecture. This causes build failures when archiving macOS apps for distribution (which builds for both arm64 and x86_64 by default). I tried to work around this with every setting I could find but did not get it working in the GUI (CLI worked.)

Fixes build error:

  • 'Float16' is unavailable in macOS
  • Conformance of 'Float16' to 'MLShapedArrayScalar' is unavailable in macOS

Why is this change needed?

Allows building Mac apps that use this with the Xcode GUI

Add #if arch(arm64) guard around Float16 usage in SortformerModelInference.swift.

Float16 is only available on Apple Silicon, not Intel, regardless of macOS
version. The existing #available check only guards OS version, not CPU
architecture. This causes build failures when archiving macOS apps for
distribution (which builds for both arm64 and x86_64 by default).

Fixes build error:
- 'Float16' is unavailable in macOS
- Conformance of 'Float16' to 'MLShapedArrayScalar' is unavailable in macOS
Copilot AI review requested due to automatic review settings January 29, 2026 00:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an architecture guard around the Float16-based Sortformer chunk embedding extraction so that macOS archives targeting x86_64 no longer fail to build. It preserves the existing runtime behavior on supported arm64 platforms while excluding the unsupported Float16 path from Intel builds.

Changes:

  • Refactors the chunk-embedding decoding logic to keep the existing Float32 code path as the primary option.
  • Wraps the Float16 MLShapedArray extraction and conversion in an #if arch(arm64) compile-time guard plus an #available(macOS 15.0, iOS 18.0, *) runtime check.
  • Ensures that on non-arm64 architectures the code consistently throws SortformerError.inferenceFailed("Missing chunk_pre_encoder_embs_out") rather than attempting to compile Float16 usages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@schmatz schmatz changed the title Fix Float16 build failure on x86_64 architecture Fix Float16 build failure in Xcode GUI Jan 29, 2026
@schmatz schmatz changed the title Fix Float16 build failure in Xcode GUI Fix Float16 build failure in Xcode GUI by adding architecture checks Jan 29, 2026
@Alex-Wengg
Copy link
Contributor

Alex-Wengg commented Jan 29, 2026

@schmatz its gonna be a while until we make a release tag as we are cleaning some things up . if that is fine i will merge this pr asap

@Alex-Wengg Alex-Wengg merged commit 01479c7 into FluidInference:main Jan 30, 2026
10 checks passed
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.

2 participants