Skip to content

fix(pytorch): add missing f-string prefixes to error messages#3256

Open
andrewwhitecdw wants to merge 2 commits into
NVIDIA:mainfrom
andrewwhitecdw:fix-fstring-error-messages
Open

fix(pytorch): add missing f-string prefixes to error messages#3256
andrewwhitecdw wants to merge 2 commits into
NVIDIA:mainfrom
andrewwhitecdw:fix-fstring-error-messages

Conversation

@andrewwhitecdw

@andrewwhitecdw andrewwhitecdw commented Jul 25, 2026

Copy link
Copy Markdown

Fix two error messages that print literal placeholders instead of the intended values.

  • In QuantizedTensor.__torch_dispatch__, the placeholder {cls.__name__} was not interpolated because the string was missing the f prefix. Users calling .view() on a quantized tensor would see the literal text instead of the class name.

  • In NVFP4Tensor.__torch_dispatch__, the placeholder {len(args)} was not interpolated for the same reason, making the arg-count diagnostic misleading.

Both fixes are one-character additions of the missing f prefix, restoring the intended error diagnostics.

Signed-off-by: Andrew White <andrewh@cdw.com>
@andrewwhitecdw
andrewwhitecdw requested a review from ksivaman as a code owner July 25, 2026 00:41
@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Jul 25, 2026
@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes two error messages that were printing literal placeholder text instead of interpolated values due to missing f prefixes on string literals.

  • In QuantizedTensor.__torch_dispatch__, adds f prefix so {cls.__name__} resolves to the actual subclass name in the NotImplementedError raised on .view() calls.
  • In NVFP4Tensor.__torch_dispatch__, adds f prefix so {len(args)} resolves to the actual argument count in the RuntimeError raised when an unexpected number of arguments is passed to the view op; the string is also lightly reformatted across two lines.

Confidence Score: 5/5

Both changes are minimal, isolated one-character (plus reformatting) fixes to error message strings with no impact on control flow or data handling.

The only changes are adding f prefixes to two string literals inside raise statements. No logic, no data paths, and no APIs are modified — only the text of exception messages is corrected.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
transformer_engine/pytorch/quantized_tensor.py Added missing f prefix to the NotImplementedError string in QuantizedTensor.__torch_dispatch__ so {cls.__name__} is interpolated correctly.
transformer_engine/pytorch/tensor/nvfp4_tensor.py Added missing f prefix to the RuntimeError string in NVFP4Tensor.__torch_dispatch__ so {len(args)} is interpolated correctly; also reformatted the string to a two-line form for readability.

Reviews (2): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant