Repository navigation
Conversation
…ng their elements without UIntPtr offsets. Co-Authored-By: Claude <noreply@anthropic.com>
…ic additions through 32-bit compare-and-swap loops, and let the Float32 and Float64 vector types accumulate Float16 vectors. Co-Authored-By: Claude <noreply@anthropic.com>
…edicates, decrements, random vectors, views of Float16 vectors, uniform Float16 vector parameters and single vector views. Co-Authored-By: Claude <noreply@anthropic.com>
m4rs-mt
force-pushed
the
half_accumulation_types
branch
from
October 30, 2026 12:46
607d01f to
d3e8d8c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #1696. The Float16 vector types gain the accumulation API of the Float32 vector types, Float32 and Float64
vectors accumulate Float16 vectors, and the atomic additions of all vector types compile in kernels.
A note on authorship
This PR was done with AI-assistant pair programming (Claude via Claude Code). The commits carry a
Co-Authored-By: Claudetrailer.What's in this PR
1. Atomic additions of all vector types in kernels (
Src/ILGPU/Vectors/VectorTypes.tt)AtomicAddmembers address their elements withUnsafe.Addinstead ofUIntPtrbyte offsets, soFloat32xN.AtomicAdd,Int32xN.AtomicAddand the other accumulation types compile in kernels.2. Accumulation members for Float16x2, Float16x4 and Float16x8 (
Src/ILGPU/Vectors/VectorTypes.tt)Float16xNimplementsIAccumulationVectorTypeforFloat16xN,UInt8xNandInt8xN:AtomicAdd,ComputeAverage(long, Half, byte, sbyte), and mixed+/-with the byte vectors.Float32xNandFloat64xNaccumulateFloat16xNvalues (+,-,AtomicAdd,ComputeAverage(Half)), so longsums of half values can be kept in single or double precision; the Float16 types document this.
AtomicAddon Float16 vectors updates each pair of elements with one 32-bit compare-and-swap loop throughAtomic.MakeAtomic, which every accelerator supports, and compares bits so NaN values end the loop.3. Tests (
Src/ILGPUC.Tests/)HalfPrecisionExecutionTests.HalfVectorAccumulation_ProducesCorrectOutput(TestPrograms/HalfPrecision/HalfVectorAccumulation.cs):atomic additions from 256 threads to Float16x8/x4/x2, Int8x4, UInt8x2 and Float32x4 views, mixed operators,
averages and the generic accumulation interface, compared with .NET.
HalfPrecisionExecutionTests.HalfVectorViews_ProducesCorrectOutput(TestPrograms/HalfPrecision/HalfVectorViews.cs):Float16x8 arithmetic, decrement, magnitude functions, classification predicates and random vectors; Float16 vectors
in views, as uniform kernel parameters and through
VectorView<Half>single vector views, compared with .NET.Depends on
#1696 (based on its head; the base is retargeted once it merges).
Testing
nvcc, NVIDIA GB10TreatWarningsAsErrors🤖 Generated with Claude Code