Skip to content

Support FP16, BF16 in ET bindings #373

Closed
Closed

Description

@chmjkb
No description provided.

Activity

  1. msluszniak commented on Sep 17, 2025

    @msluszniak
    Member

    Are we able to support them considering the fact that fixed width floating point numbers were introduced in c++23? https://en.cppreference.com/w/cpp/types/floating-point.html

  2. added
    executorchIssues and tasks related specifically to ExecuTorch
    and removed on Oct 6, 2025
  3. tslater commented on Feb 28, 2026

    @tslater

    Is FP16 not supported for useExecutorchModule? I'm having trouble and wanted to confirm.

  4. msluszniak commented on Mar 1, 2026

    @msluszniak
    Member

    Could you describe what troubles do you have? Model that uses fp16 are supported, e.g. lfm2.5 instruct.

  5. tslater commented on Mar 2, 2026

    @tslater

    @msluszniak That's very helpful to know, thanks!

    I'm getting this error:

    {"code": 17, "message": "The model's forward function did not succeed. Ensure     
      the model input is correct."}                

    I think it might be by exporter's executorch version or something else. I'm going to keep digging on it.

  6. msluszniak commented on Mar 2, 2026

    @msluszniak
    Member

    Well, exit code 17 is operation is not implemented:

      /// Operation is not yet implemented.
      NotImplemented = 0x11,
    

    This means, that some operations used by the model are not supported. Please run the model on android, run logcat in a separate terminal and check in the logs which operation is not implemented. By the way, what kind of model have you exported, LLM?

  7. chmjkb commented on Mar 2, 2026

    @chmjkb
    CollaboratorAuthor

    Hey @tslater, can you share a code snippet for reproduction? Ideally, we'd love if you opened up an issue explaining what you're trying to achieve and the code snippet, as its easier for us to track it this way. Thanks!

  8. self-assigned this
    on May 29, 2026
  9. msluszniak commented on May 29, 2026

    @msluszniak
    Member

    Closing — the ergonomic side of this can't ship today on the default RN stack, and what we can do is already possible without an API change.

    FP16: The TS-side win would be accepting a Float16Array in TensorBuffer. TypeScript 5.7+ has the type, but Hermes (the JS engine bundled with current React Native — checked against 0.16.0 / RN 0.81) does not expose Float16Array as a global, so new Float16Array(...) throws ReferenceError at runtime. Until Hermes ships it, exposing the type would only be misleading.

    BF16: No JS BFloat16Array exists in any engine.

    What works today for either dtype without any binding change: pack the 16-bit values into a Uint16Array (or a raw ArrayBuffer) yourself and pass it as dataPtr with scalarType: ScalarType.HALF (or 15 for BFloat16). The native input path at JsiConversions.h reads the underlying ArrayBuffer raw, so half-precision / bfloat16 bytes flow through ExecuTorch correctly. On output, the result comes back as an ArrayBuffer you interpret the same way.

    We can revisit when Hermes adds Float16Array (tracked upstream) and reopen as a docs / typed-array unblock at that point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

executorchIssues and tasks related specifically to ExecuTorch

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions