-
Notifications
You must be signed in to change notification settings - Fork 45
add local_graph_decomposer_wrapper #572
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,93 @@ | ||||||||||||||||||||||||||||||||||||||
| import argparse | ||||||||||||||||||||||||||||||||||||||
| import base64 | ||||||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||||||
| import subprocess | ||||||||||||||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||||||||||||||
| from typing import List | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| from graph_net.graph_net_root import get_graphnet_root | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def convert_json_to_b64_string(config) -> str: | ||||||||||||||||||||||||||||||||||||||
| return base64.b64encode(json.dumps(config).encode()).decode() | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def build_decorator_config( | ||||||||||||||||||||||||||||||||||||||
| framework: str, | ||||||||||||||||||||||||||||||||||||||
| model_name: str, | ||||||||||||||||||||||||||||||||||||||
| output_dir: str, | ||||||||||||||||||||||||||||||||||||||
| split_positions: List[int], | ||||||||||||||||||||||||||||||||||||||
| ) -> dict: | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| ) -> dict: | |
| ) -> dict: | |
| """ | |
| Build the decorator configuration for running a model with the graph decomposer. | |
| The returned dictionary is encoded and passed to the framework-specific | |
| `run_model` entry point to configure how the graph extraction and optional | |
| post-processing should be performed. | |
| :param framework: Name of the ML framework (e.g. ``"paddle"`` or ``"torch"``), | |
| used to select framework-specific extractor paths and optional post-processors. | |
| :param model_name: Logical name of the model to include in the decorator config. | |
| :param output_dir: Directory where the graph decomposer should write its outputs. | |
| :param split_positions: List of layer or block indices at which the model | |
| computation should be split during graph decomposition. | |
| :return: A nested dictionary describing the decorator, custom extractor, and, | |
| for some frameworks (e.g. ``"paddle"``), additional post-extraction processing. | |
| """ |
Copilot
AI
Jan 15, 2026
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.
The main function lacks a docstring explaining its purpose and behavior. Adding documentation would improve code clarity and maintainability.
| def main(): | |
| def main(): | |
| """Entry point for running a model with the local graph decomposer. | |
| This function expects command-line arguments to have been parsed into the | |
| module-level ``args`` variable. It: | |
| 1. Parses and validates the JSON string of tensor split positions. | |
| 2. Builds a decorator configuration for the specified framework and model. | |
| 3. Base64-encodes the configuration and passes it to the framework-specific | |
| ``run_model`` module as a decorator configuration argument. | |
| 4. Executes the model in a subprocess and exits the current process with | |
| the subprocess's return code. | |
| """ |
Copilot
AI
Jan 15, 2026
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.
The main function references the args variable before it is defined. The args variable is only assigned on line 92 within the if name == "main" block, but the main function is called on line 93. This creates a scope issue where args is not accessible within the main function.
The main function should accept args as a parameter.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -322,52 +322,33 @@ def run_decomposer_for_single_model( | |||||||
| output_dir: str, | ||||||||
| log_path: str, | ||||||||
| ) -> bool: | ||||||||
|
||||||||
| ) -> bool: | |
| ) -> bool: | |
| """Decomposes a single model.""" |
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.
The convert_json_to_b64_string function is duplicated from subgraph_decompose_and_evaluation_step.py. This creates code duplication and maintainability issues. Consider importing this function from the existing module or creating a shared utility module for common encoding/decoding functions.