Skip to content

[PyTorch] Optimize GroupedLinear validation - #3405

Open
negvet wants to merge 2 commits into
NVIDIA:mainfrom
negvet:optimize_grouped_linear_validation_cpu
Open

[PyTorch] Optimize GroupedLinear validation#3405
negvet wants to merge 2 commits into
NVIDIA:mainfrom
negvet:optimize_grouped_linear_validation_cpu

Conversation

@negvet

@negvet negvet commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Description

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

Fixes # (issue)

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

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

Signed-off-by: Evgeny <etsykunov@nvidia.com>
@negvet
negvet requested a review from ksivaman as a code owner August 19, 2026 17:04
@negvet
negvet requested a review from vthumbe1503 August 19, 2026 17:04
@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR avoids unnecessary backward custom-quantizer validation when gradients are disabled while preserving validation on the first grad-enabled use.

  • Moves the grad-mode guard into _validate_custom_recipe_quantizers after built-in-recipe, missing-generation, and cache checks.
  • Calls backward validation unconditionally from _get_quantizers, allowing the validator’s fast paths to avoid unnecessary grad-mode queries.
  • Extends hybrid quantization tests for inference, cached validation, and the transition to grad-enabled execution.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
transformer_engine/pytorch/module/grouped_linear.py Defers backward custom-quantizer validation while gradients are disabled and retains validation before a backward-capable forward consumes the generation.
tests/pytorch/test_hybrid_quantization.py Adds coverage for built-in recipes, no-grad initialization, first grad-enabled validation, and cached-validation fast paths.

Reviews (2): Last reviewed commit: "Merge branch 'main' into optimize_groupe..." | Re-trigger Greptile

@vthumbe1503 vthumbe1503 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for fixing the review comment from previous PR

@vthumbe1503

Copy link
Copy Markdown
Collaborator

/te-ci pytorch

@vthumbe1503 vthumbe1503 self-assigned this Aug 21, 2026
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.

2 participants