Download scripts/membw.py from timmyGPT/local-256k-reasoning: direct link, hf CLI and curl.
- Browser
- Download file 588 Bytes
-
https://huggingface.co/datasets/timmyGPT/local-256k-reasoning/resolve/main/scripts/membw.py
- Command line
-
hf download hf://datasets/timmyGPT/local-256k-reasoning/scripts/membw.py
-
curl -L -o membw.py https://huggingface.co/datasets/timmyGPT/local-256k-reasoning/resolve/main/scripts/membw.py
588 Bytes
| """Rough single-process RAM read bandwidth: multi-threaded numpy sum over a 8 GB array.""" | |
| import numpy as np, time, os | |
| from concurrent.futures import ThreadPoolExecutor | |
| n = 8 * 2**30 // 8 | |
| a = np.ones(n, dtype=np.float64) | |
| for threads in (1, 8, 16, 32): | |
| chunks = np.array_split(a, threads * 4) | |
| with ThreadPoolExecutor(threads) as ex: | |
| best = 0 | |
| for _ in range(3): | |
| t = time.perf_counter(); list(ex.map(np.sum, chunks)); dt = time.perf_counter() - t | |
| best = max(best, a.nbytes / dt / 1e9) | |
| print(f"threads={threads:2d} read_GBps={best:6.1f}") | |