[PR #273] [CLOSED] Add DG_MINIMIZE_NUM_SMS env var to control SM minimization #335

Closed
opened 2026-10-26 21:16:24 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/deepseek-ai/DeepGEMM/pull/273
Author: @yurekami
Created: 1/1/2026
Status: ❌ Closed

Base: main ← Head: feature/env-minimize-sms


📝 Commits (1)

  • b4e2500 Add DG_MINIMIZE_NUM_SMS env var to control SM minimization

📊 Changes

2 files changed (+6 additions, -2 deletions)

View changed files

📝 csrc/jit_kernels/heuristics/sm100.hpp (+3 -1)
📝 csrc/jit_kernels/heuristics/sm90.hpp (+3 -1)

📄 Description

Summary

This PR adds an environment variable DG_MINIMIZE_NUM_SMS to control whether DeepGEMM should minimize the number of SMs used for kernel execution, addressing #239.

Background

The current SM minimization logic in get_best_config() recomputes the minimal number of SMs required:

if (ArchSpec::should_minimize_num_sms()) {
    num_min_sms = ceil_div(ceil_div(m, best_block_m) * ceil_div(n, best_block_n) * num_groups, best_num_waves);
    num_min_sms = align(num_min_sms, best_multicast_config.num_multicast);
}

This can invoke kernel compilation multiple times with different configurations, causing unstable time-to-first-token (TTFT) during inference.

Changes

  • Modified SM90ArchSpec::should_minimize_num_sms() to check env var
  • Modified SM100ArchSpec::should_minimize_num_sms() to check env var

Usage

# Enable SM minimization (default, current behavior)
export DG_MINIMIZE_NUM_SMS=1

# Disable SM minimization for stable TTFT
export DG_MINIMIZE_NUM_SMS=0

Benefits

  • DG_MINIMIZE_NUM_SMS=1 (default): Better L2 cache usage, reduced GPU frequency drops
  • DG_MINIMIZE_NUM_SMS=0: More predictable compilation, stable TTFT

Test Plan

  • Verify default behavior is unchanged (SM minimization enabled)
  • Verify DG_MINIMIZE_NUM_SMS=0 disables SM minimization
  • Compare TTFT stability with env var disabled

Fixes #239

🤖 Generated with Claude Code


🔄 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/273 **Author:** [@yurekami](https://github.com/yurekami) **Created:** 1/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/env-minimize-sms` --- ### 📝 Commits (1) - [`b4e2500`](https://github.com/deepseek-ai/DeepGEMM/commit/b4e250067b12972c3dfb2b2e330affa7d5a23c70) Add DG_MINIMIZE_NUM_SMS env var to control SM minimization ### 📊 Changes **2 files changed** (+6 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `csrc/jit_kernels/heuristics/sm100.hpp` (+3 -1) 📝 `csrc/jit_kernels/heuristics/sm90.hpp` (+3 -1) </details> ### 📄 Description ## Summary This PR adds an environment variable `DG_MINIMIZE_NUM_SMS` to control whether DeepGEMM should minimize the number of SMs used for kernel execution, addressing #239. ## Background The current SM minimization logic in `get_best_config()` recomputes the minimal number of SMs required: ```cpp if (ArchSpec::should_minimize_num_sms()) { num_min_sms = ceil_div(ceil_div(m, best_block_m) * ceil_div(n, best_block_n) * num_groups, best_num_waves); num_min_sms = align(num_min_sms, best_multicast_config.num_multicast); } ``` This can invoke kernel compilation multiple times with different configurations, causing unstable time-to-first-token (TTFT) during inference. ## Changes - Modified `SM90ArchSpec::should_minimize_num_sms()` to check env var - Modified `SM100ArchSpec::should_minimize_num_sms()` to check env var ## Usage ```bash # Enable SM minimization (default, current behavior) export DG_MINIMIZE_NUM_SMS=1 # Disable SM minimization for stable TTFT export DG_MINIMIZE_NUM_SMS=0 ``` ## Benefits - **DG_MINIMIZE_NUM_SMS=1** (default): Better L2 cache usage, reduced GPU frequency drops - **DG_MINIMIZE_NUM_SMS=0**: More predictable compilation, stable TTFT ## Test Plan - [ ] Verify default behavior is unchanged (SM minimization enabled) - [ ] Verify `DG_MINIMIZE_NUM_SMS=0` disables SM minimization - [ ] Compare TTFT stability with env var disabled Fixes #239 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 21:16:24 +00:00
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#335
No description provided.