Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
07a3268
NCU profiling wrapper generation and execution
Jan 7, 2026
3c4b124
Refactor profiling components and add kernel_perf_util
Jan 7, 2026
11f4e79
Refactor profiling components and add kernel_perf_util
Jan 7, 2026
251f419
Refactor profiling components and add kernel_perf_util
Jan 7, 2026
b789660
update directory name and add package in pyproject
Jan 7, 2026
4d35d57
Remove kernel_perf_util directory
Jan 7, 2026
d871678
move gpu spec.py to future PR and fix import
Jan 7, 2026
db0c754
Add copyright header
Jan 7, 2026
cd29759
fix ruff
Jan 7, 2026
bbfa6cd
address previous comments
Jan 13, 2026
543453a
fix ruff
Jan 13, 2026
706c9cc
Add unified benchmarking module for kernel performance measurement
Jan 8, 2026
4febdd6
Introducing benchmarking infra for kernel performance
Jan 8, 2026
d92a7b7
fix ruff
Jan 9, 2026
2994315
fix ruff
Jan 9, 2026
1378fc3
address comments
Jan 14, 2026
45fec80
Diagnose module - prompt constructor
Jan 11, 2026
b640cde
Refactors the diagnose_prompt module into a modular architecture
Jan 13, 2026
e952123
fix diff issue
Jan 13, 2026
e7ba29a
fix ruff issue
Jan 13, 2026
72ac4d1
fix
Jan 15, 2026
e2c599e
fix ruff
Jan 15, 2026
8ab907c
Merge branch 'main' into kaiming/opt_component_3
kaiming-cheng Jan 27, 2026
e350802
fix gpu_spec based on feedback and remove judger_prompt for future PR
Jan 29, 2026
8541299
Remove judger_prompts.py changes from this PR
Jan 29, 2026
313a84f
Merge branch 'main' into kaiming/opt_component_3
kaiming-cheng Jan 29, 2026
9e608ac
Update gpu_specs_database.py
kaiming-cheng Jan 29, 2026
f3220e1
address feedback
Jan 29, 2026
4443f33
ruff fix
Jan 29, 2026
b12b138
Merge branch 'main' into kaiming/opt_component_3
kaiming-cheng Jan 29, 2026
31d0d70
introduce roofline analyzer
Jan 29, 2026
3c607b5
update doc string in init and fix ncu_roofline
Jan 29, 2026
1aad0ad
introduce judger prompt
Jan 31, 2026
d75c96a
map fix to corrsponding cause instead of bottleneck
Feb 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion kernel_perf_agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@

"""Kernel Performance Agent package."""

# "Kernel Performance Agent package
__all__ = []
20 changes: 20 additions & 0 deletions kernel_perf_agent/kernel_opt/diagnose_prompt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Diagnose Prompt Module for Hardware Bottleneck Analysis.

"""

__all__: list[str] = []
95 changes: 95 additions & 0 deletions kernel_perf_agent/kernel_opt/diagnose_prompt/gpu_specs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
GPU Specifications Database for Bottleneck Analysis

This module provides GPU hardware specifications needed for performance analysis
and bottleneck identification. It includes peak compute performance, memory bandwidth,
cache sizes, and SM counts for common NVIDIA GPUs.

"""

import logging
from typing import Any

from kernel_perf_agent.kernel_opt.diagnose_prompt.gpu_specs_database import (
GPU_SPECS_DATABASE,
)

__all__ = ["GPU_SPECS_DATABASE", "get_gpu_specs"]

logger = logging.getLogger(__name__)


def get_gpu_specs(gpu_name: str) -> dict[str, Any] | None:
"""
Get GPU specifications for bottleneck analysis.

This function returns hardware specifications needed for performance analysis,
including peak compute performance, memory bandwidth, cache sizes, and SM counts.

Args:
gpu_name: GPU name. Must exactly match a key in GPU_SPECS_DATABASE.

Returns:
Dictionary with GPU specifications, or None if GPU is not in the database.
When successful, contains:
- name: GPU name
- architecture: GPU architecture (e.g., "Ampere", "Hopper")
- peak_fp32_tflops: Peak FP32 compute performance in TFLOPS
- peak_fp16_tflops: Peak FP16 compute performance in TFLOPS
- peak_bf16_tflops: Peak BF16 compute performance in TFLOPS (0 if not supported)
- peak_memory_bw_gbps: Peak memory bandwidth in GB/s
- sm_count: Number of streaming multiprocessors
- max_threads_per_sm: Maximum threads per SM
- l1_cache_kb: L1 cache size in KB per SM
- l2_cache_mb: Total L2 cache size in MB
- memory_gb: Total GPU memory in GB
- memory_type: Memory type (e.g., "HBM2e", "GDDR6X")

Examples:
>>> specs = get_gpu_specs("NVIDIA A100")
>>> if specs:
... print(f"SM Count: {specs['sm_count']}")
"""
if gpu_name in GPU_SPECS_DATABASE:
return GPU_SPECS_DATABASE[gpu_name].copy()

logger.warning(
"Unknown GPU: '%s'. Disable Optimization. Available GPUs: %s",
gpu_name,
", ".join(GPU_SPECS_DATABASE.keys()),
)
return None


if __name__ == "__main__":
print("GPU Specifications Module")
print("=" * 60)

# Show all available GPUs
print("Available GPU specifications in database:")
for gpu_name in sorted(GPU_SPECS_DATABASE.keys()):
print(f" - {gpu_name}")

# Example usage
print(f"\n{'=' * 60}")
example_gpu = "NVIDIA A100"
specs = get_gpu_specs(example_gpu)
Comment on lines +88 to +90
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring and __main__ example use "NVIDIA A100" as the GPU name, but GPU_SPECS_DATABASE only contains more specific keys like "NVIDIA A100 SXM4 40GB" and "NVIDIA A100 PCIe 80GB", so get_gpu_specs("NVIDIA A100") will always return None. Update the example (and/or relax the key-matching logic) so that the documented usage actually resolves to an entry in GPU_SPECS_DATABASE.

Copilot uses AI. Check for mistakes.
if specs:
print(f"\nExample specs for {example_gpu}:")
print(f" - Peak Memory Bandwidth: {specs['peak_memory_bw_gbps']} GB/s")
print(f" - Peak FP32 Performance: {specs['peak_fp32_tflops']} TFLOPS")
print(f" - SM Count: {specs['sm_count']}")
182 changes: 182 additions & 0 deletions kernel_perf_agent/kernel_opt/diagnose_prompt/gpu_specs_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
GPU Specifications Database - Updated with Specific SKUs

This module contains the GPU hardware specifications database used for
performance analysis and bottleneck identification. Updated to include
specific SKU variants for multi-SKU GPUs like A100 and H100.

Sources:
- NVIDIA official specifications and datasheets
- TechPowerUp GPU Database
- Manufacturer datasheets

Last Updated: January 2026
"""

GPU_SPECS_DATABASE: dict[str, dict[str, object]] = {
# NVIDIA A100 SKUs - SXM4 Variants
"NVIDIA A100 SXM4 40GB": {
"name": "NVIDIA A100 SXM4 40GB",
"architecture": "Ampere",
"peak_fp32_tflops": 19.5,
"peak_fp16_tflops": 312.0, # Without sparsity
"peak_bf16_tflops": 312.0, # Without sparsity
"peak_memory_bw_gbps": 1555,
"sm_count": 108,
"max_threads_per_sm": 2048,
"l1_cache_kb": 192,
"l2_cache_mb": 40,
"memory_gb": 40,
"memory_type": "HBM2e",
"form_factor": "SXM4",
"tdp_w": 400,
},
"NVIDIA A100 SXM4 80GB": {
"name": "NVIDIA A100 SXM4 80GB",
"architecture": "Ampere",
"peak_fp32_tflops": 19.5,
"peak_fp16_tflops": 312.0, # Without sparsity
"peak_bf16_tflops": 312.0, # Without sparsity
"peak_memory_bw_gbps": 2039,
"sm_count": 108,
"max_threads_per_sm": 2048,
"l1_cache_kb": 192,
"l2_cache_mb": 40,
"memory_gb": 80,
"memory_type": "HBM2e",
"form_factor": "SXM4",
"tdp_w": 400,
},
# NVIDIA A100 SKUs - PCIe Variants
"NVIDIA A100 PCIe 40GB": {
"name": "NVIDIA A100 PCIe 40GB",
"architecture": "Ampere",
"peak_fp32_tflops": 19.5,
"peak_fp16_tflops": 312.0, # Without sparsity
"peak_bf16_tflops": 312.0, # Without sparsity
"peak_memory_bw_gbps": 1555,
"sm_count": 108,
"max_threads_per_sm": 2048,
"l1_cache_kb": 192,
"l2_cache_mb": 40,
"memory_gb": 40,
"memory_type": "HBM2e",
"form_factor": "PCIe",
"tdp_w": 250,
},
"NVIDIA A100 PCIe 80GB": {
"name": "NVIDIA A100 PCIe 80GB",
"architecture": "Ampere",
"peak_fp32_tflops": 19.5,
"peak_fp16_tflops": 312.0, # Without sparsity
"peak_bf16_tflops": 312.0, # Without sparsity
"peak_memory_bw_gbps": 1935,
"sm_count": 108,
"max_threads_per_sm": 2048,
"l1_cache_kb": 192,
"l2_cache_mb": 40,
"memory_gb": 80,
"memory_type": "HBM2e",
"form_factor": "PCIe",
"tdp_w": 300,
},
# NVIDIA H100 SKUs - SXM5 Variant
"NVIDIA H100 SXM5 80GB": {
"name": "NVIDIA H100 SXM5 80GB",
"architecture": "Hopper",
"peak_fp32_tflops": 67.0,
"peak_fp16_tflops": 1979.0, # Without sparsity
"peak_bf16_tflops": 1979.0, # Without sparsity
"peak_memory_bw_gbps": 3350,
"sm_count": 132,
"max_threads_per_sm": 2048,
"l1_cache_kb": 256,
"l2_cache_mb": 50,
"memory_gb": 80,
"memory_type": "HBM3",
"form_factor": "SXM5",
"tdp_w": 700,
},
# NVIDIA H100 SKUs - PCIe Variant
"NVIDIA H100 PCIe 80GB": {
"name": "NVIDIA H100 PCIe 80GB",
"architecture": "Hopper",
"peak_fp32_tflops": 51.0,
"peak_fp16_tflops": 1513.0, # Without sparsity
"peak_bf16_tflops": 1513.0, # Without sparsity
"peak_memory_bw_gbps": 2000,
"sm_count": 114,
"max_threads_per_sm": 2048,
"l1_cache_kb": 256,
"l2_cache_mb": 50,
"memory_gb": 80,
"memory_type": "HBM2e",
"form_factor": "PCIe",
"tdp_w": 350,
},
# NVIDIA H100 SKUs - NVL Variant (for LLM inference)
"NVIDIA H100 NVL 94GB": {
"name": "NVIDIA H100 NVL 94GB",
"architecture": "Hopper",
"peak_fp32_tflops": 60.0,
"peak_fp16_tflops": 1671.0, # Without sparsity
"peak_bf16_tflops": 1671.0, # Without sparsity
"peak_memory_bw_gbps": 3900,
"sm_count": 132,
"max_threads_per_sm": 2048,
"l1_cache_kb": 256,
"l2_cache_mb": 50,
"memory_gb": 94,
"memory_type": "HBM3",
"form_factor": "PCIe",
"tdp_w": 400,
},
# NVIDIA RTX 4090
"NVIDIA RTX 4090": {
"name": "NVIDIA RTX 4090",
"architecture": "Ada Lovelace",
"peak_fp32_tflops": 82.58,
"peak_fp16_tflops": 82.58,
"peak_bf16_tflops": 82.58,
"peak_memory_bw_gbps": 1008,
"sm_count": 128,
"max_threads_per_sm": 1536,
"l1_cache_kb": 128,
"l2_cache_mb": 72,
"memory_gb": 24,
"memory_type": "GDDR6X",
"form_factor": "PCIe",
"tdp_w": 450,
},
# NVIDIA RTX 5080
"NVIDIA RTX 5080": {
"name": "NVIDIA RTX 5080",
"architecture": "Blackwell",
"peak_fp32_tflops": 56.28,
"peak_fp16_tflops": 56.28,
"peak_bf16_tflops": 56.28,
"peak_memory_bw_gbps": 960,
"sm_count": 84,
"max_threads_per_sm": 1536,
"l1_cache_kb": 128,
"l2_cache_mb": 64,
"memory_gb": 16,
"memory_type": "GDDR7",
"form_factor": "PCIe",
"tdp_w": 360,
},
}
Loading
Loading