[PR #406] Add SM120 heuristic calibration harness #423

Open
opened 2026-10-26 21:17:37 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/deepseek-ai/DeepGEMM/pull/406
Author: @bvolpato
Created: 8/13/2026
Status: 🔄 Open

Base: nv_dev ← Head: bvolpato/calibrate-sm120-heuristics


📝 Commits (1)

  • 4c0aac2 Add SM120 heuristic calibration harness

📊 Changes

7 files changed (+873 additions, -10 deletions)

View changed files

📝 README.md (+5 -1)
📝 csrc/jit_kernels/heuristics/common.hpp (+43 -4)
📝 csrc/jit_kernels/heuristics/sm120.hpp (+3 -1)
📝 csrc/jit_kernels/heuristics/sm120_config.hpp (+8 -4)
➕ docs/sm120-heuristic-calibration.md (+79 -0)
➕ scripts/calibrate_sm120_heuristic.py (+583 -0)
➕ tests/test_sm120_calibration.py (+152 -0)

📄 Description

Summary

Adds an SM120 GEMM heuristic calibration script on nv_dev, addressing #385. It checks and benchmarks valid FP8/BF16 layouts, fits coefficients, and compares layout selection on held-out shapes. The calibration guide documents the existing coefficients' origin, usage, and interpretation.

Default coefficients stay unchanged. Measurements from one shared GPU do not justify tuning for the whole SM120 family.

Changes

  • Add a development-only DG_JIT_FORCE_LAYOUT=BMxBNxBK override with valid-candidate and ambiguity checks. It has no DJ_JIT_FORCE_LAYOUT fallback.
  • Isolate candidates in separate processes, randomize their order, and support steady or cold cache measurements. Correctness checks and diagnostic logging run before timing.
  • Record samples and GPU/build metadata, with fit conditioning, timing variation, and held-out selection regret.

Usage

After installing NumPy in the development environment:

./develop.sh
python scripts/calibrate_sm120_heuristic.py --dtype fp8 --output sm120-fp8.jsonl

Testing

The build, calibration checks, and FP8/BF16 runs passed on an RTX 5070 Ti with CUDA 13.2 and PyTorch 2.13.0+cu130:

PYTHONPATH=. python -m pytest -q tests/test_sm120_calibration.py

Python compilation and git diff --check passed. Builds used locally supplied elfutils development headers. SM90, SM100, and SM121 hardware were not tested.

Did this cause any problems?

Automatic selection is unchanged when DG_JIT_FORCE_LAYOUT is unset. The override affects GEMMs in its process, so the harness isolates each candidate in a subprocess.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/deepseek-ai/DeepGEMM/pull/406 **Author:** [@bvolpato](https://github.com/bvolpato) **Created:** 8/13/2026 **Status:** 🔄 Open **Base:** `nv_dev` ← **Head:** `bvolpato/calibrate-sm120-heuristics` --- ### 📝 Commits (1) - [`4c0aac2`](https://github.com/deepseek-ai/DeepGEMM/commit/4c0aac24b7fc860f1f6c9bf1428249ee94e12718) Add SM120 heuristic calibration harness ### 📊 Changes **7 files changed** (+873 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+5 -1) 📝 `csrc/jit_kernels/heuristics/common.hpp` (+43 -4) 📝 `csrc/jit_kernels/heuristics/sm120.hpp` (+3 -1) 📝 `csrc/jit_kernels/heuristics/sm120_config.hpp` (+8 -4) ➕ `docs/sm120-heuristic-calibration.md` (+79 -0) ➕ `scripts/calibrate_sm120_heuristic.py` (+583 -0) ➕ `tests/test_sm120_calibration.py` (+152 -0) </details> ### 📄 Description ## Summary Adds an SM120 GEMM heuristic calibration script on `nv_dev`, addressing #385. It checks and benchmarks valid FP8/BF16 layouts, fits coefficients, and compares layout selection on held-out shapes. The [calibration guide](https://github.com/bvolpato/DeepGEMM/blob/bvolpato/calibrate-sm120-heuristics/docs/sm120-heuristic-calibration.md) documents the existing coefficients' [origin](https://github.com/deepseek-ai/DeepGEMM/commit/1383f15d524d929059f7f4b11489e08d6b793ef2), usage, and interpretation. Default coefficients stay unchanged. Measurements from one shared GPU do not justify tuning for the whole SM120 family. ## Changes - Add a development-only `DG_JIT_FORCE_LAYOUT=BMxBNxBK` override with valid-candidate and ambiguity checks. It has no `DJ_JIT_FORCE_LAYOUT` fallback. - Isolate candidates in separate processes, randomize their order, and support steady or cold cache measurements. Correctness checks and diagnostic logging run before timing. - Record samples and GPU/build metadata, with fit conditioning, timing variation, and held-out selection regret. ## Usage After installing NumPy in the development environment: ```bash ./develop.sh python scripts/calibrate_sm120_heuristic.py --dtype fp8 --output sm120-fp8.jsonl ``` ## Testing The build, calibration checks, and FP8/BF16 runs passed on an RTX 5070 Ti with CUDA 13.2 and PyTorch 2.13.0+cu130: ```bash PYTHONPATH=. python -m pytest -q tests/test_sm120_calibration.py ``` Python compilation and `git diff --check` passed. Builds used locally supplied elfutils development headers. SM90, SM100, and SM121 hardware were not tested. ## Did this cause any problems? Automatic selection is unchanged when `DG_JIT_FORCE_LAYOUT` is unset. The override affects GEMMs in its process, so the harness isolates each candidate in a subprocess. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepGEMM#423
No description provided.