FSDS SOTA 2026 DSAI + EDAI Textbook
T1-P7-U02 • PRODUCTION LAB GUIDE ~3 phút đọc

Lab 17 — Flow Matching vs. Diffusion Action Policy, Cross-Embodiment VLAs & Sim-to-Real Ablations

Hướng dẫn thực hành, cài đặt môi trường .venv/uv và tiêu chuẩn kiểm định pytest.

Học phần: T1-P7-U02 · Chương 29 — Robotics: Diffusion vs. Flow Matching, Generalist VLAs & Sim-to-Real · Part 7

Cấu trúc 2 tầng: Thư viện PyTorch CPU kiểm thử nghiêm ngặt (src/robotics_action_policy_lab/) + CLI sinh artifact chuẩn hóa (scripts/run_lab_demo.py -> artifacts/ch29_lab17_results.json).


1. Hướng dẫn Cài đặt & Chạy Nhanh (uv)#

Thư mục lab sử dụng chỉ mục pytorch-cpu cố định trong pyproject.toml và lockfile uv.lock (34 gói khóa phiên bản, Python >=3.12).

powershell13 dòng
# Di chuyển vào thư mục Lab 17
Set-Location D:\FSDS-SOTA-Curriculum\02-track-1-data-science-and-ai\part-07-frontier-world-models-robotics\labs\lab-17-flow-matching-vs-diffusion-action-policy

# Kiểm tra lockfile (hoặc đồng bộ với uv sync)
uv lock --check

# Chạy benchmark đầy đủ (seed=42) và ghi artifacts/ch29_lab17_results.json
uv run --no-sync python scripts/run_lab_demo.py --seed 42

# Chạy kiểm định tĩnh + pytest (chế độ quick ghi ra file tạm trong pytest)
uv run --no-sync ruff check src scripts tests
uv run --no-sync mypy src scripts tests
uv run --no-sync pytest -p no:cacheprovider -v

Nếu dùng môi trường .venv chung tại gốc repo:

powershell3 dòng
$env:PYTHONPATH = "src"
D:\FSDS-SOTA-Curriculum\.venv\Scripts\python.exe scripts\run_lab_demo.py --seed 42 --quick --output $env:TEMP\lab17_quick.json
D:\FSDS-SOTA-Curriculum\.venv\Scripts\pytest.exe -p no:cacheprovider -v

2. Cấu trúc Dự án#

text14 dòng
lab-17-flow-matching-vs-diffusion-action-policy/
├── artifacts/
│   └── ch29_lab17_results.json          # Kết quả thực nghiệm verified (seed=42, quick=false)
├── scripts/
│   └── run_lab_demo.py                  # CLI chạy 3 thí nghiệm + xuất workbench_panels (6 KPI, 4 Bar, 4 Table)
├── src/robotics_action_policy_lab/
│   ├── __init__.py                      # Public API exports
│   ├── diffusion_vs_flow.py             # Exp 1: MSE vs v-pred DDIM vs Rectified Flow (CFM) + OTel exporter
│   └── vla_and_sim2real.py              # Exp 2 (Cross-Embodiment 2-DoF->3-DoF) & Exp 3 (4-Axis Sim-to-Real)
├── tests/
│   └── test_robotics_action_policy_lab.py # 22 pytest + Hypothesis + AST security + schema + OTel tests
├── pyproject.toml                       # Strict ruff, strict mypy, pytorch-cpu index pinning
├── uv.lock                              # Lockfile deterministic (34 packages)
└── README.md

3. Bảng Số liệu Thực nghiệm Verified (seed=42, quick=false)#

Tất cả các số liệu dưới đây được trích xuất trực tiếp từ artifacts/ch29_lab17_results.json (chạy trên PyTorch CPU seed=42):

Thí nghiệm 1 — Đa thức Hành động (Multimodal Obstacle Avoidance, \(H_a=8, H_e=4\))#

Chính sách (Policy & NFE) Success / Collision Mode Entropy / Jerk Độ trễ (ms/chunk) & Tần số (Hz)
Deterministic MSE (NFE=1) 0.0% / 100.0% 0.00 bits / 0.294 0.29 ms (13,962 Hz)
DDIM Diffusion (NFE=4) 82.5% / 17.5% 1.00 bits / 0.340 1.20 ms (3,329 Hz)
Flow Matching CFM (NFE=4) 97.5% / 2.5% 0.99 bits / 0.607 1.03 ms (3,894 Hz) (17.23x nhanh hơn DDIM-50)
DDIM Diffusion (NFE=20) 87.5% / 12.5% 1.00 bits / 0.357 5.21 ms (768 Hz)
Flow Matching CFM (NFE=20) 100.0% / 0.0% 1.00 bits / 0.291 3.51 ms (1,141 Hz)
DDIM Diffusion (NFE=50) 87.5% / 12.5% 1.00 bits / 0.366 17.70 ms (226 Hz)
Flow Matching CFM (NFE=50) 100.0% / 0.0% 1.00 bits / 0.275 10.21 ms (392 Hz)

Thí nghiệm 2 — Generalist VLA Transfer (2-DoF Source -> 3-DoF Target Arm)#

Chiến lược Transfer Zero-Shot (k=0) MSE / Succ Few-Shot (k=8) MSE / Succ Few-Shot (k=24) MSE / Succ
Target-Only Scratch 0.755 / 15.6% 1.063 / 9.4% 0.201 / 53.1%
Naive Shared Head (Zero-Pad) 0.601 / 3.1% 0.389 / 9.4% 0.263 / 31.2% (Negative transfer -21.9pp)
Modular VLA (Semantic + Adapter) 0.623 / 65.6% 0.380 / 84.4% (+75.0pp) 0.191 / 84.4% (mean_err=0.0566)

Thí nghiệm 3 — Controlled 4-Axis Sim-to-Real Diagnostic (SysID mass=2.4548, damp=0.2556, lag=2 steps, 28-dim History Buffer)#

Chiến lược Adaptation Nominal / Visual Shift Dynamics Shift / 2-Step Latency Combined Real-World Shift
no_adaptation 100.0% / 15.0% 0.0% / 0.0% 0.0% (coll=85.0%)
sysid_only 2.5% / 65.0% 100.0% / 100.0% 35.0% (coll=5.0%)
dr_only 100.0% / 100.0% 0.0% / 0.0% 0.0% (coll=0.0%)
dr_history_sysid 100.0% / 100.0% 100.0% / 100.0% 92.5% (coll=0.0%, dist=0.1444)
  • OpenTelemetry: BoundedInMemorySpanExporter ghi nhận đủ 4 distinct spans (policy.train_eval, nfe.pareto_sweep, vla.cross_embodiment, sim2real.ablation_diagnostic).

4. Thang điểm Đánh giá (Rubric — 100 điểm)#

Hạng mục Trọng số Tiêu chí Nghiệm thu
1. Flow Matching & Diffusion Policy 30% Chứng minh MSE sụp đổ vào vật cản (mode collapse), cài đặt đúng OT interpolant + Heun/Euler ODE và \(v\)-prediction DDIM đạt tốc độ điều khiển >= 3x ở ngưỡng thành công cao hơn hoặc tương đương.
2. Action Chunking & Độ mượt 15% Thực hiện ablation \(H_e \in \{1, 4, 8\}\) chỉ ra đánh đổi giữa mean_action_jerk, tần số điều khiển (Hz) và tính ổn định kín vòng.
3. Cross-Embodiment VLA Adapter 20% Chứng minh zero-padding naive head gây negative transfer khi động học đảo dấu, trong khi shared semantic encoder + Jacobian-structured residual head đạt zero-shot và positive transfer mạnh.
4. Controlled Sim-to-Real Ablations 20% Tách biệt 4 trục (nominal, visual shift, dynamics shift, actuation latency), xác định lag + mass/damping bằng SysID và phục hồi hoàn toàn kịch bản tổng hợp bằng DR + History + SysID.
5. Kỹ thuật Phần mềm & Kiểm thử 15% 0 lỗi ruff, 0 lỗi mypy --strict (không # type: ignore), 22 pytest + Hypothesis + BoundedInMemorySpanExporter 4 spans + uv.lock --check pass.