Skip to content

Commit 0c437c4

Browse files
committed
Reduce accuracy for CI builds
1 parent 07ec860 commit 0c437c4

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

docs/source/04-benchmark.ipynb

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 2,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -37,24 +37,17 @@
3737
},
3838
{
3939
"cell_type": "code",
40-
"execution_count": 2,
40+
"execution_count": 5,
4141
"metadata": {},
4242
"outputs": [
43-
{
44-
"name": "stderr",
45-
"output_type": "stream",
46-
"text": [
47-
"An NVIDIA GPU may be present on this machine, but a CUDA-enabled jaxlib is not installed. Falling back to cpu.\n"
48-
]
49-
},
5043
{
5144
"name": "stdout",
5245
"output_type": "stream",
5346
"text": [
54-
"GFloat scalar : 6666.04 nsec (50 runs at size 10000)\n",
55-
"GFloat vectorized, numpy arrays: 57.84 nsec (50 runs at size 1000000)\n",
56-
"GFloat vectorized, JAX JIT : 3.17 nsec (1000 runs at size 1000000)\n",
57-
"ML_dtypes : 2.92 nsec (1000 runs at size 1000000)\n"
47+
"GFloat scalar : 7518.31 nsec (5 runs at size 10000)\n",
48+
"GFloat vectorized, numpy arrays: 57.95 nsec (5 runs at size 1000000)\n",
49+
"GFloat vectorized, JAX JIT : 4.03 nsec (100 runs at size 1000000)\n",
50+
"ML_dtypes : 3.34 nsec (100 runs at size 1000000)\n"
5851
]
5952
}
6053
],
@@ -71,10 +64,15 @@
7164
" return np.array([gfloat.round_float(fi, x) for x in a])\n",
7265
"\n",
7366
"\n",
67+
"# About how many seconds to run for (autorange will take at least .2 sec)\n",
68+
"ACCURACY = 0.2\n",
69+
"\n",
70+
"\n",
7471
"def time(f, problem_size=1.0):\n",
7572
" units = 1e9 # nsec\n",
7673
" t = Timer(f)\n",
77-
" n = t.autorange()[0] * 10 # About 2 sec per run\n",
74+
" f() # pre-run\n",
75+
" n = int(t.autorange()[0] * ACCURACY / 0.2)\n",
7876
" ts = t.repeat(repeat=3, number=n) # best of 3\n",
7977
" ts = [((t / n) / problem_size) * units for t in ts] # per run\n",
8078
" return f\"{min(ts):8.2f} nsec ({n} runs at size {problem_size})\"\n",

0 commit comments

Comments
 (0)