[code-reflection] RFR: [hat] Proposal for bfloat16 [v2]
Gary Frost
gfrost at openjdk.org
Wed Dec 3 12:26:55 UTC 2025
On Wed, 3 Dec 2025 11:53:56 GMT, Juan Fumero <jfumero at openjdk.org> wrote:
>> This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT.
>>
>> Testing for OpenCL:
>>
>>
>> HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type
>>
>>
>> Testing for CUDA:
>>
>>
>> HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type
>>
>>
>> Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example.
>
> Juan Fumero has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 22 commits:
>
> - [hat] abstracting the OpenCL and CUDA code builders
> - Merge branch 'code-reflection' into hat/type/bfloat16
> - Merge branch 'code-reflection' into hat/type/bfloat16
> - [hat] remove custom Op for bfloat
> - single line imports in hat code builders
> - single line imports in hat code builders
> - [hat] test matmul with bfloat16
> - [hat] dialect for bfloat16 removed
> - [hat] new test file included in the hat test list
> - [hat] OpenCL handler for bfloat16 via float convs
> - ... and 12 more: https://git.openjdk.org/babylon/compare/0a7929cc...ddc932c3
hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java line 316:
> 314: byte f32Mixed = hatF16BinaryOp.getF32();
> 315:
> 316: oparen();
you might consider leaning into paren($->$.generateReduceFloat....().) rather than balancing parenthesis yourself.
hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java line 334:
> 332:
> 333: if (f32Mixed == HATF16BinaryOp.LAST_OP) {
> 334: cparen();
Looks like separate executaionpaths here can create imbalanced paren?
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2584905562
PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2584909503
More information about the babylon-dev
mailing list