Skip to content

fix(mlsysim): give the T4 its FP32 and INT4 rates - #2192

Merged
profvjreddi merged 2 commits into
harvard-edge:devfrom
Shakhtar-Sankur:mlsysim-t4-fp32
Nov 12, 2026
Merged

profvjreddi merged 2 commits into
harvard-edge:devfrom
Shakhtar-Sankur:mlsysim-t4-fp32

Conversation

@Shakhtar-Sankur

Copy link
Copy Markdown
Contributor

Summary

The T4 entry stored only an INT8 rate, so Engine.solve(..., precision="fp32") fell through to peak_flops, the 65 TFLOP/s FP16 tensor-core rate. FP32 work on the T4, the GPU students get on Colab and Kaggle, was modelled about 8x too fast. This adds the datasheet FP32 (8.1 TFLOP/s) and INT4 (260 TOPS) rates and two regression tests.

Area

  • Book (textbook content, figures, exercises)
  • TinyTorch (modules, tests, milestones)
  • StaffML (interview questions, challenges)
  • Kits (hardware labs)
  • Infrastructure (CI/CD, scripts, config): MLSys·im hardware registry

Changes

  • mlsysim/hardware/data/cloud/T4.yaml: add fp32: 8.1 TFLOPs / s and int4: 260 TOPS from the NVIDIA T4 datasheet, with a comment on why both keys are needed. peak_flops (FP16 tensor, 65) and int8 (130) are unchanged, so FP16 and INT8 results, the accelerator table in the Vol 1 appendix and the hardware chapter's T4 ridge point stay the same.
  • tests/test_hardware.py: test_precision_keys_use_canonical_vocabulary catches an aliased key such as fp32_cuda, but not a chip with no fp32 key at all, which is how the T4 slipped through. Two new tests: the T4 resolves fp32 and int4 to the datasheet rates, and a compute-bound FP32 Engine.solve (ResNet-50, batch 256) is limited by the FP32 rate without the "not in precision_flops" fallback warning.

Measured on a Tesla T4 (public Kaggle run: https://www.kaggle.com/code/sankurkundu/notebook9652c65b82), PyTorch matmul, TF32 off, best of n = 4096 and 8192:

FP32 FP16
Measured on the T4 4.24 TFLOP/s 27.48 TFLOP/s
MLSys·im rate before 65 (falls through to the FP16 peak: 15.3x measured) 65
MLSys·im rate after 8.1 (datasheet peak: 1.9x measured) 65

Engine.solve(ResNet50, T4, batch_size=256), same run:

precision before after
fp32 65.12 ms, with the "not in precision_flops" warning 518.85 ms, no warning
fp16 65.12 ms 65.12 ms
int8 32.83 ms 32.83 ms
int4 65.12 ms, with the warning 16.68 ms, no warning

Before the fix, FP32 and FP16 got the same latency; after it, FP32 is 7.97x slower, as the datasheet rates imply. FP16 and INT8 are unchanged.

Sixteen other accelerators also have no fp32 key (the TPUs, Gaudi 2 and 3, MI325X, Trainium2, Cerebras CS-3, Groq, Graphcore, DMatrix, Untether, GB200 NVL72). Some may not run FP32 matmul at all, so I left them out of this PR; happy to add the ones with a published FP32 rate if you want them.

Testing

  • Ran tests (pytest tests/): tests/test_hardware.py, 19 passed on the Kaggle T4 run; full MLSys·im suite on this branch and on its parent on dev (https://www.kaggle.com/code/sankurkundu/notebook6040d01dac): the same 7 tests fail on both, none new: four in test_paper_integrity.py, two in test_downstream_impact.py and one in test_v1_08_experiments.py, all failing the same way on dev in that environment (marimo is not installed there)
  • Manual verification: FP32 and FP16 matmul measured on a Tesla T4 against the old and new modelled rates (table above)

Related Issues

None; found while checking MLSys·im's T4 numbers against measurements on a T4.


By submitting this PR, you agree to release your contribution under the project's license.

The T4 entry stored only an int8 rate, so Engine.solve with precision='fp32' fell through to peak_flops, the 65 TFLOP/s FP16 tensor-core rate, and warned "Results may be inaccurate". FP32 work on the T4 was modelled about 8x too fast, and INT4 4x too slow.

Add the datasheet rates: FP32 8.1 TFLOP/s on the CUDA cores and INT4 260 TOPS. peak_flops (FP16 tensor, 65) and int8 (130) are unchanged, so FP16 and INT8 results, the appendix table and the hardware chapter's ridge point stay the same.

test_precision_keys_use_canonical_vocabulary catches an aliased key such as 'fp32_cuda', but not a chip with no fp32 key at all, which is how the T4 slipped through. Add a T4 regression test and an Engine check that a compute-bound FP32 solve is limited by the FP32 rate without the fallback warning.
@github-actions github-actions Bot added area: mlsysim Path mlsysim/ — auto-label type: bug bug in rendering labels Nov 11, 2026
labs/tools/check_browser_wheels.py requires the committed mlsysim wheel to match the runtime source. Replace mlsysim/hardware/data/cloud/T4.yaml inside mlsysim-0.3.1-py3-none-any.whl with the updated file and its RECORD entry; every other entry is unchanged, and all 508 runtime files now match the source.
@Shakhtar-Sankur

Copy link
Copy Markdown
Contributor Author

A note on the remaining red checks:

Labs · Validate Notebooks is green now. test_browser_wheels_match_release_runtime_source needs the committed browser wheel to match the source, so the second commit replaces mlsysim/hardware/data/cloud/T4.yaml (and its RECORD line) inside labs/wheels/mlsysim-0.3.1-py3-none-any.whl. Every other file in the wheel is unchanged, and labs/tools/check_browser_wheels.py passes.

MLSys·im · Run Tests: in a replica of this job on Kaggle (same Python, same pip install ".[dev,viz,labs]", same steps), lint, calibration, modeling docs and the full test suite pass on both dev and this branch (https://www.kaggle.com/code/sankurkundu/notebookd36adca4d0). The only difference is the paper's timing receipt:

generate_paper_values --check: 2 difference(s):
  - timing receipt source_sha256 stale: mlsysim/hardware/data/cloud/T4.yaml
  - timing receipt source_sha256 stale: tests/test_hardware.py

No paper value changes (the hardware table uses the FP16 peak, still 65). Since make values re-times the sweep and records the machine it runs on, I've left the receipt for you to regenerate rather than writing machine values from a Kaggle box into the paper.

Labs · Build Labs Site is not from this PR, which touches no styles: quarto render stops at 404.qmd with Undefined variable for $accent-dark at shared/styles/partials/_mobile.scss:353, added in c9b22d1. The Labs stylesheet (labs/assets/styles/style.scss) defines $accent but not $accent-dark, and the Labs workflow hasn't run on dev since that commit because its path filter doesn't include shared/. Defining it next to $accent, e.g. $accent-dark: #3b82f6; as in shared/styles/themes/_theme-labs.scss, should fix it; happy to open a separate PR for that if it helps.

@profvjreddi
profvjreddi merged commit 927971e into harvard-edge:dev Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks @Shakhtar-Sankur! 🎉

I added @Shakhtar-Sankur to labs, mlsysim for: bug, code, test, doc.

The contributor tables are now handled directly by this workflow; no follow-up command is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mlsysim Path mlsysim/ — auto-label type: bug bug in rendering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants