I summed the same 10 million float32 numbers five times on my laptop, changing only torch.set_num_threads . I got five different answers:
1 thread: -177.465576171875 2 threads: -177.46554565429688 4 threads: -177.46632385253906 8 threads: -177.4659423828125 16 threads: -177.46597290039062
Enter fullscreen mode
Exit fullscreen mode
Then I ran a transformer layer plus a 32,000-way output head at the same five thread counts. All 32,000 logits came out bit-identical every time.
So the honest answer to "does the thread count change my output?" is: sometimes, and you can predict when. This post shows which operations changed, which didn't, and why the line falls where it does.
The setup
One script, blog_04_script.py (full code at the end).…