Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
TransformerEngine
Commits
b8412430
Unverified
Commit
b8412430
authored
Feb 09, 2026
by
Paweł Gadziński
Committed by
GitHub
Feb 09, 2026
Browse files
[PyTorch Debug] Skip logging stats if unsupported (#2652)
fix Signed-off-by:
Pawel Gadzinski
<
pgadzinski@nvidia.com
>
parent
c1a0c974
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
18 deletions
+42
-18
transformer_engine/debug/features/log_fp8_tensor_stats.py
transformer_engine/debug/features/log_fp8_tensor_stats.py
+18
-6
transformer_engine/debug/features/log_nvfp4_tensor_stats.py
transformer_engine/debug/features/log_nvfp4_tensor_stats.py
+24
-12
No files found.
transformer_engine/debug/features/log_fp8_tensor_stats.py
View file @
b8412430
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
from
typing
import
Dict
,
Optional
,
List
,
Tuple
from
typing
import
Dict
,
Optional
,
List
,
Tuple
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
import
warnings
import
torch
import
torch
import
nvdlfw_inspect.api
as
debug_api
import
nvdlfw_inspect.api
as
debug_api
...
@@ -298,15 +299,26 @@ class LogFp8TensorStats(BaseLogTensorStats):
...
@@ -298,15 +299,26 @@ class LogFp8TensorStats(BaseLogTensorStats):
API call used to collect the data about the tensor after process_tensor()/quantization.
API call used to collect the data about the tensor after process_tensor()/quantization.
"""
"""
assert
rowwise_quantized_tensor
is
columnwise_quantized_tensor
assert
rowwise_quantized_tensor
is
columnwise_quantized_tensor
assert
(
quantizer
is
not
None
# Skip logging if quantizer is None (layer runs in high precision)
),
"[NVTORCH INSPECT ERROR] LogFp8TensorStats cannot be run without low-precision recipe."
if
quantizer
is
None
:
warnings
.
warn
(
f
"[LogFp8TensorStats] Skipping stats collection for layer '
{
layer_name
}
', "
f
"tensor '
{
tensor_name
}
': layer runs in high precision (no quantizer)."
)
return
quantized_tensor
=
rowwise_quantized_tensor
quantized_tensor
=
rowwise_quantized_tensor
assert
isinstance
(
# Skip logging if quantized_tensor is not a QuantizedTensor (incompatible precision)
quantized_tensor
,
QuantizedTensor
if
not
isinstance
(
quantized_tensor
,
QuantizedTensor
):
),
"[NVTORCH INSPECT ERROR] LogFp8TensorStats quantized_tensor must be a QuantizedTensor."
warnings
.
warn
(
f
"[LogFp8TensorStats] Skipping stats collection for layer '
{
layer_name
}
', "
f
"tensor '
{
tensor_name
}
': incompatible precision "
f
"(expected QuantizedTensor, got
{
type
(
quantized_tensor
).
__name__
}
)."
)
return
recipe_name
=
_get_recipe_name
(
quantizer
)
recipe_name
=
_get_recipe_name
(
quantizer
)
for
stat
in
config
[
"stats"
]:
for
stat
in
config
[
"stats"
]:
...
...
transformer_engine/debug/features/log_nvfp4_tensor_stats.py
View file @
b8412430
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
from
typing
import
Dict
,
Optional
from
typing
import
Dict
,
Optional
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
import
warnings
import
torch
import
torch
import
nvdlfw_inspect.api
as
debug_api
import
nvdlfw_inspect.api
as
debug_api
...
@@ -152,23 +153,34 @@ class LogNvfp4TensorStats(BaseLogTensorStats):
...
@@ -152,23 +153,34 @@ class LogNvfp4TensorStats(BaseLogTensorStats):
API call used to collect the data about the tensor after process_tensor()/quantization.
API call used to collect the data about the tensor after process_tensor()/quantization.
"""
"""
assert
rowwise_quantized_tensor
is
columnwise_quantized_tensor
assert
rowwise_quantized_tensor
is
columnwise_quantized_tensor
assert
(
quantizer
is
not
None
# Skip logging if quantizer is None (layer runs in high precision)
),
"[NVTORCH INSPECT ERROR] LogNvfp4TensorStats cannot be run without NVFP4 quantizer."
if
quantizer
is
None
:
warnings
.
warn
(
f
"[LogNvfp4TensorStats] Skipping stats collection for layer '
{
layer_name
}
', "
f
"tensor '
{
tensor_name
}
': layer runs in high precision (no quantizer)."
)
return
quantized_tensor
=
rowwise_quantized_tensor
quantized_tensor
=
rowwise_quantized_tensor
#
Ensure we're working with NVFP4 tensors
#
Skip logging if not NVFP4 quantizer (incompatible precision)
if
not
isinstance
(
quantizer
,
NVFP4Quantizer
):
if
not
isinstance
(
quantizer
,
NVFP4Quantizer
):
raise
ValueError
(
warnings
.
warn
(
"[NVTORCH INSPECT ERROR] LogNvfp4TensorStats requires NVFP4Quantizer, "
f
"[LogNvfp4TensorStats] Skipping stats collection for layer '
{
layer_name
}
', "
f
"but got
{
type
(
quantizer
).
__name__
}
"
f
"tensor '
{
tensor_name
}
': incompatible precision "
f
"(expected NVFP4Quantizer, got
{
type
(
quantizer
).
__name__
}
)."
)
)
return
assert
isinstance
(
quantized_tensor
,
NVFP4TensorStorage
),
(
"[NVTORCH INSPECT ERROR] LogNvfp4TensorStats quantized_tensor must be a"
# Skip logging if quantized tensor is not NVFP4TensorStorage (incompatible precision)
" NVFP4TensorStorage."
if
not
isinstance
(
quantized_tensor
,
NVFP4TensorStorage
):
)
warnings
.
warn
(
f
"[LogNvfp4TensorStats] Skipping stats collection for layer '
{
layer_name
}
', "
f
"tensor '
{
tensor_name
}
': incompatible precision "
f
"(expected NVFP4TensorStorage, got
{
type
(
quantized_tensor
).
__name__
}
)."
)
return
for
stat
in
config
[
"stats"
]:
for
stat
in
config
[
"stats"
]:
self
.
check_if_stat_is_supported
(
stat
)
self
.
check_if_stat_is_supported
(
stat
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment