Skip to content

Commit 60fb21b

Browse files
committed
merge develop
2 parents f8524bb + 956fb0d commit 60fb21b

File tree

3,336 files changed

+2379447
-70345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,336 files changed

+2379447
-70345
lines changed

.github/actions/check-bypass/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "Check bypass"
2-
description: "A custom action to encapsulate PFCCLab/ci-bypass"
2+
description: "A custom action to encapsulate GraphNet"
33
inputs:
44
github-token:
55
description: "GitHub token"
@@ -18,7 +18,7 @@ runs:
1818
- id: check-bypass
1919
name: Check Bypass
2020
env:
21-
CI_TEAM_MEMBERS: '["SigureMo", "risemeup1", "tianshuo78520a", "0x3878f", "swgu98", "luotao1", "XieYunshen"]'
21+
CI_TEAM_MEMBERS: '["lixinqi", "Xreki"]'
2222
uses: PFCCLab/ci-bypass@v1
2323
with:
2424
github-token: ${{ inputs.github-token }}

.github/workflows/Validate-GPU.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
-v "/home/data/cfs/.ccache:/root/.ccache" \
6262
-v "/dev/shm:/dev/shm" \
6363
-v ${{ github.workspace }}/../../..:${{ github.workspace }}/../../.. \
64-
-v ${{ github.workspace }}:/graphnet \
64+
-v ${{ github.workspace }}:${{ github.workspace }} \
6565
-e python \
6666
-e core_index \
6767
-e BRANCH \
@@ -73,7 +73,7 @@ jobs:
7373
-e CACHE_DIR \
7474
-e GITHUB_API_TOKEN \
7575
-e CFS_DIR \
76-
-w /graphnet --network host ${docker_image}
76+
-w ${{ github.workspace }} --network host ${docker_image}
7777
7878
- name: Run check
7979
env:

README.md

Lines changed: 109 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,164 @@
11
# GraphNet ![](https://img.shields.io/badge/version-v0.1-brightgreen) ![](https://img.shields.io/github/issues/PaddlePaddle/GraphNet?label=open%20issues) [![](https://img.shields.io/badge/Contribute%20to%20GraphNet-blue)](https://github.com/PaddlePaddle/GraphNet/issues/98)
22

3+
**GraphNet** is a large-scale dataset of deep learning **computation graphs**, built as a standard benchmark for **tensor compiler** optimization. It provides 2.7K computation graphs extracted from state-of-the-art deep learning models spanning diverse tasks and ML frameworks. With standardized formats and rich metadata, GraphNet enables fair comparison and reproducible evaluation of the general optimization capabilities of tensor compilers, thereby supporting advanced research such as AI for System on compilers (AI for Compiler).
34

4-
**GraphNet** is a large-scale dataset of deep learning **computation graphs**, designed to serve as a standard benchmark and training corpus for **AI-driven tensor compiler optimization**. It contains diverse graphs extracted from state-of-the-art models, enabling effective evaluation of compiler pass optimizations across frameworks and hardware platforms.
5-
6-
7-
With GraphNet, users can:
8-
1. Quickly benchmark the optimization performance of various compiler strategies.
9-
2. Easily conduct regression tests on existing compilers.
10-
3. Train AI‑for‑Systems models to automatically generate compiler optimization passes.
11-
12-
**Vision**: We aim to achieve cross-hardware portability of compiler optimizations by allowing models to learn and transfer optimization strategies. It will significantly reduce the manual effort required to develop efficient operator implementations.
5+
<br>
6+
<div align="center">
7+
<img src="/pics/Eval_result.png" alt="Violin plots of speedup distributions" width="65%">
8+
</div>
139

10+
Compiler developers can use GraphNet samples to evaluate tensor compilers (e.g., CINN, TorchInductor, TVM) on target tasks. The figure above shows the speedup of two compilers (CINN and TorchInductor) across two tasks (CV and NLP).
1411

12+
## 🧱 Dataset Construction
1513

14+
To guarantee the dataset’s overall quality, reproducibility, and cross-compiler compatibility, we define the following construction **constraints**:
1615

17-
### Dataset Construction Constraints:
18-
1. Dynamic graphs must execute correctly.
19-
2. Each computation graph should include a standardized method for measuring performance.
20-
3. Graphs and their corresponding Python code must support serialization and deserialization.
21-
4. The full graph can be decomposed into two disjoint subgraphs.
22-
5. Compiler passes or behaviors must be configurable.
23-
6. Operator names within each computation graph must be statically parseable.
24-
7. If custom operators are used, their implementation code must be fully accessible.
25-
8. Graph execution on different hardware backends must be configurable via a unified interface.
16+
1. Computation graphs must be executable in imperative (eager) mode.
17+
2. Computation graphs and their corresponding Python code must support serialization and deserialization.
18+
3. The full graph can be decomposed into two disjoint subgraphs.
19+
4. Operator names within each computation graph must be statically parseable.
20+
5. If custom operators are used, their implementation code must be fully accessible.
2621

22+
### Graph Extraction & Validation
2723

28-
## ⚡ Quick Start
29-
For full implementation details, please refer to the [Co-Creation Tutorial](https://github.com/PaddlePaddle/GraphNet/blob/develop/CONTRIBUTE_TUTORIAL.md#co-creation-tutorial).
30-
### Benchmark your compiler on the model:
24+
We provide automated extraction and validation tools for constructing this dataset.
3125

32-
**graph_net.torch.test_compiler**
33-
```
34-
python3 -m graph_net.torch.test_compiler \
35-
--model-path $GRAPH_NET_EXTRACT_WORKSPACE/model_name/ \
36-
--compiler /path/to/custom/compiler
37-
# Note: if --compiler is omitted, PyTorch’s built-in compiler is used by default
38-
```
26+
<div align="center">
27+
<img src="/pics/graphnet_overview.jpg" alt="GraphNet Architecture Overview" width="65%">
28+
</div>
3929

40-
### Contribute computation graphs to GraphNet:
4130
**Demo: Extract & Validate ResNet‑18**
42-
```
31+
```bash
4332
git clone https://github.com/PaddlePaddle/GraphNet.git
4433
cd GraphNet
4534

4635
# Set your workspace directory
47-
export GRAPH_NET_EXTRACT_WORKSPACE=/home/yourname/graphnet_workspace
36+
export GRAPH_NET_EXTRACT_WORKSPACE=/home/yourname/graphnet_workspace/
4837

4938
# Extract the ResNet‑18 computation graph
5039
python graph_net/test/vision_model_test.py
5140

52-
# Validate the extracted graph (e.g. /home/yourname/graphnet_workspace/resnet18)
41+
# Validate the extracted graph (e.g. /home/yourname/graphnet_workspace/resnet18/)
5342
python -m graph_net.torch.validate \
54-
--model-path $GRAPH_NET_EXTRACT_WORKSPACE/resnet18
43+
--model-path $GRAPH_NET_EXTRACT_WORKSPACE/resnet18/
5544
```
5645

57-
**graph_net.torch.extract**
46+
**Illustration: How does GraphNet extract and construct a computation graph sample on PyTorch?**
5847

59-
```python
48+
<div align="center">
49+
<img src="/pics/graphnet_sample.png" alt="GraphNet Extract Sample" width="65%">
50+
</div>
51+
52+
* Source code of custom_op is required **only when** corresponding operator is used in the module, and **no specific format** is required.
53+
54+
**Step 1: graph_net.torch.extract**
55+
56+
Import and wrap the model with `graph_net.torch.extract(name=model_name, dynamic=dynamic_mode)()` is all you need:
57+
58+
```bash
6059
import graph_net
6160

6261
# Instantiate the model (e.g. a torchvision model)
6362
model = ...
6463

6564
# Extract your own model
66-
model = graph_net.torch.extract(name="model_name")(model)
67-
68-
# After running, the extracted graph will be saved to:
69-
# $GRAPH_NET_EXTRACT_WORKSPACE/model_name
65+
model = graph_net.torch.extract(name="model_name", dynamic="True")(model)
7066
```
7167

72-
**graph_net.torch.validate**
73-
```
74-
# Verify that the extracted model meets requirements
68+
After running, the extracted graph will be saved to: `$GRAPH_NET_EXTRACT_WORKSPACE/model_name/`.
69+
70+
For more details, see docstring of `graph_net.torch.extract` defined in `graph_net/torch/extractor.py`.
71+
72+
**Step 2: graph_net.torch.validate**
73+
74+
To verify that the extracted model meets requirements, we use `graph_net.torch.validate` in CI tool and also ask contributors to self-check in advance:
75+
76+
```bash
7577
python -m graph_net.torch.validate \
7678
--model-path $GRAPH_NET_EXTRACT_WORKSPACE/model_name
7779
```
7880

79-
**graph_net.pack**
80-
```
81-
# Create a ZIP archive of $GRAPH_NET_EXTRACT_WORKSPACE.
82-
# The --clear-after-pack flag (True|False) determines whether to delete the workspace after packing.
83-
python -m graph_net.pack \
84-
--output /path/to/output.zip \
85-
--clear-after-pack True
81+
All the **construction constraints** will be examined automatically. After passing validation, a unique `graph_hash.txt` will be generated and later checked in CI procedure to avoid redundant.
82+
83+
## ⚖️ Compiler Evaluation
84+
85+
**Step 1: Benchmark**
86+
87+
We use `graph_net.torch.test_compiler` to benchmark GraphNet samples with specific batch and log configurations:
88+
89+
```bash
90+
# Set your benchmark directory
91+
export GRAPH_NET_BENCHMARK_PATH=/home/yourname/graphnet_benchmark/
92+
93+
# Run benchmark
94+
python -m graph_net.torch.test_compiler \
95+
--model-path $GRAPH_NET_EXTRACT_WORKSPACE/model_name/ \
96+
--compiler /custom/or/builtin/compiler/ \
97+
--device /device/to/execute/ \
98+
--warmup /times/to/warmup/ \
99+
--trials /times/to/test/ \
100+
> $GRAPH_NET_BENCHMARK_PATH/log.log 2>&1
101+
102+
# Note: if --compiler is omitted, PyTorch’s built-in compiler is used by default
86103
```
87104

88-
Note: To configure your user details (username and email) for GraphNet, run:
105+
After executing, `graph_net.torch.test_compiler` will:
106+
1. Running the original model in eager mode to record a baseline.
107+
2. Compiling the model with the specified backend (e.g., CINN, TVM, Inductor, TensorRT, XLA, BladeDISC).
108+
3. Executing the compiled model and collecting its runtime and outputs.
109+
4. Conduct speedup by comparing the compiled results against the baseline (if no execution failure occurs).
110+
111+
**Step 2: Generate JSON Record**
112+
113+
This step is to extract information (including failure) from logs in benchmark.
114+
All the information will be saved to multiple `model_compiler.json` files via:
115+
116+
```bash
117+
python -m graph_net.torch.log2json \
118+
--log-file $GRAPH_NET_BENCHMARK_PATH/log.log \
119+
--output-dir $GRAPH_NET_BENCHMARK_PATH
89120
```
90-
python -m graph_net.config --global \
91-
--username "your-name" \
92-
--email "your-email"
121+
122+
**Step 3: Analysis**
123+
124+
After processing, we provide `graph_net/analysis.py` to generate [violin plot](https://en.m.wikipedia.org/wiki/Violin_plot) based on the JSON results.
125+
126+
```bash
127+
python -m graph_net.analysis \
128+
--benchmark-path /path/to/read/JSON/result/file/ \
129+
--output-dir /path/to/save/output/figures/
93130
```
94-
Once you have packaged these extracted computation graphs, submit them to the GraphNet community via the following group chats.
95131

132+
After executing, one summary plot of results on all compilers, as well as multiple sub-plots of results in categories (model tasks, Library...) on a single compiler will be exported.
133+
134+
The script is designed to process a file structure as `/benchmark_path/compiler_name/category_name/` (for example `/benchmark_logs/paddle/nlp/`), and items on x-axis are identified by name of the folders. So you can modify `read_all_speedups` function to fit the benchmark settings on your demand.
135+
136+
## 📌 Roadmap
137+
138+
1. Scale GraphNet to 10K+ graphs.
139+
2. Further annotate GraphNet samples into more granular sub-categories
140+
3. Extract samples from multi-GPU scenarios to support benchmarking and optimization for large-scale, distributed computing.
141+
4. Enable splitting full graphs into independently optimized subgraphs and operator sequences.
142+
143+
**Vision**: GraphNet aims to lay the foundation for AI for Compiler by enabling **large-scale, systematic evaluation** of tensor compiler optimizations, and providing a **dataset for models to learn** and transfer optimization strategies.
144+
145+
## 💬 GraphNet Community
146+
147+
You can join our community via following group chats. Welcome to ask any questions about using and building GraphNet.
96148

97149
<div align="center">
98150
<table>
99151
<tr>
100152
<td align="center">
101-
<img width="200" src="https://github.com/user-attachments/assets/3ea4794b-1aed-4096-bd1c-3184832b98f3" />
153+
<img width="200" src="https://github.com/user-attachments/assets/125e3494-25c9-4494-9acd-8ad65ca85d03" />
102154
</td>
103155
<td align="center">
104156
<img width="150" src="https://cdn.prod.website-files.com/6257adef93867e50d84d30e2/67d00cf7266d2c75571aebde_Example.svg" />
105-
<p><a href="https://discord.gg/FCZQVCkC">Channel</a> is also available.</p>
157+
<p><a href="https://discord.gg/vyeAydwh">Channel</a> is also available.</p>
106158
</td>
107159
</tr>
108160
</table>
109161
</div>
110162

111-
112-
## License
163+
## 🪪 License
113164
This project is released under the [MIT License](LICENSE).
114-

README_cn.md

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)