-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Use sets to improve performance of dfs search #6213
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
Conversation
5714577
to
61e7fb1
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6213 +/- ##
==========================================
+ Coverage 56.95% 57.11% +0.15%
==========================================
Files 506 506
Lines 30467 31087 +620
Branches 4592 4624 +32
==========================================
+ Hits 17353 17754 +401
- Misses 12285 12505 +220
+ Partials 829 828 -1 ☔ View full report in Codecov by Sentry. |
c1ca823
to
e75c67a
Compare
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
e75c67a
to
01d56d4
Compare
It seems reachable + unreachable = set of nodes. Do you it is doable to remoave unreachable and simplify the function signature assuming performance stays the same? |
@xadupre The nodes_to_search = [
index
for index in range(len(nodes))
if node_output_name in nodes[index].output and index not in reachable
] This leads to a longer runtime for larger models
|
### Description This change modifies the DFS search used in model extraction to use sets rather than iterables ### Motivation and Context While shape inference is the most significant bottleneck, these changes are a step in the direction of being able to support model extraction for very large graphs. ## Test Script ## ```python3 import onnx from onnx.utils import Extractor model = onnx.load("obertquant.onnx") extractor = Extractor(model) extracted_model = extractor.extract_model( input_names=["input_ids", "attention_mask", "token_type_ids"], output_names=["2058"] ) onnx.save(extracted_model, "truncated.onnx") ``` Benchmarks were produced using pyinstrument and analyzing the `Extractor.extract_model` function | Model Name | Num Nodes | Previous | New | | ---- | -------- | --------- | ----- | | obertquant.onnx | 1271 | 0.158s | 0.110s | | ai-town-3B.onnx | 3515 | 8.002s | 3.725s | Signed-off-by: Kyle Sayers <kylesayrs@gmail.com> Signed-off-by: Andreas Fehlner <fehlner@arcor.de>
### Description This change modifies the DFS search used in model extraction to use sets rather than iterables ### Motivation and Context While shape inference is the most significant bottleneck, these changes are a step in the direction of being able to support model extraction for very large graphs. ## Test Script ## ```python3 import onnx from onnx.utils import Extractor model = onnx.load("obertquant.onnx") extractor = Extractor(model) extracted_model = extractor.extract_model( input_names=["input_ids", "attention_mask", "token_type_ids"], output_names=["2058"] ) onnx.save(extracted_model, "truncated.onnx") ``` Benchmarks were produced using pyinstrument and analyzing the `Extractor.extract_model` function | Model Name | Num Nodes | Previous | New | | ---- | -------- | --------- | ----- | | obertquant.onnx | 1271 | 0.158s | 0.110s | | ai-town-3B.onnx | 3515 | 8.002s | 3.725s | Signed-off-by: Kyle Sayers <kylesayrs@gmail.com> Signed-off-by: Linsho Kaku <linsho@preferred.jp>
Description
This change modifies the DFS search used in model extraction to use sets rather than iterables
Motivation and Context
While shape inference is the most significant bottleneck, these changes are a step in the direction of being able to support model extraction for very large graphs.
Test Script
Benchmarks were produced using pyinstrument and analyzing the
Extractor.extract_model
function