Skip to content

fix: TransformerEngineBaseModule quantizers init values type#2927

Open
muutot wants to merge 1 commit intoNVIDIA:mainfrom
muutot:dev
Open

fix: TransformerEngineBaseModule quantizers init values type#2927
muutot wants to merge 1 commit intoNVIDIA:mainfrom
muutot:dev

Conversation

@muutot
Copy link
Copy Markdown

@muutot muutot commented Apr 25, 2026

Description

Make TransformerEngineBaseModule quantizer initialization values correct

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 the TransformerEngineBaseModule quantizers init values("scaling_fwd", "scaling_bwd") type from dict to list

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 25, 2026

Greptile Summary

This PR corrects the initial placeholder type of self.quantizers["scaling_fwd"] and self.quantizers["scaling_bwd"] from {} (dict) to [] (list) in TransformerEngineBaseModule.__init__. Both values are always replaced by recipe_state.make_quantizers() (which returns a list) before any code accesses them by integer index, so the practical impact of the original bug is low, but aligning the initial type with the actual type is a clear improvement in correctness and consistency.

Confidence Score: 5/5

Safe to merge — single-line corrective change with no functional risk.

The only changed line corrects the initial type of two placeholder values that are always overwritten before use. No logic paths access these values as dicts, and the list type matches the actual runtime type produced by make_quantizers(). No P1 or P0 findings.

No files require special attention.

Important Files Changed

Filename Overview
transformer_engine/pytorch/module/base.py Single-line fix changing the initial type of self.quantizers["scaling_fwd"] and self.quantizers["scaling_bwd"] from {} (dict) to [] (list), matching the list returned by recipe_state.make_quantizers() that replaces these values at runtime.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["__init__\nself.quantizers = {scaling_fwd: [], scaling_bwd: []}"] --> B["prepare_forward / init_fp8_metadata"]
    B --> C["init_fp8_meta_tensors(recipe)"]
    C --> D["set_meta_tensor(fwd=True)"]
    C --> E["set_meta_tensor(fwd=False)"]
    D --> F["recipe_state = RecipeState.create(...)"]
    E --> G["recipe_state = RecipeState.create(...)"]
    F --> H["self.quantizers['scaling_fwd'] = recipe_state.make_quantizers() → list"]
    G --> I["self.quantizers['scaling_bwd'] = recipe_state.make_quantizers() → list"]
    H --> J["reset_parameters\nself.quantizers['scaling_fwd'][fp8_meta_index] ← integer index"]
    I --> J
    H --> K["adjust_amax_history_length\nself.quantizers[meta_key] = ...make_quantizers()"]
Loading

Reviews (1): Last reviewed commit: "fix: TransformerEngineBaseModule quantiz..." | Re-trigger Greptile

@muutot
Copy link
Copy Markdown
Author

muutot commented Apr 25, 2026

/te-ci

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