You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 640e517
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+108Lines changed: 108 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,6 +198,114 @@ oxideon/
198
198
199
199
---
200
200
201
+
## Accuracy and Speed vs PyTorch
202
+
203
+
Measured against PyTorch 2.15 (CPU) on the same machine: float32 on the CPU (13th-gen Core i7, 10 cores, AVX2/FMA, a thermally limited laptop), Oxideon in its default `Balanced` precision mode. Every number below is reproducible with the commands at the end of this section.
204
+
205
+
### Numerical error
206
+
207
+
The error of each result is measured against a float64 reference on identical inputs, in units of 2^-24 (half an ulp at 1.0): relative to the true value for element-wise functions, and relative to the sum of the absolute terms for sums, matrix products and convolutions (so cancellation cannot hide an error). "x better" is PyTorch's error divided by Oxideon's, so above 1 Oxideon is more accurate.
208
+
209
+
**40 operations: Oxideon is more accurate in 21 (12 of them by 2x or more), equal within 5% in 19, and less accurate in 0.**
210
+
211
+
<details>
212
+
<summary>All 40 operations (worst and mean error)</summary>
213
+
214
+
| operation | worst: Oxideon | PyTorch | x better | mean: Oxideon | PyTorch | x better |
215
+
|---|---:|---:|---:|---:|---:|---:|
216
+
|`sum_1M`| 0.0001 | 0.0004 | tie | 0.0001 | 0.0004 | tie |
The `gelu` row is dominated by the relative error deep in the negative tail, where the result is about 1e-15; both libraries are far from the floor there.
258
+
259
+
</details>
260
+
261
+
Matrix products and convolutions trade accuracy for speed through one switch, `oxideon.set_precision_mode("fastest" | "balanced" | "highest")` (or `OXIDEON_PRECISION`): `Fastest` is PyTorch-class in accuracy and time, `Balanced` (default) is 1.5-2.4x more accurate, `Highest` 6-19x. Details: [docs/NUMERICAL_ACCURACY.md](docs/NUMERICAL_ACCURACY.md).
262
+
263
+
### Speed
264
+
265
+
Best of several runs, microseconds, each benchmark in its own process (so power throttling of a long run does not distort later rows). `ratio` is Oxideon's time divided by PyTorch's (below 1 is faster). The last columns repeat the numerical error of the same operation from the table above.
266
+
267
+
op oxideon us torch us ratio
268
+
add 1M 40.6 47.2 0.86
269
+
mul 1M 39.2 48.0 0.82
270
+
add broadcast row 1M 36.6 26.5 1.38
271
+
mul_scalar 1M 33.1 29.6 1.12
272
+
exp 1M 68.3 42.6 1.60
273
+
tanh 1M 182.6 247.1 0.74
274
+
gelu 1M 182.8 108.3 1.69
275
+
relu 1M 33.3 28.2 1.18
276
+
sum 1M 21.1 24.4 0.86
277
+
sum axis0 1M 38.1 37.9 1.01
278
+
sum axis1 1M 24.9 28.1 0.89
279
+
max axis1 1M 54.4 105.4 0.52
280
+
softmax 1M 120.2 129.1 0.93
281
+
transpose+contiguous 1M 484.9 764.5 0.63
282
+
add transposed 1M 258.2 344.9 0.75
283
+
matmul 512 390.8 392.0 1.00
284
+
matmul 1024 3312.6 3045.3 1.09
285
+
matmul 256x4096x256 955.6 803.5 1.19
286
+
conv2d 8x16x64x64 k3 685.5 521.9 1.31
287
+
max_pool2d 96.8 206.6 0.47
288
+
layer_norm 32x128x256 51.6 79.5 0.65
289
+
index_select 4096 rows 155.6 127.7 1.22
290
+
cat 2x1M 57.3 72.4 0.79
291
+
small add 64 (overhead) 0.6 1.2 0.50
292
+
small matmul 8x8 1.1 3.5 0.31
293
+
mlp train step b256 992.9 832.3 1.19
294
+
autograd elementwise chain 661.5 892.7 0.74
295
+
296
+
Operations whose result is a single correctly rounded IEEE operation (add, mul, relu, copies ...) are `exact` in both libraries. Run-to-run noise is about 10-15%.
0 commit comments