Thread count can change PyTorch results, but only for some operations
A developer summed 10 million float32 values on a laptop while varying only torch.set_num_threads, and got five slightly different totals. A transformer layer followed by a 32,000-way output head produced bit-identical logits at every thread count tested. Across 11 operations, the test found that matrix multiplies and softmax stayed bit-for-bit identical, while full reductions such as sums, dot products and means diverged. The divergence comes from floating-point addition not being associative, so splitting a reduction into different chunks per thread changes the rounding. Repeated runs at a fixed thread count gave identical bits, so the variation is a setting rather than randomness.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in