YummyYum commited on
Commit
10de125
·
verified ·
1 Parent(s): c49a571

Upload folder using huggingface_hub

Browse files
Files changed (8) hide show
  1. .msc +0 -0
  2. .mv +1 -0
  3. README.md +142 -0
  4. config.json +85 -0
  5. configuration.json +1 -0
  6. model.safetensors +3 -0
  7. policy_postprocessor.json +31 -0
  8. policy_preprocessor.json +86 -0
.msc ADDED
Binary file (458 Bytes). View file
 
.mv ADDED
@@ -0,0 +1 @@
 
 
1
+ Revision:master,CreatedAt:1758283512
README.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Introduction
2
+
3
+ **FlagOS** is a unified heterogeneous computing software stack for large models, co-developed with leading global chip manufacturers. With core technologies such as the **FlagScale** distributed training/inference framework, **FlagGems** universal operator library, **FlagCX** communication library, and **FlagTree** unified compiler, the **FlagRelease** platform leverages the FlagOS stack to automatically produce and release various combinations of <chip + open-source model>. This enables efficient and automated model migration across diverse chips, opening a new chapter for large model deployment and application.
4
+
5
+ Based on this, the **pi0-FlagOS** model is adapted for the Nvidia chip using the FlagOS software stack, enabling:
6
+
7
+ ### Integrated Deployment
8
+
9
+ - Deep integration with the open-source [FlagScale framework](https://github.com/FlagOpen/FlagScale)
10
+ - Out-of-the-box inference scripts with pre-configured hardware and software parameters
11
+ - Released **FlagOS** container image supporting deployment within minutes
12
+
13
+ ### Consistency Validation
14
+
15
+ - Rigorously evaluated through benchmark testing: Performance and results from the FlagOS software stack are compared against native stacks on multiple public.
16
+
17
+ # Technical Overview
18
+
19
+ ## **FlagScale Distributed Training and Inference Framework**
20
+
21
+ FlagScale is an end-to-end framework for large models across heterogeneous computing resources, maximizing computational efficiency and ensuring model validity through core technologies. Its key advantages include:
22
+
23
+ - **Unified Deployment Interface:** Standardized command-line tools support one-click service deployment across multiple hardware platforms, significantly reducing adaptation costs in heterogeneous environments.
24
+ - **Intelligent Parallel Optimization:** Automatically generates optimal distributed parallel strategies based on chip computing characteristics, achieving dynamic load balancing of computation/communication resources.
25
+ - **Seamless Operator Switching:** Deep integration with the FlagGems operator library allows high-performance operators to be invoked via environment variables without modifying model code.
26
+
27
+ ## **FlagGems Universal Large-Model Operator Library**
28
+
29
+ FlagGems is a Triton-based, cross-architecture operator library collaboratively developed with industry partners. Its core strengths include:
30
+
31
+ - **Full-stack Coverage**: Over 100 operators, with a broader range of operator types than competing libraries.
32
+ - **Ecosystem Compatibility**: Supports 7 accelerator backends. Ongoing optimizations have significantly improved performance.
33
+ - **High Efficiency**: Employs unique code generation and runtime optimization techniques for faster secondary development and better runtime performance compared to alternatives.
34
+
35
+ ## **FlagEval Evaluation Framework**
36
+
37
+ FlagEval (Libra)** is a comprehensive evaluation system and open platform for large models launched in 2023. It aims to establish scientific, fair, and open benchmarks, methodologies, and tools to help researchers assess model and training algorithm performance. It features:
38
+ - **Multi-dimensional Evaluation**: Supports 800+ model evaluations across NLP, CV, Audio, and Multimodal fields, covering 20+ downstream tasks including language understanding and image-text generation.
39
+ - **Industry-Grade Use Cases**: Has completed horizontal evaluations of mainstream large models, providing authoritative benchmarks for chip-model performance validation.
40
+
41
+ # Evaluation Results
42
+
43
+ Unlike other models, we use the MAPE (Mean Absolute Percentage Error) of the action tensor to evaluate whether the FlagOS version of the model computes correctly. To achieve this, we built upon the standard usage of the Pi0 model while controlling the random seeds of the random, numpy, and torch libraries, and configured PyTorch to use deterministic GPU kernels. Additionally, before each inference step, we replaced the randomly generated noise tensor with a fixed tensor. In the subsequent usage section, we will provide detailed instructions on how to restore these randomized settings for normal Pi0 model operation.
44
+ The MAPE between CUDA and FlagOS(CUDA as ground truth) is 1.4152%. You can easily reproduce this result using our image.
45
+
46
+ # User Guide
47
+
48
+ **Environment Setup**
49
+
50
+ | Item | Version |
51
+ | ------------- | ------------------------------------------------------------ |
52
+ | Docker Version | Docker version 28.1.0, build 4d8c241 |
53
+ | Operating System | Ubuntu 22.04.5 LTS |
54
+ | FlagScale | Version: 0.8.0 |
55
+ | FlagGems | Version: 3.0 |
56
+
57
+ ## Operation Steps
58
+
59
+ ### Download Open-source Model Weights
60
+
61
+ We have already download pi0 and its tokenizer's weights into /workspace in docker image. You don't need to download it again. If you really want to download it, you can run:
62
+
63
+ ```bash
64
+ pip install modelscope
65
+ modelscope download --model lerobot/pi0 --local_dir /workspace/pi0
66
+ modelscope download --model google/paligemma-3b-pt-224 --local_dir /workspace/paligemma-3b-pt-224
67
+
68
+ ```
69
+
70
+ ### Download FlagOS Image
71
+
72
+ ```bash
73
+ docker pull harbor.baai.ac.cn/flagrelease-public/flagrelease_nvidia_pi0_norand
74
+ ```
75
+
76
+ ### Start the inference service
77
+
78
+ ```bash
79
+ #Container Startup
80
+ docker run --rm --init --detach --net=host --uts=host --ipc=host --security-opt=seccomp=unconfined --privileged=true --ulimit stack=67108864 --ulimit memlock=-1 --ulimit nofile=1048576:1048576 --shm-size=32G -v /share:/share --gpus all --name flagos harbor.baai.ac.cn/flagrelease-public/flagrelease_nvidia_pi0_norand sleep infinity
81
+ ```
82
+
83
+ ### Serve
84
+
85
+ ```bash
86
+ docker exec -it flagos bash
87
+ cd /workspace/FlagScale
88
+ python run.py --config-path ./examples/pi0/conf --config-name train action=run
89
+ ```
90
+
91
+ ### Call the server
92
+
93
+ ```bash
94
+ docker exec -it flagos bash
95
+ cd /workspace/FlagScale
96
+ python examples/pi0/client_pi0.py \
97
+ --host 127.0.0.1 \
98
+ --port 9010 \
99
+ --base-img orbbec_0_latest.jpg \
100
+ --left-wrist-img orbbec_1_latest.jpg \
101
+ --right-wrist-img orbbec_2_latest.jpg \
102
+ --num-steps 20
103
+ ```
104
+
105
+ ### Validate the MAPE
106
+
107
+ If you want to validate the MAPE between CUDA and FlagOS, you can:
108
+ 1. Restart the container
109
+ 2. Find /workspace/FlagScale/flagscale/models/pi0/modeling_pi0.py
110
+ 3. Use Vim or other editor, comment all lines include "flag_gems"
111
+ , then you get pi0-CUDA enviroment. Repeat "Serve" and "Call the server", then you get action tensor from CUDA and FlagOS.
112
+
113
+ ### Eliminate the no-rand constrain
114
+
115
+ 1. Find /workspace/FlagScale/flagscale/models/pi0/modeling_pi0.py
116
+ 2. Comment line below:
117
+ ```python
118
+ random.seed(42)
119
+ np.random.seed(42)
120
+ torch.manual_seed(42)
121
+ torch.cuda.manual_seed(42)
122
+ torch.cuda.manual_seed_all(42)
123
+ torch.backends.cudnn.deterministic = True
124
+ torch.backends.cudnn.benchmark = False
125
+ ```
126
+ 3. Restart the container and then Repeat "Serve" and "Call the server".
127
+
128
+
129
+ # Contributing
130
+
131
+ We warmly welcome global developers to join us:
132
+
133
+ 1. Submit Issues to report problems
134
+ 2. Create Pull Requests to contribute code
135
+ 3. Improve technical documentation
136
+ 4. Expand hardware adaptation support
137
+
138
+
139
+ # License
140
+
141
+ 本模型的权重来源于lerobot/pi0,以apache2.0协议https://www.apache.org/licenses/LICENSE-2.0.txt开源。
142
+
config.json ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "pi0",
3
+ "n_obs_steps": 1,
4
+ "input_features": {
5
+ "observation.state": {
6
+ "type": "STATE",
7
+ "shape": [
8
+ 6
9
+ ]
10
+ },
11
+ "observation.images.camera0": {
12
+ "type": "VISUAL",
13
+ "shape": [
14
+ 3,
15
+ 480,
16
+ 640
17
+ ]
18
+ },
19
+ "observation.images.camera1": {
20
+ "type": "VISUAL",
21
+ "shape": [
22
+ 3,
23
+ 480,
24
+ 640
25
+ ]
26
+ },
27
+ "observation.images.camera2": {
28
+ "type": "VISUAL",
29
+ "shape": [
30
+ 3,
31
+ 480,
32
+ 640
33
+ ]
34
+ }
35
+ },
36
+ "output_features": {
37
+ "action": {
38
+ "type": "ACTION",
39
+ "shape": [
40
+ 6
41
+ ]
42
+ }
43
+ },
44
+ "device": "cpu",
45
+ "use_amp": false,
46
+ "push_to_hub": true,
47
+ "repo_id": null,
48
+ "private": null,
49
+ "tags": null,
50
+ "license": null,
51
+ "chunk_size": 50,
52
+ "n_action_steps": 50,
53
+ "normalization_mapping": {
54
+ "VISUAL": "IDENTITY",
55
+ "STATE": "MEAN_STD",
56
+ "ACTION": "MEAN_STD"
57
+ },
58
+ "max_state_dim": 32,
59
+ "max_action_dim": 32,
60
+ "resize_imgs_with_padding": [
61
+ 224,
62
+ 224
63
+ ],
64
+ "empty_cameras": 0,
65
+ "adapt_to_pi_aloha": false,
66
+ "use_delta_joint_actions_aloha": false,
67
+ "tokenizer_max_length": 48,
68
+ "proj_width": 1024,
69
+ "num_steps": 10,
70
+ "use_cache": true,
71
+ "attention_implementation": "eager",
72
+ "freeze_vision_encoder": true,
73
+ "train_expert_only": false,
74
+ "train_state_proj": true,
75
+ "optimizer_lr": 2.5e-05,
76
+ "optimizer_betas": [
77
+ 0.9,
78
+ 0.95
79
+ ],
80
+ "optimizer_eps": 1e-08,
81
+ "optimizer_weight_decay": 1e-10,
82
+ "scheduler_warmup_steps": 1000,
83
+ "scheduler_decay_steps": 30000,
84
+ "scheduler_decay_lr": 2.5e-06
85
+ }
configuration.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"framework": "pytorch", "task": "robotics", "allow_remote": true}
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1bbcefd55bab3ddff07ead42f4773505f07c68c9694ae44d636d86733dfebc1
3
+ size 14005623256
policy_postprocessor.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "policy_postprocessor",
3
+ "steps": [
4
+ {
5
+ "registry_name": "unnormalizer_processor",
6
+ "config": {
7
+ "eps": 1e-08,
8
+ "features": {
9
+ "action": {
10
+ "type": "ACTION",
11
+ "shape": [
12
+ 6
13
+ ]
14
+ }
15
+ },
16
+ "norm_map": {
17
+ "VISUAL": "IDENTITY",
18
+ "STATE": "MEAN_STD",
19
+ "ACTION": "MEAN_STD"
20
+ }
21
+ }
22
+ },
23
+ {
24
+ "registry_name": "device_processor",
25
+ "config": {
26
+ "device": "cpu",
27
+ "float_dtype": null
28
+ }
29
+ }
30
+ ]
31
+ }
policy_preprocessor.json ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "policy_preprocessor",
3
+ "steps": [
4
+ {
5
+ "registry_name": "rename_observations_processor",
6
+ "config": {
7
+ "rename_map": {}
8
+ }
9
+ },
10
+ {
11
+ "registry_name": "to_batch_processor",
12
+ "config": {}
13
+ },
14
+ {
15
+ "registry_name": "pi0_new_line_processor",
16
+ "config": {}
17
+ },
18
+ {
19
+ "registry_name": "tokenizer_processor",
20
+ "config": {
21
+ "max_length": 48,
22
+ "task_key": "task",
23
+ "padding_side": "right",
24
+ "padding": "max_length",
25
+ "truncation": true,
26
+ "tokenizer_name": "google/paligemma-3b-pt-224"
27
+ }
28
+ },
29
+ {
30
+ "registry_name": "device_processor",
31
+ "config": {
32
+ "device": "cpu",
33
+ "float_dtype": null
34
+ }
35
+ },
36
+ {
37
+ "registry_name": "normalizer_processor",
38
+ "config": {
39
+ "eps": 1e-08,
40
+ "features": {
41
+ "observation.state": {
42
+ "type": "STATE",
43
+ "shape": [
44
+ 6
45
+ ]
46
+ },
47
+ "observation.images.camera0": {
48
+ "type": "VISUAL",
49
+ "shape": [
50
+ 3,
51
+ 480,
52
+ 640
53
+ ]
54
+ },
55
+ "observation.images.camera1": {
56
+ "type": "VISUAL",
57
+ "shape": [
58
+ 3,
59
+ 480,
60
+ 640
61
+ ]
62
+ },
63
+ "observation.images.camera2": {
64
+ "type": "VISUAL",
65
+ "shape": [
66
+ 3,
67
+ 480,
68
+ 640
69
+ ]
70
+ },
71
+ "action": {
72
+ "type": "ACTION",
73
+ "shape": [
74
+ 6
75
+ ]
76
+ }
77
+ },
78
+ "norm_map": {
79
+ "VISUAL": "IDENTITY",
80
+ "STATE": "MEAN_STD",
81
+ "ACTION": "MEAN_STD"
82
+ }
83
+ }
84
+ }
85
+ ]
86
+ }