-
Notifications
You must be signed in to change notification settings - Fork 531
[PyTorch Debug] Custom feature tutorial. #2216
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Pawel Gadzinski <[email protected]>
Signed-off-by: Pawel Gadzinski <[email protected]>
Signed-off-by: Pawel Gadzinski <[email protected]>
Signed-off-by: Pawel Gadzinski <[email protected]>
Signed-off-by: Pawel Gadzinski <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: Pawel Gadzinski <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: Pawel Gadzinski <[email protected]>
|
It's better to debug this PR with docs generated, instead of looking into changes. |
Signed-off-by: Pawel Gadzinski <[email protected]>
Signed-off-by: Pawel Gadzinski <[email protected]>
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.
Pull Request Overview
This PR adds a tutorial for creating custom features in PyTorch debug tools, demonstrating how to implement and use a custom PercentageGreaterThanThreshold feature.
- Adds a custom feature implementation that calculates the percentage of tensor values exceeding a threshold
- Provides utility functions for plotting statistics from debug logs
- Includes YAML configuration example showing how to enable custom features alongside built-in ones
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/debug/custom_feature_dir/percentage_greater_than_threshold.py | Implements the custom PercentageGreaterThanThreshold feature class with tensor inspection methods |
| docs/debug/custom_feature_dir/utils.py | Provides plotting utilities to visualize statistics from debug logs |
| docs/debug/custom_feature_dir/custom_feature_example_config.yaml | Configuration file demonstrating how to enable both custom and built-in features |
| docs/debug.rst | Adds reference to the new custom feature tutorial notebook |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| rowwise_quantized_tensor: Optional[torch.Tensor | QuantizedTensor] = None, | ||
| columnwise_quantized_tensor: Optional[torch.Tensor | QuantizedTensor] = None, |
Copilot
AI
Oct 23, 2025
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.
The union type syntax torch.Tensor | QuantizedTensor uses Python 3.10+ syntax. Consider using Union[torch.Tensor, QuantizedTensor] from the typing module for better backward compatibility, especially since Optional from typing is already imported.
| custom_feature_values = [] | ||
|
|
||
| with open(stat_file, "r") as f: | ||
| import re |
Copilot
AI
Oct 23, 2025
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.
The import re statement should be moved to the top of the file with other imports (after line 9) following Python's PEP 8 style guidelines.
Description
This PR adds short custom feature tutorial to precision debug tools docs.
Type of change
Documentation change (change only to the documentation, either a fix or a new content)
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
Infra/Build change
Code refactoring
I have read and followed the contributing guidelines
The functionality is complete
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation
My changes generate no new warnings
I have added tests that prove my fix is effective or that my feature works
New and existing unit tests pass locally with my changes