Skip to content

[PyTorch] Decouple python quantization classes and refactor custom quantization - #2276

Merged
negvet merged 14 commits into
NVIDIA:mainfrom
negvet:custom_quantization_refactor
Oct 22, 2025
Merged

[PyTorch] Decouple python quantization classes and refactor custom quantization#2276
negvet merged 14 commits into
NVIDIA:mainfrom
negvet:custom_quantization_refactor

Conversation

@negvet

@negvet negvet commented Oct 16, 2025

Copy link
Copy Markdown
Collaborator

Description

Decouple python base quantization classes (aka API).
Keep "custom" instead of "experimental" naming convention.

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

negvet and others added 7 commits October 14, 2025 14:57
Signed-off-by: Evgeny <etsykunov@nvidia.com>
Signed-off-by: Evgeny <etsykunov@nvidia.com>
Signed-off-by: Evgeny <etsykunov@nvidia.com>
Signed-off-by: Evgeny <etsykunov@nvidia.com>
Signed-off-by: Evgeny <etsykunov@nvidia.com>
@negvet

negvet commented Oct 20, 2025

Copy link
Copy Markdown
Collaborator Author

/te-ci pytorch

Signed-off-by: Evgeny <etsykunov@nvidia.com>
@negvet

negvet commented Oct 20, 2025

Copy link
Copy Markdown
Collaborator Author

/te-ci pytorch

@negvet

negvet commented Oct 21, 2025

Copy link
Copy Markdown
Collaborator Author

/te-ci pytorch

Comment thread tests/pytorch/nvfp4/test_nvfp4_rht_quantize_exact.py Outdated
Comment thread tests/pytorch/test_custom_recipe.py Outdated

@ksivaman ksivaman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The main blocking issue is with some of the imports.

Could you detail in the description the motivation behind this change aside from the naming from experimentalcustom? Why do we want to have a separate quantization_base.py outside of the tensor dir and why the decoupling of that from the quantization_helpers file which is inside the tensor dir?

negvet and others added 2 commits October 21, 2025 17:23
Co-authored-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
Signed-off-by: Evgeny Tsykunov <e.tsykunov@gmail.com>
Co-authored-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
Signed-off-by: Evgeny Tsykunov <e.tsykunov@gmail.com>
@negvet

negvet commented Oct 21, 2025

Copy link
Copy Markdown
Collaborator Author

Why do we want to have a separate quantization_base.py outside of the tensor dir and why the decoupling of that from the quantization_helpers file which is inside the tensor dir?

The main idea is to help users more easily create custom recipes.
Here is the benefit: when subclassing, users need to learn only classes from quantization_base.py (three classes and two functions as of now).
This is an attempt to abstract away all TE complexity from the user.

For us, this can enable setting guards for this API change - if this file is getting changes, certain people might be alarmed etc.
This will help to keep API stable. Usually API is located separately, quantization_base.py is not an API because it contains some implementations (there are no pure abstractions), but still it is good to keep it separate at a pytorch top level.

For the quantization_helpers, it contains some TE internal implementations that a general user might not need to know about, so I kept it in tensor submodule. With this PR, tensor submodule becomes a place for concrete implementations, but not base classes.

@ksivaman

Copy link
Copy Markdown
Member

Fair. I think the name quantized_tensor.py might be more apt instead of quantization_base.py then. Because it is more representative of the methods in it and we already have a quantization.py file in the same dir which is mostly unrelated to this.

ksivaman and others added 3 commits October 21, 2025 13:53
Signed-off-by: Evgeny <etsykunov@nvidia.com>
Signed-off-by: Evgeny <etsykunov@nvidia.com>
@negvet
negvet requested a review from ksivaman October 22, 2025 09:16
@negvet

negvet commented Oct 22, 2025

Copy link
Copy Markdown
Collaborator Author

/te-ci pytorch

@ksivaman ksivaman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@negvet
negvet merged commit ce2e8bd into NVIDIA:main Oct 22, 2025
20 of 23 checks passed
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