From 5691127f46b6c2ad6c492ccc16206e2eef803e06 Mon Sep 17 00:00:00 2001 From: Julian P Samaroo Date: Tue, 1 Dec 2026 10:26:59 -0700 Subject: [PATCH] Select the scan test initializer from device Float64 support The oneAPI CI device rejects a Float64 initializer before the accumulation value assertion. Query the selected task device module capability flags; retain Float64 coverage on capable devices and the same assertion with Float32 elsewhere. Named-properties tests deliberately separate module and arithmetic flags. Native Arc controls pass 26 assertions, including the unchanged repository assertion. No backend skip or production change. Assisted-by: OpenAI Codex --- AGENTS.md | 11 +++++++++++ test/gpu.jl | 23 ++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index ad8c5740e..8721bcc06 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1217,3 +1217,14 @@ this section verbatim). Each entry is one bullet starting with `- `. the protocol alone is not enough for them. Test with a remote reader *and* a remote writer, in both orders: in one process every slot is the argument itself, so none of this is visible. + +109. **Choose GPU test scalar types from the selected device's capability.** + A backend can expose both Float64-capable and incapable devices. A + Float32 array with a `0.0` scan initializer widens to Float64, so a test + can fail before reaching its intended value assertion. Query the actual + device inside the task's GPU scope. Level Zero's module capability bits + belong to `module_properties(device).flags`; `fp64flags` instead holds + arithmetic properties, so applying a module mask there can pass by + coincidence. Test those fields with different values. Keep the Float64 case on capable hardware and run the same + behavioral assertion with a supported initializer elsewhere; a vendor-wide + skip loses coverage on devices that support it. diff --git a/test/gpu.jl b/test/gpu.jl index 94f81e1d8..508dd6407 100644 --- a/test/gpu.jl +++ b/test/gpu.jl @@ -94,6 +94,26 @@ end end end +@everywhere begin + gpu_accumulate_init(properties, mask) = (properties.flags & mask) == mask ? 0.0 : 0f0 + function gpu_accumulate_init(name::Symbol) + if name == :oneAPI + # This runs in the selected GPU scope, so query that task's device. + properties = oneAPI.oneL0.module_properties(oneAPI.device()) + return gpu_accumulate_init(properties, oneAPI.oneL0.ZE_DEVICE_MODULE_FLAG_FP64) + end + return 0.0 + end +end + +@testset "GPU accumulate init capability" begin + # Module support flags and floating-point arithmetic flags are distinct. + @test gpu_accumulate_init((flags=UInt32(0), fp64flags=UInt32(2)), UInt32(2)) === 0f0 + @test gpu_accumulate_init((flags=UInt32(1), fp64flags=UInt32(0x7f)), UInt32(2)) === 0f0 + @test gpu_accumulate_init((flags=UInt32(2), fp64flags=UInt32(0)), UInt32(2)) === 0.0 + @test gpu_accumulate_init((flags=UInt32(3), fp64flags=UInt32(0)), UInt32(2)) === 0.0 +end + @testset "DArray accumulate ($name)" for (name, scope) in GPU_SCOPES Dagger.with_options(; scope) do DA = rand(Blocks(4, 4), Float32, 16, 16) @@ -109,7 +129,8 @@ end @test collect(accumulate(+, DA; dims=2, init=1f0)) ≈ accumulate(+, A; dims=2, init=1f0) # Metal has no Float64 if name != :Metal - @test collect(accumulate(+, DA; dims=1, init=0.0)) ≈ accumulate(+, A; dims=1, init=0.0) + init = fetch(Dagger.@spawn gpu_accumulate_init(name)) + @test collect(accumulate(+, DA; dims=1, init)) ≈ accumulate(+, A; dims=1, init) end DV = rand(Blocks(4), Float32, 16) @test collect(cumsum(DV)) ≈ cumsum(collect(DV))