tinygrad/test/unit
qazal 2407fecdae
viz bytepack format (#11792)
* viz bytepack format

Training a 1B llama yields ~20M profiler events.

With JSON serialization, the browser tries to load 6GB to memory. This OOMs since each tab is limited to <3-4GB memory usage. Using a packed format, we only need ~600MB.

**Design decisions:**

- Timestamps are in microseconds relative to start time. They're stored in u32, which can express up to ~1 hr of trace events.
- Strings (kernel names, metadata, etc) are deduped.
- Buffer sizes are in u64 nbytes.

More optimization possible:

- The string lookup is a JSON dumped array, we can compress this.
- Can store less for memory by moving the layout to client.

**Results**

|  | Events | JSON | bytepack |
|----------------|---------|-------------|-------------|
| DP=8 llama 1B train (`command: [1]`) | 24M | 5.8GB | 640MB |
| examples/beautiful_mnist.py | 16K | 3.7MB | 745KB |
| examples/gpt2.py | 55K | 12.54MB | 1.40MB |

`[1]`: `VIZ=1 FAKEDATA=1 OFFLOAD_OPTIM=1 DP=8 BS=8 GRADIENT_ACC_STEPS=2 BLOCK_REORDER=0 LR=3e-4 TRAIN_ON_VAL=1 DEFAULT_FLOAT=bfloat16 OPTIM_DTYPE=bfloat16 LLAMA3_SIZE=1B WARMUP_STEPS=36 DECAY_STEPS=360 SEQLEN=8192 PYTHONPATH=. AMD=1 AMD_LLVM=0 MODEL=llama3 python3 examples/mlperf/model_train.py`

* python reference decoder

* 27 bytes / event, 1hr hard limit
2025-08-23 23:50:21 +03:00
..
__init__.py more test cleanups (#2631) 2023-12-05 16:17:57 -08:00
test_allreduce.py minimal mstack pr to fix allreduce (#10649) 2025-06-05 15:14:53 -07:00
test_attention.py move cast to before softmax in attention (#9213) 2025-02-24 17:24:59 -05:00
test_block_reorder.py Pass list to block_reorder in test_loads (#10881) 2025-06-19 09:49:45 -04:00
test_conv.py move high level stuff to unit tests [pr] (#10708) 2025-06-08 14:05:56 -07:00
test_device.py Fix device (#10929) 2025-06-23 15:30:19 -07:00
test_disk_cache.py helpers.diskcache_clear (#4436) 2024-05-05 14:19:01 -04:00
test_disk_tensor.py fix DiskDevice reuse (#11039) 2025-07-01 10:29:21 -04:00
test_dtype.py support bf16 and fp8 in Tensor.tolist (#11704) 2025-08-17 15:11:13 -04:00
test_dtype_spec.py move dtype spec tests into unit test (#10808) 2025-06-13 22:21:22 -04:00
test_elf.py CLANG -> CPU (#9189) 2025-02-20 18:03:09 -05:00
test_gguf.py add a missing unittest.main() [pr] (#8274) 2024-12-16 14:28:10 -05:00
test_gradient.py rename lazydata to uop (#10698) 2025-06-08 08:42:22 -07:00
test_graph_rewrite.py render ranges in viz, name gbufs with sizes. changes from rangeify (#11656) 2025-08-13 12:46:16 -07:00
test_hashing.py move device tests to test/device + test cleanups (#11735) 2025-08-19 16:02:20 -07:00
test_helpers.py fix word_wrap with newlines in input string [pr] (#11319) 2025-07-22 12:03:13 +03:00
test_indexing.py move high level stuff to unit tests [pr] (#10708) 2025-06-08 14:05:56 -07:00
test_kernelize.py move view left to the outer graph prereqs + testing (#10725) 2025-06-09 20:43:25 -07:00
test_linalg.py move device tests to test/device + test cleanups (#11735) 2025-08-19 16:02:20 -07:00
test_linearizer_rewrite.py move opt under codegen (#11569) 2025-08-07 14:19:17 -07:00
test_llm_tokenizer.py delete the arange dim mismatch restriction (#11568) 2025-08-07 13:46:17 -07:00
test_masked_st.py move high level tests to unit (#10760) 2025-06-10 12:55:44 -04:00
test_microbenchmarks.py move files into uop dir (#10399) 2025-05-18 11:38:28 -07:00
test_mnist_dataset.py move high level tests to unit (#10760) 2025-06-10 12:55:44 -04:00
test_pattern_matcher.py if upat returns self, it's none (#10898) 2025-06-20 12:11:19 -07:00
test_qcom.py BufferSpec and ProgramSpec [pr] (#7814) 2024-11-21 12:18:05 +08:00
test_rearrange_einops.py move high level tests to unit (#10760) 2025-06-10 12:55:44 -04:00
test_rewrite_map.py move symbolic and transcendental to uop [pr] (#10771) 2025-06-10 20:51:22 -07:00
test_rewrite_not_ready.py skip_0 in graph rewrite [pr] (#11627) 2025-08-11 18:29:04 -07:00
test_rewrite_tracked_childen.py small changes from rangeify (#11682) 2025-08-15 08:45:52 -07:00
test_search.py move opt under codegen (#11569) 2025-08-07 14:19:17 -07:00
test_shapetracker.py remove unused ShapeTracker.consecutive [pr] (#11426) 2025-07-29 18:36:19 -04:00
test_shapetracker_math.py [bounty] Stride is flip (#8792) 2025-01-31 11:34:10 +09:00
test_shm_tensor.py line reduction [pr] (#7296) 2024-10-25 17:05:09 +07:00
test_simple_schedule.py simple schedule test [pr] (#10853) 2025-06-17 16:19:27 -07:00
test_simplify_valid_idx.py add AxisType to range (#11798) 2025-08-23 11:15:00 -07:00
test_symbolic_failures.py [bounty] Z3 symbolic fuzzer [pr] (#10514) 2025-05-28 16:28:37 -04:00
test_symbolic_shapetracker.py move high level tests to unit (#10760) 2025-06-10 12:55:44 -04:00
test_tar.py accept filename decorator [pr] (#8049) 2024-12-05 11:40:59 +08:00
test_tensor_io.py tar_extract with Tensors (#7853) 2024-12-04 17:03:19 +08:00
test_tensor_uop_representation.py update test_tensor_uop_representation comments [pr] (#10946) 2025-06-24 10:47:09 +03:00
test_tqdm.py Change rate to int in test_tqdm (#10848) 2025-06-18 08:40:43 -04:00
test_transcendental_helpers.py TRANSCENDENTAL_SUPPORTED_DTYPES->TRANSCENDENTAL_DTYPES (#11752) 2025-08-20 10:29:36 -04:00
test_uop_resolve.py move files into uop dir (#10399) 2025-05-18 11:38:28 -07:00
test_uop_spec.py Revert "REDUCE_AXIS keepdim=False (#11311)" (#11718) 2025-08-18 13:28:53 -07:00
test_uop_symbolic.py adjust idiv min_max (#11802) 2025-08-23 22:25:51 +02:00
test_uop_vmin_vmax.py don't narrow range of CAST on bool/unsigned (#11156) 2025-07-09 22:20:09 -04:00
test_upat_compile.py move files into uop dir (#10399) 2025-05-18 11:38:28 -07:00
test_view.py Fix division by zero and mask bug in add views (#11088) 2025-07-07 10:05:47 -07:00
test_viz.py viz bytepack format (#11792) 2025-08-23 23:50:21 +03:00