fix(exla): restore OutputBuffer default constructor for CUDA callback path - #1813
Conversation
… path The host-callback hooks change left OutputBuffer with only the AnyBuffer constructor. A user-declared constructor suppresses the implicit default constructor, but runtime_callback_cuda.cc:113 default-constructs an OutputBuffer for its declare-then-fill staging pattern — so XLA_TARGET=cuda builds fail to compile on current main. CPU-only CI never builds that translation unit, which is why the break is invisible upstream. Members carry safe default initializers (nullptr / 0), so the defaulted constructor is well-defined. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
I think the fix is to actually use the new constructor |
Per review: rather than restoring the default constructor, construct OutputBuffer from the AnyBuffer (which computes the size) and repoint data at the host staging buffer. The header is back to exactly what main has, and the duplicated ByteWidth * element_count computation in runtime_callback_cuda.cc goes away. Verified: XLA_TARGET=cuda12 compile succeeds with this change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
hmm okay tried that way, seemed to work (generated text below) Reworked as suggested — the CUDA path now uses the Re-verified: |
|
man I really gotta give more instruction not to just like reply on these threads thats annoying. This is just an error I ran into before and figured I'd upstream the short workaround on. It's drifting into territory where I'm not sure I have the context for this code change so be aware of that, more just if this error wasn't encountered yet its documented and here's a plausible fix. |
What I ran into
Building EXLA from source with
XLA_TARGET=cuda12fails to compile on current main (da1f4fb8):I hit this on an RTX 5090 (sm_120), where building from source is the normal path. Every from-source CUDA build of current main is affected; CPU builds are fine, which is why CI stays green —
runtime_callback_cuda.ccis only compiled when targeting CUDA (-DCUDA_ENABLED).Cause
#1766 gave
OutputBuffera user-declared constructor takingxla::ffi::AnyBuffer. In C++, declaring any constructor suppresses the implicitly-generated default constructor. But the CUDA callback path still default-constructs anOutputBufferand fills it field-by-field:Fix
Re-declare the default constructor explicitly (
OutputBuffer() = default;). The members already have safe initializers (nullptr/0), so the defaulted constructor is well-defined and the CPU path is untouched.Verification
Both directions verified on Linux x86_64 (clang, CUDA 12.9, Erlang/OTP 27, Elixir 1.18.4) with
XLA_TARGET=cuda12:libexla.soproducedNo test accompanies this: it is a compile-time fix in a translation unit CI doesn't build, so the CUDA compile itself is the test.
🤖 Generated with Claude Code