Skip to content

Add narrow-precision floats to cudaDataType#3180

Open
AntonOresten wants to merge 2 commits into
JuliaGPU:mainfrom
AntonOresten:append-narrow
Open

Add narrow-precision floats to cudaDataType#3180
AntonOresten wants to merge 2 commits into
JuliaGPU:mainfrom
AntonOresten:append-narrow

Conversation

@AntonOresten

Copy link
Copy Markdown
Contributor

Adds narrow-precision floats to the cudaDataType enum based on library_types.h in CUDA 13:

    CUDA_R_8F_E4M3 = 28, /* real as a nv_fp8_e4m3 */
    CUDA_R_8F_UE4M3 = CUDA_R_8F_E4M3, /* real as an unsigned nv_fp8_e4m3 */
    CUDA_R_8F_E5M2 = 29, /* real as a nv_fp8_e5m2 */
    CUDA_R_8F_UE8M0 = 30,  /* real as an exponent-only unsigned nv_fp8_e8m0 */
    CUDA_R_6F_E2M3  = 31,  /* real as a nv_fp6_e2m3 */
    CUDA_R_6F_E3M2  = 32,  /* real as a nv_fp6_e3m2 */
    CUDA_R_4F_E2M1  = 33,  /* real as a nv_fp4_e2m1 */

R_8F_UE4M3 is an alias of R_8F_E4M3, differing semantically in that the sign is meaningless in the NVFP4 block-scaling format where every element has a sign anyway.

Implementations like DLFP8Types.jl and Microfloats.jl could define e.g. Base.convert(::Type{CUDACore.cudaDataType}, ::Type{Float8_E5M2}) = CUDACore.R_8F_E5M2 in an extension, or there could be some jltype_to_cudaDataType function.

It doesn't work the other way though, since each cudaDataType can only map to one julia type, but not sure if this is a problem.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CUDA.jl Benchmarks

Details
Benchmark suite Current: 603e01b Previous: fbb9098 Ratio
array/accumulate/Float32/1d 98650 ns 98020 ns 1.01
array/accumulate/Float32/dims=1 74613 ns 73968 ns 1.01
array/accumulate/Float32/dims=1L 1599478 ns 1598577 ns 1.00
array/accumulate/Float32/dims=2 140349 ns 139829 ns 1.00
array/accumulate/Float32/dims=2L 660575 ns 660479 ns 1.00
array/accumulate/Int64/1d 118541 ns 118236 ns 1.00
array/accumulate/Int64/dims=1 78538 ns 78818 ns 1.00
array/accumulate/Int64/dims=1L 1716721 ns 1717142 ns 1.00
array/accumulate/Int64/dims=2 153234 ns 151913 ns 1.01
array/accumulate/Int64/dims=2L 986806 ns 987639 ns 1.00
array/broadcast 18155 ns 18185 ns 1.00
array/construct 915.21875 ns 900.1904761904761 ns 1.02
array/copy 16092 ns 16081 ns 1.00
array/copyto!/cpu_to_gpu 209944 ns 210623 ns 1.00
array/copyto!/gpu_to_cpu 241959 ns 242406 ns 1.00
array/copyto!/gpu_to_gpu 10027 ns 8883.666666666666 ns 1.13
array/iteration/findall/bool 132638 ns 132352 ns 1.00
array/iteration/findall/int 147033 ns 146447 ns 1.00
array/iteration/findfirst/bool 68498 ns 67784 ns 1.01
array/iteration/findfirst/int 69743 ns 69220 ns 1.01
array/iteration/findmin/1d 62791 ns 62612 ns 1.00
array/iteration/findmin/2d 100452 ns 99990 ns 1.00
array/iteration/logical 187356 ns 186900 ns 1.00
array/iteration/scalar 61927 ns 62246 ns 0.99
array/permutedims/2d 49356 ns 49143 ns 1.00
array/permutedims/3d 50426 ns 49912 ns 1.01
array/permutedims/4d 49671 ns 50252 ns 0.99
array/random/rand/Float32 10979 ns 10722 ns 1.02
array/random/rand/Int64 21140 ns 20792 ns 1.02
array/random/rand!/Float32 7629 ns 7728 ns 0.99
array/random/rand!/Int64 20269 ns 20553 ns 0.99
array/random/randn/Float32 33042 ns 33301 ns 0.99
array/random/randn!/Float32 23523 ns 24939 ns 0.94
array/reductions/mapreduce/Float32/1d 31277 ns 31290 ns 1.00
array/reductions/mapreduce/Float32/dims=1 37569 ns 37312 ns 1.01
array/reductions/mapreduce/Float32/dims=1L 50264 ns 50036 ns 1.00
array/reductions/mapreduce/Float32/dims=2 54868 ns 54292 ns 1.01
array/reductions/mapreduce/Float32/dims=2L 66489 ns 65880 ns 1.01
array/reductions/mapreduce/Int64/1d 38437 ns 39323 ns 0.98
array/reductions/mapreduce/Int64/dims=1 40493 ns 40145 ns 1.01
array/reductions/mapreduce/Int64/dims=1L 88023 ns 87779 ns 1.00
array/reductions/mapreduce/Int64/dims=2 57305 ns 57093 ns 1.00
array/reductions/mapreduce/Int64/dims=2L 82670 ns 82500 ns 1.00
array/reductions/reduce/Float32/1d 31665 ns 31207 ns 1.01
array/reductions/reduce/Float32/dims=1 37442 ns 37284 ns 1.00
array/reductions/reduce/Float32/dims=1L 50207 ns 50034 ns 1.00
array/reductions/reduce/Float32/dims=2 54870 ns 54677 ns 1.00
array/reductions/reduce/Float32/dims=2L 67734 ns 67287 ns 1.01
array/reductions/reduce/Int64/1d 38022 ns 38695 ns 0.98
array/reductions/reduce/Int64/dims=1 39940 ns 39938 ns 1.00
array/reductions/reduce/Int64/dims=1L 88256 ns 87933 ns 1.00
array/reductions/reduce/Int64/dims=2 57034 ns 56801 ns 1.00
array/reductions/reduce/Int64/dims=2L 82019 ns 82417 ns 1.00
array/reverse/1d 16257 ns 16212 ns 1.00
array/reverse/1dL 68999 ns 69012 ns 1.00
array/reverse/1dL_inplace 67048 ns 66891 ns 1.00
array/reverse/1d_inplace 9634.666666666666 ns 9703.666666666666 ns 0.99
array/reverse/2d 19422 ns 19393 ns 1.00
array/reverse/2dL 72757 ns 72842 ns 1.00
array/reverse/2dL_inplace 66722 ns 66766 ns 1.00
array/reverse/2d_inplace 10315 ns 10134 ns 1.02
array/sorting/1d 2654767 ns 2658542 ns 1.00
array/sorting/2d 1037891 ns 1039211 ns 1.00
array/sorting/by 3192053 ns 3193897 ns 1.00
cuda/synchronization/context/auto 1028.9 ns 1040 ns 0.99
cuda/synchronization/context/blocking 783.5858585858585 ns 795.5444444444445 ns 0.98
cuda/synchronization/context/nonblocking 5870 ns 5738.666666666667 ns 1.02
cuda/synchronization/stream/auto 879.8301886792453 ns 889.2083333333334 ns 0.99
cuda/synchronization/stream/blocking 675.8141025641025 ns 676.8387096774194 ns 1.00
cuda/synchronization/stream/nonblocking 5741.714285714285 ns 5562.285714285715 ns 1.03
integration/byval/reference 147462 ns 147385 ns 1.00
integration/byval/slices=1 149274 ns 149634 ns 1.00
integration/byval/slices=2 292306 ns 292176 ns 1.00
integration/byval/slices=3 434580 ns 435096 ns 1.00
integration/cudadevrt 104483 ns 104391 ns 1.00
integration/volumerhs 9307671 ns 9304645 ns 1.00
kernel/indexing 12574 ns 12267 ns 1.03
kernel/indexing_checked 13247 ns 13063 ns 1.01
kernel/launch 2014.111111111111 ns 1980.4 ns 1.02
kernel/occupancy 722.2867647058823 ns 638.797619047619 ns 1.13
kernel/rand 13564 ns 14927 ns 0.91
latency/import 3912069945 ns 3890391684 ns 1.01
latency/precompile 4687020413 ns 4668709973 ns 1.00
latency/ttfp 4916672311 ns 4883527794 ns 1.01

This comment was automatically generated by workflow using github-action-benchmark.

@AntonOresten

Copy link
Copy Markdown
Contributor Author

@maleadt How, and where, could packages define DataType to cudaDataType mappings? Is this considered public API? If not, would it need to be in extensions of CUDACore?

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 17.42%. Comparing base (fbb9098) to head (603e01b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3180      +/-   ##
==========================================
- Coverage   17.44%   17.42%   -0.03%     
==========================================
  Files         124      124              
  Lines        9883     9883              
==========================================
- Hits         1724     1722       -2     
- Misses       8159     8161       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant