Conversation
…#5318)"" This reverts commit 7da56015a19ce0cad13a219cabb80f0046d55ecb.
The enum bias change (#5318) commented out the sharding_tests CI job. This re-enables them so that Reactant compatibility is tested. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace `@enum Bias LeftBias RightBias` with a plain Bool: `bias(u) = u > 0` (true = left, false = right). This preserves the performance optimization from #5318 (single concrete type, so Julia compiles one method instead of two) while being Reactant-safe: Bool is a ReactantPrimitive that Reactant can trace natively, unlike Julia enums which are not supported by Reactant's tracing infrastructure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Benchmark ComparisonBenchmark Comparison: PR vs Main
NSYS Kernel ProfilingEarthOcean_tripolar_360x180x50_F64_WENOVectorInvariantDefault_WENO7_CATKE_2tr
|
|
I don't think this will actually solve the issue. After speaking to @giordano, it seems that the compiler uses too much memory when trying to compile the kernel - this will likely be the case if we use enums or bools. On top of that, enums are just structs containing ints (after macros) and run fine with all the other Reactant tests. I think it is a sharding issue specifically. Moreover, the test runs fine on MacOS, so it is a Linux specific issue with the code generation. |
Can you explain how this is different from using the |
|
@giordano may be able to help with an explanation too I suspect. |
|
I don't have a great explanation besides what Jack said above. In practice, somehow the sharding attributes to the MLIR modules disappear when doing this, and that causes as a side effect memory usage to blow up, which is only the visible symptom, but not the root (😏) problem. Why this is happening, is wholly unclear. I have the feeling it's bug in the x86-64 XLA backend, but haven't investigated too much in that direction. The problem is independent of the specific implementation (enum vs boolean), once the sharding problem is resolved, that's a matter of style preference. |
|
Ok I think you are saying that the difference between enum and Bool is style preference only? This is my question: what is the difference between enums (#5450) and bools (this PR)? |
I think so. The generated code, at least for sharding, is the same. |
|
Which approach is preferred aesthetically? This one or enums? I am agnostic. |
I'm not sure to be honest. I personally find the enum approach cute 😅 But I don't know if that's better. |
|
If they are the same in terms of performance and maintainability I also prefer the enum because it is more explicative |
|
ill close this then |
Summary
Replaces the
@enum Bias LeftBias RightBiasfrom #5318 (and the originalstruct LeftBias end/struct RightBias end) with a plainBool:This preserves the performance optimization from #5318 — a single concrete type means Julia compiles one method instead of two specialized methods with call-site branching — while being Reactant-safe.
Boolis aReactantPrimitivethat Reactant can trace natively, unlike Julia enums which are not supported by Reactant's tracing infrastructure and may cause memory corruption (see #5449).Builds on #5450 (reinstate of #5318) to preserve Jack Franklin's original contribution in the git history.
Test plan
🤖 Generated with Claude Code