Skip to content

[PyTorch Debug] Support log fp8 tensor stats for blockwise recipe #1905

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lengerfulluse
Copy link

Support log fp8 tensor stats for fp8 blockwise recipe.

fp8_recipe: 'blockwise'

Description

When enable fp8 underflow logging for blockwise recipe, it report the following exception:

[rank2]:   File "/TransformerEngine/transformer_engine/pytorch/module/layernorm_linear.py", line 283, in forward
[rank2]:     weightmat = module.get_weight_workspace(
[rank2]:   File "/TransformerEngine/transformer_engine/pytorch/module/base.py", line 1263, in get_weight_workspace
[rank2]:     out = quantizer.quantize(tensor, dtype=workspace_dtype)
[rank2]:   File "/TransformerEngine/transformer_engine/debug/pytorch/debug_quantization.py", line 332, in quantize
[rank2]:     self._call_inspect_tensor_api(tensor, rowwise_gemm_tensor, columnwise_gemm_tensor)
[rank2]:   File "/TransformerEngine/transformer_engine/debug/pytorch/debug_quantization.py", line 247, in _call_inspect_tensor_api
[rank2]:     debug_api.transformer_engine.inspect_tensor_postquantize(**args)
[rank2]:   File "nvidia-dlfw-inspect/nvdlfw_inspect/base.py", line 257, in route_api
[rank2]:     ret = getattr(self.namespace_features[feat_name], api_name)(
[rank2]:   File "/usr/local/lib/python3.10/dist-packages/transformer_engine/debug/features/log_fp8_tensor_stats.py", line 113, in inspect_tensor_postquantize
[rank2]:     assert type(tensor) in [Float8Tensor, Float8TensorBase, MXFP8Tensor, MXFP8TensorBase], (
[rank2]: AssertionError: [NVTORCH INSPECT ERROR] Tensor weight must be a quantized tensor when using log_fp8_tensor_stats. Use log_tensor_stats for high precision tensors.

Please include a brief summary of the changes, relevant motivation and context.

Fixes # (issue)
Import the necessary Blockwise Tensor and Base.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • [x ] 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

Changes

Please list the changes introduced in this PR:

  • Change A
  • Change B

Checklist:

  • 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

lengerfulluse and others added 2 commits June 27, 2025 16:40
Support log fp8 tensor stats for fp8 blockwise recipe

Signed-off-by: Wei Heng <jj@hengwei.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant