-
Notifications
You must be signed in to change notification settings - Fork 543
[PyTorch Debug] NVFP4 debug stats support #2296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
pggPL
wants to merge
8
commits into
NVIDIA:main
Choose a base branch
from
pggPL:debug_nvfp4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b463cd7
init
pggPL 96622bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4b48026
fixes
pggPL 55ed4ee
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c5f1849
fix
pggPL 160b77b
fix
pggPL 9907081
fix
pggPL 23b2d1d
fix
pggPL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
transformer_engine/debug/features/disable_quantization_gemm.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Copyright (c) 2022-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # See LICENSE for license information. | ||
|
|
||
| """DisableQuantizationGEMM Feature support for nvidia-dlframework-inspect""" | ||
|
|
||
| from nvdlfw_inspect.registry import Registry, api_method | ||
| from transformer_engine.debug.features.api import TEConfigAPIMapper | ||
|
|
||
|
|
||
| @Registry.register_feature(namespace="transformer_engine") | ||
| class DisableQuantizationGEMM(TEConfigAPIMapper): | ||
| """ | ||
| Disables specific GEMM operations from using quantization, forcing high-precision execution. | ||
|
|
||
| Works with any quantization format (FP8, NVFP4, etc.). | ||
|
|
||
| Parameters | ||
| ---------- | ||
|
|
||
| gemms: List[str] | ||
| list of gemms to disable quantization for | ||
|
|
||
| - fprop | ||
| - dgrad | ||
| - wgrad | ||
|
|
||
| Example | ||
| ------- | ||
| .. code-block:: yaml | ||
|
|
||
| example_disable_quantization_gemm: | ||
| enabled: True | ||
| layers: | ||
| layer_types: [fc1] | ||
| transformer_engine: | ||
| DisableQuantizationGEMM: | ||
| enabled: True | ||
| gemms: [dgrad, wgrad] | ||
| """ | ||
|
|
||
| @api_method | ||
| def fp8_gemm_enabled( | ||
| self, config, layer_name: str, gemm: str, iteration: int | ||
| ): # pylint: disable=unused-argument | ||
| """API call responsible for choice between high-precision and quantized GEMM execution. | ||
|
|
||
| Note: Method name kept as 'fp8_gemm_enabled' for backward compatibility with the debug API, | ||
| but it applies to all quantization formats (FP8, NVFP4, etc.). | ||
| """ | ||
|
|
||
| for key in config: | ||
| if key != "gemm": | ||
| raise ValueError(f'[NVTORCH INSPECT ERROR] Unexpected key in config: "{key}".') | ||
|
|
||
| # If this feature is invoked, then quantized GEMM is disabled (returns to high precision). | ||
| # If not, then default behavior in TransformerEngineAPI | ||
| # is that fp8_gemm() API call returns True. | ||
| return False, iteration + 1 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be worth raising a deprecation warning in the constructor or something.
DisableFP8GEMMwould also benefit from this.