Skip to content

Reductions along dims=2 drop to ~250 GB/s for 3072–4096 rows and fewer than ~2700 columns, slower than GPUArrays 11 #174

Closed

Description

@CarloLucibello

AI agent:


sum(x; dims=2) of a Float32 matrix runs at 1–1.26 TB/s for most shapes on an RTX 5090, but at 230–290 GB/s for some shapes with 3072–4096 rows and fewer than ~2700 columns. There it is slower than GPUArrays 11's own kernel was.

using CUDA, Printf
const FLUSH = CUDA.zeros(UInt8, 256 * 2^20)   # larger than the L2 cache
bench(f; n=30) = (f(); CUDA.synchronize(); minimum(1e6 * (fill!(FLUSH, 0x00); CUDA.@elapsed f()) for _ in 1:n))  # µs
for (M, N) in ((2048, 4096), (3072, 2730), (4096, 1024), (4096, 2048), (4096, 4096), (8192, 1024))
    x = CUDA.randn(Float32, M, N)
    t = bench(() -> sum(x; dims=2))
    @printf("%5d × %-5d %6.1f µs %5.0f GB/s\n", M, N, t, 4M * N / t / 1e3)
end

sum(x; dims=2), Float32, µs (GB/s read):

M × N GPUArrays 11.5.16 GPUArrays 12.1.1
512 × 16384 92.2 (364) 26.6 (1262)
1024 × 8192 90.1 (372) 26.6 (1262)
2048 × 4096 86.0 (390) 26.6 (1260)
3072 × 2730 94.2 (356) 147.5 (227)
4096 × 1024 51.2 (328) 63.5 (264)
4096 × 2048 90.1 (372) 116.7 (288)
4096 × 4096 163.8 (410) 67.6 (993)
6144 × 1365 100.4 (334) 83.9 (400)
8192 × 1024 96.2 (349) 67.6 (497)
16384 × 512 104.4 (321) 43.0 (781)
32768 × 256 98.3 (341) 32.8 (1024)

The slow shapes sit between fast ones: 4096 × 2048 takes longer than 4096 × 4096, which reads twice as much. So it looks like the launch shape chosen for these sizes rather than a bandwidth limit. BFloat16 input and maximum behave the same (4096 × 2048: 112.6 and 114.7 µs).

Follow-up to JuliaGPU/CUDA.jl#3446, whose shapes are on the fast side. AcceleratedKernels 0.5.8, GPUArrays 12.1.1, CUDA.jl main (a9e28c0), against CUDA.jl 6.4.2 with GPUArrays 11.5.16; Julia 1.13.2, RTX 5090.

Activity

  1. christiangnrd commented on Oct 23, 2026

    @christiangnrd
    Member

    This might be a tuning thing since I'm not seeing this on my 3060:

    M × N GPUArrays 11.5.16 GPUArrays 12.1.1
    512 × 16384 286.5 (117) 109.6 (306)
    1024 × 8192 344.1 (98) 110.6 (303)
    2048 × 4096 379.9 (88) 112.6 (298)
    3072 × 2730 400.4 (84) 143.4 (234)
    4096 × 1024 263.2 (64) 63.5 (264)
    4096 × 2048 413.7 (81) 119.7 (280)
    4096 × 4096 736.3 (91) 220.2 (305)
    6144 × 1365 479.4 (70) 108.5 (309)
    8192 × 1024 524.3 (64) 106.5 (315)
    16384 × 512 699.4 (48) 105.5 (318)
    32768 × 256 113.7 (295) 105.5 (318)
  2. maleadt commented on Oct 25, 2026

    @maleadt
    Member

    Fixes by #176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions