﻿# Parallel GPU reductions: the tree changes floating-point order

Parallel GPU reduction trees change addition order; evaluate numerical error and repeatability separately from whether every input was included exactly once.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/learn-parallel-reduction-tree/
Language: en

A parallel reduction combines values through a tree rather than necessarily following the source array from beginning to end. Floating-point addition is sensitive to grouping, so changing the tree can change the result. The reduction algorithm therefore has both an execution structure and a numerical interpretation.

## The tree defines parenthesization

A sum can be formed by combining neighbors, accumulating local groups and then merging partial results. Each choice creates different intermediate magnitudes and rounding points. Real-number associativity does not guarantee identical floating-point output for those arrangements. The implementation must still include the intended inputs with the correct operation. Separating structural correctness from numerical variation prevents a valid rounding difference from hiding a missing-element or duplicate-element bug.

Primary reference: [Floating Point and IEEE 754 Compliance for NVIDIA GPUs](https://docs.nvidia.com/cuda/floating-point/).

## Mixed magnitudes expose grouping

Imagine positive and negative large values surrounding small contributions. Combining the large values first can preserve a different residual from absorbing the small contributions into large partial sums. The input order and grouping both matter. A uniform array is useful for checking counts but weak for exploring this mechanism. Include cancellation cases and compare against a reference whose precision and summation procedure are actually stated.

Primary reference: [CUDA Programming Guide: Writing SIMT Kernels](https://docs.nvidia.com/cuda/cuda-programming-guide/02-basics/writing-cuda-kernels.html).

## Scheduling can make order variable

Some implementations combine partial results in an order affected by execution progress, for example through contended atomic updates. Others deliberately use a fixed reduction structure. The API or library documentation should establish the supported reproducibility property. Do not infer that property solely from several matching runs. Repeated agreement under one launch is useful evidence about that experiment, but it does not define behavior across changed concurrency, shapes or devices.

Primary reference: [CUDA C++ Best Practices Guide](https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/).

## Stability can cost additional work

Wider accumulators, compensation techniques or deterministic grouping can change storage, arithmetic and synchronization costs. A numerical improvement is therefore an implementation tradeoff rather than a free label. Assess the error behavior needed by the consumer and keep the accepted tolerance explicit. If a downstream threshold is sensitive to tiny variations, test that boundary directly instead of assuming that a small aggregate matrix error makes every decision stable.

## Record the reduction identity

A reproducible record includes input ordering, format, algorithm, launch or library configuration and the comparison reference. Check counts and edge handling before interpreting numerical differences. Then compare error distributions and repeated outcomes under the intended operating conditions. The useful conclusion identifies a reduction path suitable for the application. It does not promise that all mathematically equivalent trees produce identical bits or that deterministic execution necessarily minimizes numerical error.

Related reading: [A GPU inference benchmark you can trust](/journal/inference-benchmark-method/); [Reproducible inference stacks: preserving a GPU pilot’s result](/journal/software-stack-reproducibility/).
