Repository navigation
fix(exla): solve f16 triangular systems in f32 on CUDA - #1890
Merged
Merged
Conversation
XLA on CUDA lowers triangular_solve to cuBLAS trsm, which has no f16 routine, so f16 triangular_solve raised "Invalid type for triangular solve". On CUDA, f16 systems are now solved in f32 and the result is converted back to f16, which is what XLA already does for bf16. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ApZrZkd5sFVCfLWjPxS8o1
heydtn
marked this pull request as ready for review
October 20, 2026 22:02
polvalente
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On CUDA,
Nx.LinAlg.triangular_solve/3raises for f16 inputs:XLA on CUDA rewrites
triangular_solveinto a cuBLAStrsmcustom call, and that call only supports f32, f64, c64 and c128. For bf16, XLA converts the operands to f32 around the call and converts the result back, but it passes f16 through unchanged, so the call fails at runtime. On the CPU, XLA expands the solve into regular ops, so f16 works there.This PR does for f16 on CUDA what XLA already does for bf16: it solves the system in f32 and converts the result to f16. Other types and platforms are unchanged.
The new test in
nx_linalg_doctest_test.exscovers everyleft_side/lower/transform_acombination on a batch of f16 matrices and compares against the f32 result. It fails on CUDA without this change and passes on both CUDA and host with it.Tested on an RTX 5070 Ti (CUDA 12.9, cuDNN 9.10,
XLA_TARGET=cuda12)