ZibinDong commited on
Commit
eae75a9
·
verified ·
1 Parent(s): 85fb22c

Document consolidated tokenizer and inference package

Browse files
Files changed (1) hide show
  1. README.md +128 -0
README.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ tags:
5
+ - robotics
6
+ - action-tokenization
7
+ - actioncodec2
8
+ ---
9
+
10
+ # ActionCodec2
11
+
12
+ 30 tokenizer variants share one runtime and one optional native extension.
13
+ Select a published variant explicitly; its configuration and fitted assets are loaded together.
14
+
15
+ ```bash
16
+ pip install numpy scipy torch "transformers>=4.57,<6" huggingface-hub pyyaml
17
+ ```
18
+
19
+ ```python
20
+ import numpy as np
21
+ from transformers import AutoProcessor
22
+
23
+ codec = AutoProcessor.from_pretrained(
24
+ "ZibinDong/ActionCodec2", variant="paper-1st", trust_remote_code=True,
25
+ # revision="<commit>",
26
+ )
27
+ actions = np.zeros((12, 7), dtype=np.float32)
28
+ tokens = codec.encode(actions, fps=15)
29
+ decoded = codec.decode(tokens, fps=15)
30
+ codec.save_pretrained("./saved-tokenizer")
31
+ restored = AutoProcessor.from_pretrained(
32
+ "./saved-tokenizer", trust_remote_code=True, local_files_only=True,
33
+ )
34
+ ```
35
+
36
+ The default action space is `single_eef_delta`: translation increments in metres,
37
+ body-frame rotation-vector increments in radians, and an absolute binary gripper command.
38
+ Rotation follows `R_next = R_previous @ Exp(rotvec)`; the gripper opens at values >= 0.8.
39
+ Pass the actual recording rate as `fps`; the tokenizer resamples to 15 Hz.
40
+ Inputs have shape `(T, D)` or `(B, T, D)`; decoded CPU float32 tensors have shape `(B, T_out, D)`.
41
+ Resampling may change the length. Quantization is lossy.
42
+
43
+ Second-order variants require the preceding first-order motion at every chunk boundary:
44
+
45
+ ```python
46
+ codec = AutoProcessor.from_pretrained(
47
+ "ZibinDong/ActionCodec2", variant="paper-2nd", trust_remote_code=True,
48
+ )
49
+ # Use a zero template only when the preceding motion is known to be zero.
50
+ boundary = codec.first_order_template(batch_size=1)
51
+ tokens = codec.encode(actions, fps=15, previous_first_order=boundary)
52
+ decoded = codec.decode(tokens, fps=15, previous_first_order=boundary)
53
+ boundary = codec.final_first_order(tokens, previous_first_order=boundary, executed_steps=None)
54
+ ```
55
+
56
+ For partially executed chunks, set `executed_steps` to the executed step count.
57
+ Use `codec.for_action_space("single_joint7_delta")` or another registered layout to change
58
+ the physical input convention. Absolute layouts require `current_state` for reconstruction.
59
+ The 1mm/2k variants contain EEF profiles only.
60
+
61
+ | Variant | Order | Precision | Budget per profile | Profiles |
62
+ | --- | --- | --- | --- | --- |
63
+ | `paper-1st` | 1 | Paper | 4096 | joint, eef |
64
+ | `paper-2nd` | 2 | Paper | 4096 | joint, eef |
65
+ | `extended-1st-1mm-2k` | 1 | 1mm | 2048 | eef |
66
+ | `extended-1st-1mm-4k` | 1 | 1mm | 4096 | joint, eef |
67
+ | `extended-1st-1mm-8k` | 1 | 1mm | 8192 | joint, eef |
68
+ | `extended-1st-1mm-16k` | 1 | 1mm | 16384 | joint, eef |
69
+ | `extended-1st-5mm-1k` | 1 | 5mm | 1024 | joint, eef |
70
+ | `extended-1st-5mm-2k` | 1 | 5mm | 2048 | joint, eef |
71
+ | `extended-1st-5mm-4k` | 1 | 5mm | 4096 | joint, eef |
72
+ | `extended-1st-5mm-8k` | 1 | 5mm | 8192 | joint, eef |
73
+ | `extended-1st-5mm-16k` | 1 | 5mm | 16384 | joint, eef |
74
+ | `extended-1st-10mm-1k` | 1 | 10mm | 1024 | joint, eef |
75
+ | `extended-1st-10mm-2k` | 1 | 10mm | 2048 | joint, eef |
76
+ | `extended-1st-10mm-4k` | 1 | 10mm | 4096 | joint, eef |
77
+ | `extended-1st-10mm-8k` | 1 | 10mm | 8192 | joint, eef |
78
+ | `extended-1st-10mm-16k` | 1 | 10mm | 16384 | joint, eef |
79
+ | `extended-2nd-1mm-2k` | 2 | 1mm | 2048 | eef |
80
+ | `extended-2nd-1mm-4k` | 2 | 1mm | 4096 | joint, eef |
81
+ | `extended-2nd-1mm-8k` | 2 | 1mm | 8192 | joint, eef |
82
+ | `extended-2nd-1mm-16k` | 2 | 1mm | 16384 | joint, eef |
83
+ | `extended-2nd-5mm-1k` | 2 | 5mm | 1024 | joint, eef |
84
+ | `extended-2nd-5mm-2k` | 2 | 5mm | 2048 | joint, eef |
85
+ | `extended-2nd-5mm-4k` | 2 | 5mm | 4096 | joint, eef |
86
+ | `extended-2nd-5mm-8k` | 2 | 5mm | 8192 | joint, eef |
87
+ | `extended-2nd-5mm-16k` | 2 | 5mm | 16384 | joint, eef |
88
+ | `extended-2nd-10mm-1k` | 2 | 10mm | 1024 | joint, eef |
89
+ | `extended-2nd-10mm-2k` | 2 | 10mm | 2048 | joint, eef |
90
+ | `extended-2nd-10mm-4k` | 2 | 10mm | 4096 | joint, eef |
91
+ | `extended-2nd-10mm-8k` | 2 | 10mm | 8192 | joint, eef |
92
+ | `extended-2nd-10mm-16k` | 2 | 10mm | 16384 | joint, eef |
93
+
94
+ Joint and EEF token IDs occupy disjoint namespaces. Precision tiers describe physical
95
+ quantization settings. A trained policy must use its original tokenizer variant.
96
+ Pin `revision` to a commit for reproducibility; `variants.json` records each variant's
97
+ asset hashes and its previous repository ID. Loading downloads shared files plus the
98
+ selected variant, and verifies its assets. `subfolder` is not a variant selector.
99
+
100
+ Saved processors contain only the selected assets and the complete portable runtime.
101
+ They load offline and preserve `artifact_manifest.json` with their asset hashes and origin.
102
+ Select a different variant by loading the catalog again.
103
+
104
+ Build the optional C++17 kernels once for all variants:
105
+
106
+ ```bash
107
+ hf download ZibinDong/ActionCodec2 --include "setup.py" "pyproject.toml" "LICENSE" "actioncodec2_kernels/*" --local-dir ./actioncodec2-kernels
108
+ pip install ./actioncodec2-kernels
109
+ ```
110
+
111
+ `ACTIONCODEC2_NUM_THREADS` controls the per-process thread budget.
112
+ `ACTIONCODEC2_NO_NATIVE=1` selects the Python reference implementation.
113
+
114
+ ## VLA inference package
115
+
116
+ The verified source archive `actioncodec2-0.1.0.tar.gz` is included in this repository.
117
+ It contains the policy inference code, native kernels, training recipes, and evaluation scripts.
118
+ With a C++17 compiler available, install the version used to validate the six released policies:
119
+
120
+ ```bash
121
+ pip install "actioncodec2[cuda] @ https://hf-mirror.com/ZibinDong/ActionCodec2/resolve/v0.1.0/actioncodec2-0.1.0.tar.gz"
122
+ ```
123
+
124
+ Each policy includes its selected AC2 assets and text tokenizer. After downloading the
125
+ complete policy, inference works offline without the base-model or another tokenizer repository.
126
+
127
+ The tokenizer runtime and fitted assets use Apache-2.0. The source archive also contains
128
+ G0.5 components under `LICENSE-G0.5`; see the archive's license files and `NOTICE`.