Skip to content

chore: Port the fine decoders to fine 0.2 - #167

Merged
polvalente merged 3 commits into
elixir-nx:mainfrom
georgeguimaraes:chore/fine-0.2
Nov 27, 2026
Merged

polvalente merged 3 commits into
elixir-nx:mainfrom
georgeguimaraes:chore/fine-0.2

Conversation

@georgeguimaraes

Copy link
Copy Markdown
Member

Do not merge before EXLA releases on fine 0.2. Hex EXLA 1.0.0 requires fine ~> 0.1 and does not compile with fine 0.2 (no member named 'try_decode' in 'fine::Decoder<xla::Shape>'). After this PR, a project that uses EMLX and hex EXLA 1.0.0 cannot compile. Today it is the opposite: EXLA main requires fine ~> 0.2.0, and EMLX does not compile with fine 0.2. Thus the EMLX release with this PR and the EXLA release on fine 0.2 must come out together.

fine 0.2 replaces Decoder<T>::decode with try_decode, which returns fine::DecodeResult<T>. The requirement ~> 0.1 let a new project get fine 0.2, and then EMLX did not compile.

  • Require fine ~> 0.2.0, as EXLA main does.
  • Port the 11 custom decoders to try_decode. A term of the wrong type now gives a fine::DecodeError instead of a std::invalid_argument. The std::variant and std::optional decoders of fine try the next type only on a DecodeError. fine::decode still raises with the same message.
  • Remove the decoder for std::optional<TensorArg>. The generic std::optional decoder of fine does the same nil check.
  • Add emlx::native::decode_field for the struct decoders of the compiler.

emlx_axon/mix.lock keeps fine 0.1.6, because emlx_axon builds hex EMLX 0.5.0 by default. With EMLX_AXON_LOCAL_EMLX=true, as in CI, mix deps.get takes fine 0.2.0.

Checks on an M2 Pro:

  • :cpu suite: 2739 of 2739. EMLX_TEST_DEFAULT_GPU=true: the same 12 failures as main (fix: Move every operand of an op to one device #166 fixes them).
  • emlx_axon with the local EMLX and EMLX_TEST_DEFAULT_GPU=true: 192 of 192.
  • A deallocated tensor in a fine NIF raises "Tensor has been deallocated", as on main.

fine 0.2 replaces Decoder<T>::decode with try_decode, which returns fine::DecodeResult<T>. EMLX did not compile with fine 0.2, and the requirement "~> 0.1" let a new project get 0.2. EXLA main requires "~> 0.2.0", so a project could not use EMLX and EXLA main together.

- Require fine "~> 0.2.0".
- Port the 11 custom decoders to try_decode. A term of the wrong type now gives a fine::DecodeError instead of a std::invalid_argument, as fine 0.2 requires. The std::variant and std::optional decoders of fine try the next type only on a DecodeError. fine::decode still raises with the same message.
- Remove the decoder for std::optional<TensorArg>. The generic std::optional decoder of fine does the same nil check.
- Add emlx::native::decode_field for the struct decoders of the compiler.
@georgeguimaraes
georgeguimaraes marked this pull request as ready for review November 27, 2026 15:46
georgeguimaraes and others added 2 commits November 27, 2026 12:46
Require nx ~> 1.1 in emlx and emlx_axon, and lock nx 1.1.0, with complex
1.0.1 and telemetry 1.4.3 that come with it. The root mix.lock had nx
0.13.0. emlx_axon keeps fine 0.1.6, since it builds hex EMLX by default.

Co-authored-by: Paulo Valente <polvalente@users.noreply.github.com>
@polvalente
polvalente merged commit 15306d4 into elixir-nx:main Nov 27, 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