Customize
VLA
Vision-Language-Action(VLA)model 接受图像和语言指令作为输入,输出机器人动作。MinT 通过两条路径支持 OpenPI 兼容的 VLA 训练:用 Python SDK 比较省事,或者直接走 HTTP 与非 Python 系统集成。
参考实现是 demos/embodied/openpi_vla_sdk.py(SDK)和 demos/embodied/openpi_vla_http.py(HTTP)。
Configuration
Python 流程里推荐用 SDK:
import mint
import mint.mint as mintx
service_client = mint.ServiceClient()
training_client = mintx.create_openpi_training_client(
service_client,
base_model=mintx.OPENPI_FAST_MODEL,
rank=mintx.OPENPI_FAST_LORA_RANK, # 默认 16
create_timeout_seconds=1200.0,
user_metadata={"example": "vla-training"},
)
info = training_client.get_info()
print(f"Model: {info.model_name}, LoRA rank: {info.lora_rank}")环境变量:
export MINT_API_KEY=sk-your-key
export MINT_BASE_URL=https://mint.macaron.xin/
export MINT_OPENPI_SDK_BASE_MODEL="openpi/pi0-fast-libero-low-mem-finetune"
export MINT_OPENPI_SDK_LORA_RANK=16
export MINT_OPENPI_SDK_LR=0.003HTTP 路径绕开 SDK,通过 HTTPS 直接发原始 JSON。给非 Python 客户端或集成测试用:
curl -X POST https://mint.macaron.xin/api/v1/sessions/create \
-H "Authorization: Bearer $MINT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"tags": ["vla-training"], "type": "create_session"}'返回里包含 session_id。然后创建 model:
curl -X POST https://mint.macaron.xin/api/v1/models/create \
-H "Authorization: Bearer $MINT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "...",
"base_model": "openpi/pi0-fast-libero-low-mem-finetune",
"lora_config": {"rank": 16, "train_attn": true, "train_mlp": true, "train_unembed": true}
}'完整的 wire protocol 和请求构造器见 demos/embodied/openpi_vla_http.py。
Prompting Guide
VLA 的 prompt 包含三种模态:图像、状态和语言。规范结构:
from mint.mint import build_openpi_fast_datum, CAMERA_LAYOUT
# 来自三个固定摄像头的图像
images: dict[str, bytes] = {
"base_0_rgb": load_png("base_cam.png"),
"left_wrist_0_rgb": load_png("left_cam.png"),
"right_wrist_0_rgb": load_png("right_cam.png"),
}
# 状态向量(本体感觉)
state = [0.1, -0.2, 0.05, ...] # 关节角度、夹爪位置等
# 动作 token(model 要生成的)
target_tokens = [42, 43, 44, ...] # 动作量化
# 构造 datum
datum = build_openpi_fast_datum(
prefix_tokens=[], # 可选的 instruction token
image_bytes_by_camera=images,
state=state,
target_tokens=target_tokens,
weights=[1.0] * len(target_tokens), # 所有动作都参与训练
token_ar_mask=[1] * len(target_tokens), # 自回归 mask
)关键字段:
- Images: 三路固定摄像头视角(base、左腕、右腕),RGB PNG 格式。
- State: 机器人本体感觉(关节角度、夹爪状态、末端执行器姿态)。
- Actions: 量化成 token ID。Model 预测动作序列里的下一个 token。
- token_ar_mask: 自回归解码 mask(1 = 生成这个 token,0 = 跳过)。
Output Format
VLA model 输出的是动作 token,需要反量化回连续控制信号。对 OpenPI FAST:
- Token 形状:
[seq_len]— 每个时间步一个 token。 - Token 取值范围: 0–511(每个维度 8 bit 量化,2 个维度 = 每步 2 个 token)。
- 反量化: token i → 连续值 = (i / 256) - 1.0,再 rescale 到机器人动作范围。
训练循环对动作预测算 loss:
result = training_client.train_step(
[datum],
loss_fn="cross_entropy",
adam_params=types.AdamParams(learning_rate=0.003),
).result()
print(f"Loss: {result.metrics.get('loss')}")训练完保存权重再采样:
sampler = training_client.save_weights_for_sampler(
name="vla-checkpoint-1",
ttl_seconds=3600,
).result()
# 用 sampler 做推理(MinT 这边目前还没文档化)All Parameters
| 参数 | 类型 | 默认值 | 含义 |
|---|---|---|---|
base_model | str | "openpi/pi0-fast-libero-low-mem-finetune" | OpenPI model 变体。FAST = 轻量,~0.6B 参数。 |
rank | int | 16 | LoRA rank。VLA 一般取 8–32。 |
train_mlp | bool | True | 训练 MLP 层。 |
train_attn | bool | True | 训练 attention 层。 |
train_unembed | bool | True | 训练输出层(action head)。 |
learning_rate | float | 0.003 | Adam 学习率。VLA:1e-4 到 1e-2,比 language model 高。 |
max_frames | int | 10 | 每个 batch 的最大帧数(图像数)。VLA:1–32。 |
action_dim | int | 2 | 动作维度。默认 = (dx, dy),给夹爪用。 |
quantization_levels | int | 256 | 每个动作维度的量化级数(例如 256 = 8 bit)。 |
create_timeout_seconds | float | 1200.0 | session / model 创建超时。 |
step_timeout_seconds | float | 1200.0 | 单个 training step 超时。 |
SDK 专属(环境变量):
export MINT_OPENPI_SDK_BASE_MODEL="..."
export MINT_OPENPI_SDK_LORA_RANK=16
export MINT_OPENPI_SDK_LR=0.003
export MINT_OPENPI_SDK_CREATE_TIMEOUT_SECONDS=1200
export MINT_OPENPI_SDK_STEP_TIMEOUT_SECONDS=1200HTTP 专属(wire protocol):
create_session:初始化训练 session。create_model:在 session 内分配 LoRA。train_step:提交数据,拿回 loss / metrics。save_weights_for_sampler:导出权重供推理。delete_model:清理。
完整 JSON schema 见 openpi_vla_http.py。
状态: MinT 的 VLA 支持还在演进。OpenPI FAST 是为低延迟机器人控制优化的 model。更高维度的任务(完整 manipulation)可能会在后续版本里发布更大的 model 变体。