Skip to content

[AutoDeploy][2/n] Modular InferenceOptimizer - #90

Merged
lucaslie merged 2 commits into
feat/ad-2025-07-07from
ll/modular_transforms_2
Jul 17, 2025
Merged

[AutoDeploy][2/n] Modular InferenceOptimizer #90
lucaslie merged 2 commits into
feat/ad-2025-07-07from
ll/modular_transforms_2

Conversation

@lucaslie

Copy link
Copy Markdown

moving more transforms into the modular inference optimizer

@lucaslie
lucaslie requested a review from Fridah-nv July 16, 2025 22:34
@lucaslie lucaslie self-assigned this Jul 16, 2025
Copilot AI review requested due to automatic review settings July 16, 2025 22:34

Copilot AI left a comment

Copy link
Copy Markdown

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 modular inference optimizer by moving low-level cleanup transforms out of the export module and into configurable stages, introduces stricter config typing, updates the InferenceOptimizer API, and adjusts tests to use a shared FakeFactory helper and the new optimizer in the attention matcher tests.

  • Remove inline cleanup functions (no-op slice/add/check removals) from export.py, drive them via optimizer config
  • Introduce StrictInferenceOptimizerConfig, allow supplying an existing GraphModule to InferenceOptimizer
  • Centralize FakeFactory in a test helper and update test_attention_matcher to use InferenceOptimizer

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unittest/_torch/auto_deploy/unit/singlegpu/transformations/library/test_kv_cache.py Remove local FakeFactory and import shared helper
tests/unittest/_torch/auto_deploy/unit/singlegpu/transformations/library/test_attention_matcher.py Add _get_match_repeat_kv_optimizer using InferenceOptimizer
tests/unittest/_torch/auto_deploy/_utils_test/_graph_test_helpers.py Add shared FakeFactory
tensorrt_llm/_torch/auto_deploy/transformations/export.py Remove cleanup transforms and update export signatures
tensorrt_llm/_torch/auto_deploy/transform/optimizer.py Import strict config type, make gm optional in __call__
tensorrt_llm/_torch/auto_deploy/transform/interface.py Define StrictInferenceOptimizerConfig and refine config type aliases
tensorrt_llm/_torch/auto_deploy/config/default.yaml Add cleanup transforms under post_export stage
Comments suppressed due to low confidence (2)

tensorrt_llm/_torch/auto_deploy/transform/optimizer.py:48

  • [nitpick] The signature now accepts an optional gm, but the docstring above still only mentions cm. Update the docstring to explain the new gm parameter.
        self, cm: CachedSequenceInterface, gm: Optional[GraphModule] = None

tests/unittest/_torch/auto_deploy/_utils_test/_graph_test_helpers.py:14

  • The helper file refers to nn.Module but nn is not imported. Add import torch.nn as nn at the top to avoid a NameError.
    def __init__(self, model: nn.Module):

Comment thread tensorrt_llm/_torch/auto_deploy/transformations/export.py
@lucaslie
lucaslie force-pushed the ll/modular_transforms_2 branch from 6b773de to 31f03c5 Compare July 16, 2025 22:40
Comment thread tensorrt_llm/_torch/auto_deploy/transform/library/cleanup_noop_add.py Outdated
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/export.py
Comment thread tensorrt_llm/_torch/auto_deploy/transformations/export.py

@Fridah-nv Fridah-nv left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

lucaslie added 2 commits July 17, 2025 08:42
Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
@lucaslie
lucaslie force-pushed the ll/modular_transforms_2 branch from 31f03c5 to 8af25f2 Compare July 17, 2025 15:45
@lucaslie
lucaslie enabled auto-merge (squash) July 17, 2025 15:45
@lucaslie
lucaslie merged commit 3b229c7 into feat/ad-2025-07-07 Jul 17, 2025
1 check passed
lucaslie added a commit that referenced this pull request Jul 18, 2025
* moving more transforms into the modular system

Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>

* fixes for some configs

Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>

---------

Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
lucaslie added a commit that referenced this pull request Jul 21, 2025
* moving more transforms into the modular system

Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>

* fixes for some configs

Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>

---------

Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
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.

3 participants