-
Notifications
You must be signed in to change notification settings - Fork 273
Integrate Automated QDQ placement tool - part 2.2 #845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate Automated QDQ placement tool - part 2.2 #845
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughA new ONNX graph region search module is introduced, implementing a two-phase hierarchical partitioning framework. The implementation includes bottom-up partitioning via Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant CombinedRegionSearch
participant RegionPartitioner
participant RegionSearchBase as RegionSearchBase<br/>(Analysis)
participant TopDownRegionBuilder
participant Graph
User->>CombinedRegionSearch: search_regions()
CombinedRegionSearch->>RegionPartitioner: __init__() + partition_graph()
RegionPartitioner->>RegionSearchBase: _build_forward_reachable_nodes_map()<br/>_is_tensor_divergent()
RegionPartitioner->>Graph: traverse nodes, detect sequences
Graph-->>RegionPartitioner: nodes, connectivity
RegionPartitioner->>RegionPartitioner: _build_sequence_from_node()<br/>_build_small_converged_region()
RegionPartitioner-->>CombinedRegionSearch: list[Region] (leaf regions)
CombinedRegionSearch->>TopDownRegionBuilder: __init__(root_region)<br/>build_composite_region()
TopDownRegionBuilder->>RegionSearchBase: compute_region_boundaries()
TopDownRegionBuilder->>TopDownRegionBuilder: _split_sequence_regions()<br/>_merge_converged_regions()
TopDownRegionBuilder-->>CombinedRegionSearch: Region (hierarchical composite)
CombinedRegionSearch-->>User: final hierarchical regions
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@modelopt/onnx/quantization/autotune/region_search.py`:
- Around line 36-56: In __init__, _build_root_region() can call
compute_region_boundaries which expects self.tensor_users_map to exist, so
initialize tensor_users_map before calling _build_root_region: compute and
assign self.tensor_users_map (using get_tensor_consumer_node_indices(self.graph)
when tensor_users_map is None) prior to calling self._build_root_region(); then
proceed to construct root and finally set/compute forward_reachable_nodes_map as
currently done.
- Around line 425-455: In _build_small_converged_region the divergent node
(start_node_idx) is removed from visited_nodes and never appended to the region;
fix this by explicitly adding the divergent node to the region and marking it
visited: after visited_nodes.remove(start_node_idx) call
self._append_node_to_region(start_node_idx) and
self.visited_nodes.add(start_node_idx) (so it isn't skipped by the subsequent
loop), keeping the rest of the logic for appending branch nodes and the converge
node as-is.
🧹 Nitpick comments (2)
tests/unit/onnx/quantization/autotune/test_region_search.py (2)
126-133: Useself.assert*methods instead of bareassertinunittesttests.Bare
assertstatements are compiled away when Python runs with the-Oor-OOoptimization flags, causing these checks to be skipped entirely in optimized mode.self.assert*methods (e.g.,self.assertEqual(),self.assertTrue()) are regular method calls that execute regardless of optimization flags and provide better diagnostic context on failure.Replace
assert partitioner is not Nonewithself.assertIsNotNone(partitioner)andassert partitioner.graph == graphwithself.assertEqual(partitioner.graph, graph).
23-30: Remove thesys.path.insert()call; it's unnecessary given the pytest configuration inpyproject.toml.The project already configures
pythonpath = ["tests/"]inpyproject.toml(line 137), which handles import resolution properly. Thesys.path.insert()on line 29 is redundant sincemodeloptis at the repository root and will be discoverable by pytest's standard import resolution. Removing this keeps the test file cleaner and avoids manual path manipulation.
cbd709a to
42ca7f2
Compare
gcunhase
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, deferring final approval to @ajrasane, thanks.
|
/ok to test 00e8202 |
Signed-off-by: Will Guo <willg@nvidia.com>
Signed-off-by: Will Guo <willg@nvidia.com>
Signed-off-by: Will Guo <willg@nvidia.com>
00e8202 to
54e3ddc
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #845 +/- ##
==========================================
+ Coverage 73.43% 73.70% +0.26%
==========================================
Files 197 198 +1
Lines 20651 21096 +445
==========================================
+ Hits 15166 15549 +383
- Misses 5485 5547 +62 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Will Guo <willg@nvidia.com>
f67d957 to
b13c011
Compare
b13c011 to
f67d957
Compare
|
/ok to test f67d957 |
Signed-off-by: Will Guo <willg@nvidia.com>
|
/ok to test bdedacf |
What does this PR do?
This PR implements RegionSearch class. RegionSearch could help partition big ONNX model into small region. QDQ autouning will be performed on the regions.
Overview: ?
Usage
# Add a code snippet demonstrating how to use thisTesting
Before your PR is "Ready for review"
Additional Information
Summary by CodeRabbit
Release Notes
Refactor