-
Notifications
You must be signed in to change notification settings - Fork 45
Feature/graph net bench #541
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
Open
leon062112
wants to merge
20
commits into
PaddlePaddle:develop
Choose a base branch
from
leon062112:feature/graph_net_bench
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
eeca326
add grpc server and remote executo demo
leon062112 933de80
add rpc_cmd script
leon062112 5872d02
add RpcExecutor
leon062112 9925ca3
remove DESIGN.md
leon062112 80b96c7
Merge branch 'PaddlePaddle:develop' into develop
leon062112 398f78c
refactor: reorganize code structure
leon062112 e9e3191
Merge branch 'PaddlePaddle:develop' into develop
leon062112 a7ec54e
Merge branch 'PaddlePaddle:develop' into feature/graph_net_bench
leon062112 0f0b234
Merge branch 'PaddlePaddle:develop' into develop
leon062112 929709e
change rpc_cmd to test_reference_device.py
leon062112 9304fad
Merge branch 'feature/graph_net_bench' of https://github.com/leon0621…
leon062112 7387172
Merge branch 'PaddlePaddle:develop' into feature/graph_net_bench
leon062112 6bb75f4
Merge branch 'feature/graph_net_bench' of https://github.com/leon0621…
leon062112 f0e0179
reconstruct SampleRemoteExecutor
leon062112 87cd9fe
remove unrelated changes
leon062112 74c26dd
add test config
leon062112 0406f8e
Merge branch 'feature/graph_net_bench' into develop
leon062112 62b90ef
executor
leon062112 482daa7
Merge branch 'feature/graph_net_bench' into develop
leon062112 e5a6748
change
leon062112 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # gRPC generated code package |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
graph_net/graph_net_bench/grpc/sample_remote_executor_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #!/usr/bin/env python3 | ||
| """gRPC Client CLI for SampleRemoteExecutor. | ||
|
|
||
| Usage: | ||
| python -m graph_net.graph_net_bench.client --help | ||
| """ | ||
|
|
||
| import argparse | ||
| import sys | ||
|
|
||
| from graph_net.graph_net_bench.sample_remote_executor import SampleRemoteExecutor | ||
|
|
||
| def main(args): | ||
| parser = argparse.ArgumentParser( | ||
| description="gRPC Client for remote model execution", | ||
| formatter_class=argparse.RawDescriptionHelpFormatter, | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--machine", | ||
| type=str, | ||
| default="localhost", | ||
| help="Remote server address (default: localhost)", | ||
| ) | ||
| parser.add_argument( | ||
| "--port", | ||
| type=int, | ||
| default=50052, | ||
| help="gRPC server port (default: 50052)", | ||
| ) | ||
| parser.add_argument( | ||
| "--model-path", | ||
| type=str, | ||
| required=True, | ||
| help="Path to model directory containing model.py and weight_meta.py", | ||
| ) | ||
| parser.add_argument( | ||
| "--random-seed", | ||
| type=int, | ||
| default=42, | ||
| help="Random seed for reproducible inference (default: 42)", | ||
| ) | ||
| parser.add_argument( | ||
| "--rpc-cmd", | ||
| type=str, | ||
| default="python3 -m graph_net.torch.test_reference_device", | ||
| help="Command to execute on remote server", | ||
| ) | ||
| parser.add_argument( | ||
| "--output-dir", | ||
| type=str, | ||
| default=None, | ||
| help="Directory to save output tensors (default: current directory)", | ||
| ) | ||
|
|
||
|
|
||
| executor = SampleRemoteExecutor( | ||
leon062112 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| machine=args.machine, | ||
| port=args.port, | ||
| rpc_cmd=args.rpc_cmd, | ||
| ) | ||
|
|
||
| try: | ||
| print(f"Sending request to {args.machine}:{args.port}...", file=sys.stderr) | ||
| tensors = executor(args.model_path, args.random_seed) | ||
|
|
||
| print(f"Received {len(tensors)} output tensors:", file=sys.stderr) | ||
| for i, tensor in enumerate(tensors): | ||
| print(f" output_{i}: shape={tensor.shape}, dtype={tensor.dtype}", file=sys.stderr) | ||
|
|
||
| if args.output_dir: | ||
| import os | ||
| from pathlib import Path | ||
| import torch | ||
|
|
||
| output_path = Path(args.output_dir) | ||
| output_path.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| for i, tensor in enumerate(tensors): | ||
| output_file = output_path / f"output_{i}.pt" | ||
| torch.save(tensor, output_file) | ||
| print(f"Saved output_{i} to {output_file}", file=sys.stderr) | ||
leon062112 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
leon062112 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| print("Execution completed successfully!", file=sys.stderr) | ||
|
|
||
| except Exception as e: | ||
| print(f"Error: {e}", file=sys.stderr) | ||
| sys.exit(1) | ||
| finally: | ||
| executor.close() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.