feat(hyvla): Hy-Embodied-0.5-VLA Thor SM110 — dynamic FP8 + fused megakernels - #167
feat(hyvla): Hy-Embodied-0.5-VLA Thor SM110 — dynamic FP8 + fused megakernels#167DXICM wants to merge 3 commits into
Conversation
Hy-Embodied-0.5-VLA (HunYuan MoT dual-tower + flow matching) on Jetson
Thor SM110 with runtime dynamic per-tensor FP8, fused megakernels, and
optional NVFP4 FFN.
New kernels (csrc/kernels/, SM110-gated):
- hyvla_fused_thor: RoPE+QK-Norm+KV-write megakernel (also SM87-portable)
- hyvla_vit_fuse: ViT residual-add + LayerNorm (also SM87-portable)
- hyvla_quant_fp8_thor: single-CTA dynamic FP8 quantize (graph-safe)
- hyvla_ffn_fp8_thor: FFN gate/up+SiLU and down+residual fused GEMM
Architecture (per docs/adding_new_model.md):
- models/hyvla/pipeline_thor.py — Thor compute path
- frontends/torch/hyvla_thor.py — HyVLATorchFrontendThor
- frontends/torch/_hyvla_thor_spec.py — declarative weight spec
- _PIPELINE_MAP: ("hyvla","torch","thor") one-to-one
- load_model(config="hyvla") dispatches through the standard VLA path
Performance (real image, Thor SM110):
- E2E predict: 159.6 ms (vs reference eager ~930 ms, ~5.8x)
- Action cosine vs reference: 0.999706
Docs: docs/hyvla05_thor_sm110.md (English), docs/stable_api.md updated.
|
Thank you for contributing the native Hy-Embodied-0.5-VLA Thor path. The model/frontend/pipeline split follows the repository's intended structure, the kernel names are model-scoped, and the matching CMake definitions and pybind guards are a good start. Codex performed a strict review against FlashRT's long-term maintenance rules. The following items should be addressed before merge. Required changes
Pre-merge checklist
Please refer to the repository's PR Review Checklist and Adding a New Model guides. This is a Codex-assisted maintainability review. The architecture and optimization direction are reasonable; the model-selected build boundary, public routing correctness, safe input contracts, and reproducible validation need to be closed before this becomes a supported path on |
Address review feedback: Build isolation: - New FLASHRT_ENABLE_HYVLA CMake option (OFF by default). Both arch blocks (SM110 full set, SM87 portable shared kernels) now require the option together with the matching GPU_ARCH; sources, compile definitions, and pybind symbols gate together. HyVLA OFF leaves the default SM87/SM110 build and symbol surface unchanged. FP4 routing correctness: - load_model(config="hyvla", use_fp4=True) previously dropped use_fp4 before constructing the frontend. A dedicated _hyvla_fp4 flag now carries the route and the hyvla kwarg branch passes use_fp4=True explicitly; the validated fp8 production tier selects use_fused=True and use_autotune when the frontend accepts them. Hardware fail-fast and safe loading: - HyVLATorchFrontendThor validates torch.cuda capability (11,0) before loading weights or allocating CUDA state; a documented FLASHRT_HYVLA_FORCE_ARCH env override skips the probe for development only. The check is inheritable by the Orin subclass. - Tokenizer loading no longer uses trust_remote_code — checkpoint- provided Python code is never executed during model loading. Public input contracts (deterministic under python -O): - predict_actions: missing-prompt assert replaced with RuntimeError; state wider than max_state_dim and wrong-element-count noise raise ValueError before any graph lookup or copy. - All five fused-kernel pybind APIs validate their launch contract (positive dims, hd==128, off+S<=S_tot, eps>0, kv_rep>=1, K%16 and N/Nout%32 alignment) and raise ValueError instead of launching invalid grids. Reproducible in-tree validation: - tests/test_hyvla_thor_dispatch.py — registration one-to-one gate - tests/test_hyvla_arch_gate.py — mocked-capability fail-fast tests - tests/test_hyvla_fp4_routing.py — proves use_fp4/use_fused reach the frontend (stubbed construction, mocked flash_rt_fp4) - tests/test_hyvla_kernel_contracts.py — negative-dimension contract tests for all five kernels - tests/test_hyvla_thor_graphsafe.py — graph==eager + replay stability gate with deterministic seed-0 inputs (checkpoint via env var) - docs/hyvla05_thor_sm110.md updated to reference only committed tests and document the build option.
Production validation on Orin SM87 found the routing tests failed with
kwargs={'num_views': 2}: load_model feature-detects accepted kwargs via
inspect.signature(pipe_cls), and the recording stub declared only
**kwargs, so use_fp4/use_fp8/use_fused were never forwarded. The real
routing path is unaffected (HyVLATorchFrontendThor declares all named
parameters).
- Stub now mirrors the real HyVLATorchFrontendThor constructor
signature exactly.
- Orin FP4 fallback test stubs HyVLATorchFrontendOrin as well so it
validates the warning and the dropped use_fp4 without touching a
checkpoint (skips only where the Orin frontend is not importable).
|
Thanks for the review. All six required changes are addressed, and re-validated on a production Jetson Orin (sm_87, CUDA 12.2, torch 2.3.0). 1. Model-level build option —
2.
3. Fail-fast + no implicit remote code — 4. Fused-kernel contracts — host-side validation added before launch for all five fused kernels (RoPE/QK-Norm/KV-write, ViT add+LayerNorm, dynamic FP8 quant, FFN gu/silu, FFN dn/res): positive dims, supported 5. Committed validation — the PR now ships 6. Frontend input contract — the missing-prompt Combined production run: 43 passed / 0 failed / 5 skipped (all skips are intended hardware gates). Remaining SM110-device checklist items (Thor build/import/symbol checks, fixed-noise cosine and graph-safety gates on real Thor hardware) are queued for the Thor device and will be reported here. |
…ommitted gates Address the flashrt-project#168 maintainability review: - HyVLATorchFrontendOrin now enforces SM87 via the inherited _require_arch() gate (_REQUIRED_CAPABILITY=(8,7), documented FLASHRT_HYVLA_FORCE_ARCH dev override), failing before checkpoint loading and CUDA allocation on non-Orin devices. - Precision contract consistency: use_int8_vlm_ffn / use_int8_exp are the validated default tier (cosine >= 0.999, re-verified on production Orin at 0.999162); use_int8_vlm / use_int8_vit remain clearly labeled below-gate opt-ins, matching the doc. - Orin predict_actions inherits the full Thor input contract: stable RuntimeError for missing prompt, oversized-state rejection, noise element-count validation. - Commit the gates the doc references: fixed-noise BF16-vs-INT8 cosine gate + input boundaries (test_orin_hyvla05_e2e_check.py), graph-vs- eager / replay-stability / fused-vs-unfused (test_orin_hyvla05_graphsafe.py), hardware fail-fast + FP4 rejection (test_orin_hyvla05_arch_gate.py). - Doc build snippet now passes -DFLASHRT_ENABLE_HYVLA=ON; verification section points at the committed pytest gates. - Rebased onto the corrected flashrt-project#167 head so the SM87 shared kernels are gated behind FLASHRT_ENABLE_HYVLA; removed the EOF blank line in hyvla_orin.py.
Summary
Adds Hy-Embodied-0.5-VLA (HunYuan MoT dual-tower + flow matching) to FlashRT on Jetson Thor SM110. Orin SM87 port lands in a follow-up PR based on this branch.
New kernels (
csrc/kernels/, SM110-gated viaFLASHRT_HAVE_HYVLA_THOR):hyvla_fused_thor.cu— fused RoPE + QK-Norm + KV-write megakernel (replaces 11 launches per attention block; also SM87-portable)hyvla_vit_fuse.cu— ViT residual-add + LayerNorm fusion (also SM87-portable)hyvla_quant_fp8_thor.cu— single-CTA dynamic per-tensor FP8 quantize (graph-safe, 1 launch vs 4)hyvla_ffn_fp8_thor.cu— FFN gate/up+SiLU and down+residual fused GEMM kernelsArchitecture (per
docs/adding_new_model.mdrules 1-4):models/hyvla/pipeline_thor.py— Thor compute pathfrontends/torch/hyvla_thor.py—HyVLATorchFrontendThorfrontends/torch/_hyvla_thor_spec.py— declarative weight spec_PIPELINE_MAP:("hyvla","torch","thor")one-to-oneload_model(config="hyvla")dispatches through the standard VLA pathuse_fp4=Trueon Thor routes to NVFP4 FFN tierPerformance (real image, Thor SM110):
CMake/binding compliance:
if(GPU_ARCH STREQUAL "110")+FLASHRT_HAVE_HYVLA_THORm.defuses matching#ifdefguard; no unconditional binding references gated symbolsFLASHRT_HAVE_HYVLA_ORINWhat is not changed
flash_rt_kernelssymbol surface is additive onlyexecutors/torch_weights.pyadds model-agnosticToBf16(mirrors existingToFp16/ToFp32)Test plan
cmake -B build -S . -DGPU_ARCH=110 && cmake --build build -j$(nproc) --target flash_rt_kernelspython -c "from flash_rt import flash_rt_kernels; print(flash_rt_kernels.__file__)"python -c "from flash_rt.hardware import resolve_pipeline_class; print(resolve_pipeline_class('hyvla','torch','thor'))"