Skip to content

Clean up base constructor in model builder - #2192

Merged
kunal-vaishnavi merged 22 commits into
mainfrom
kvaishnavi/clean-up-init
Jun 4, 2026
Merged

Clean up base constructor in model builder#2192
kunal-vaishnavi merged 22 commits into
mainfrom
kvaishnavi/clean-up-init

Conversation

@kunal-vaishnavi

Copy link
Copy Markdown
Contributor

Description

This PR cleans up the constructor in the base class of the model builder.

Motivation and Context

Many PR contributions have polluted the constructor which has made it hard to read and understand. This PR standardizes the attribute initializations + subsequent group initialization helper method as the preferred approach.

Copilot AI review requested due to automatic review settings June 1, 2026 08:52
@kunal-vaishnavi
kunal-vaishnavi requested a review from a team as a code owner June 1, 2026 08:52
Comment thread src/python/py/models/builders/base.py Fixed
Comment thread src/python/py/models/quantized_model.py Dismissed
Comment thread src/python/py/models/quantized_model.py Dismissed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Python model builder base constructor to move scattered initialization logic into grouped helper methods and introduces EP-specific “expansions” (notably for TRT-RTX) to keep the base builder cleaner.

Changes:

  • Refactors base builder initialization: graph-capture handling, RoPE naming cleanup, quant-attrs structure flattening, and helper init hooks (make_lm_head_init, make_quant_init, make_tied_embeddings_init).
  • Adds TRT-RTX expansion module and wiring intended to patch/extend builder behavior for that EP.
  • Moves some model-specific init logic into subclasses (e.g., Phi block-sparse attention and LM-head masking).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
src/python/py/models/quantized_model.py Removes CodeQL suppressions and minor style cleanup.
src/python/py/models/builders/qwen.py Updates quant-attrs access pattern and minor node naming tweaks.
src/python/py/models/builders/phi.py Adds Phi-specific init hooks for RoPE, block-sparse attention, and LM-head masking.
src/python/py/models/builders/llama.py Adds LLaMA-specific RoPE scaling init hook.
src/python/py/models/builders/expansions/trt_rtx.py New TRT-RTX expansion mixin intended to provide EP-specific subgraph expansions.
src/python/py/models/builders/expansions/init.py Exports TRT-RTX expansion.
src/python/py/models/builders/base.py Main refactor: constructor cleanup, new init hooks, flattened quant attrs, and expansion initialization.
src/python/py/models/builders/init.py Adds sys.path mutation (intended to support expansion imports).
src/python/py/models/builder.py Updates CLI help text for qmoe block size defaults / supported EPs.

Comment thread src/python/py/models/builders/base.py
Comment thread src/python/py/models/builders/base.py Outdated
Comment thread src/python/py/models/builders/__init__.py Outdated
Comment thread src/python/py/models/builders/expansions/trt_rtx.py
Comment thread src/python/py/models/builders/expansions/trt_rtx.py
Comment thread src/python/py/models/builders/phi.py Outdated
Comment thread src/python/py/models/builders/phi.py Outdated
Comment thread src/python/py/models/builders/base.py
Comment thread src/python/py/models/builders/expansions/trt_rtx.py Outdated
Comment thread src/python/py/models/builders/base.py Outdated
Comment thread src/python/py/models/builders/base.py Dismissed
Comment thread src/python/py/models/builders/base.py Dismissed
Comment thread src/python/py/models/builders/base.py Outdated
Comment thread src/python/py/models/builders/base.py Outdated
Comment thread src/python/py/models/builders/expansions/webgpu.py Fixed
@kunal-vaishnavi
kunal-vaishnavi merged commit 9b875c3 into main Jun 4, 2026
16 of 18 checks passed
@kunal-vaishnavi
kunal-vaishnavi deleted the kvaishnavi/clean-up-init branch June 4, 2026 05:17
kunal-vaishnavi added a commit that referenced this pull request Jun 9, 2026
### Description

This PR adds a README file in `test/` to explain the folder structure
for future contributions.

### Motivation and Context

[This PR](#2192)
updated the entire `test/` directory structure.
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.

OGA export generating an invalid model when a lm_head unquantized model is exported

5 participants