Skip to content

feat(hyvla): Hy-Embodied-0.5-VLA Orin SM87 — INT8 W8A8 + fused kernels - #168

Open
DXICM wants to merge 5 commits into
flashrt-project:mainfrom
DXICM:feat/hyvla-orin
Open

feat(hyvla): Hy-Embodied-0.5-VLA Orin SM87 — INT8 W8A8 + fused kernels#168
DXICM wants to merge 5 commits into
flashrt-project:mainfrom
DXICM:feat/hyvla-orin

Conversation

@DXICM

@DXICM DXICM commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Jetson Orin SM87 port of Hy-Embodied-0.5-VLA using INT8 W8A8 quantization. Depends on #167 (Thor port with shared kernels).

Orin-specific additions:

  • frontends/torch/hyvla_orin.pyHyVLATorchFrontendOrin (subclasses Thor frontend, overrides quantization and GEMM dispatch for SM87)
  • models/hyvla/pipeline_orin.py — Orin compute path (INT8 GEMM via cutlass_sm80_int8_rowwise, BF16 fallback)
  • _PIPELINE_MAP: ("hyvla","torch","rtx_sm87") + _SM87_ALLOWED entry
  • tests/test_orin_hyvla05_dispatch.py — dispatch resolution smoke test (pure pytest, no GPU/checkpoint needed)

Shared kernels reused from #167 (compiled for SM87 via FLASHRT_HAVE_HYVLA_ORIN):

  • hyvla_fused_thor.cu — fused RoPE+QK-Norm+KV-write megakernel (plain CUDA, no SM110-only instructions)
  • hyvla_vit_fuse.cu — ViT residual-add + LayerNorm

Performance (real image, Orin SM87):

Metric Value
E2E predict 277.5 ms (~11.3× vs reference eager)
Action cosine vs reference ≥ 0.999

Quantization approach: INT8 W8A8 with per-row dynamic scales. Orin SM87 has no native FP4/FP8 tensor cores, so INT8 integer GEMMs (hardware I2F dequant) are the optimal low-precision tier.

What is not changed

  • No Thor-path code modified (additive Orin frontend + pipeline only)
  • Shared kernel math unchanged; SM87 compilation gate is additive in CMake

Test plan

  • python -m pytest tests/test_orin_hyvla05_dispatch.py -q
  • cmake -B build -S . -DGPU_ARCH=87 && cmake --build build -j$(nproc) --target flash_rt_kernels
  • python -c "from flash_rt.hardware import resolve_pipeline_class; print(resolve_pipeline_class('hyvla','torch','rtx_sm87'))"
  • E2E validation with real checkpoint on Orin hardware

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.
@DXICM
DXICM requested a review from LiangSu8899 as a code owner August 6, 2026 06:46
@LiangSu8899

Copy link
Copy Markdown
Member

Thank you for following the Thor work with a separate HyVLA Orin implementation. Keeping the Orin frontend and pipeline as an additive layer over #167 is the right general dependency shape, and the Orin-only diff does not modify the Thor runtime implementation. Codex reviewed the current head against FlashRT's long-term maintenance standards. The following items should be addressed before merge.

Required changes

  1. Merge and correct feat(hyvla): Hy-Embodied-0.5-VLA Thor SM110 — dynamic FP8 + fused megakernels #167 first, then rebase this PR

    This is a stacked PR and currently includes the full feat(hyvla): Hy-Embodied-0.5-VLA Thor SM110 — dynamic FP8 + fused megakernels #167 commit. Please first complete feat(hyvla): Hy-Embodied-0.5-VLA Thor SM110 — dynamic FP8 + fused megakernels #167's model-level build isolation, kernel contract checks, routing fix, and validation. After feat(hyvla): Hy-Embodied-0.5-VLA Thor SM110 — dynamic FP8 + fused megakernels #167 is merged, rebase this PR onto the new main so the review and rollback surface contains only the Orin additions.

  2. Keep the SM87 shared kernels behind the HyVLA model option

    The shared fused RoPE/QK-Norm/KV-write and ViT fusion sources are currently compiled into every SM87 flash_rt_kernels build. They should require both FLASHRT_ENABLE_HYVLA=ON and GPU_ARCH=87, with matching symbol guards. An unrelated SM87 model build should remain unchanged when HyVLA is disabled.

  3. Add an SM87 fail-fast check

    HyVLATorchFrontendOrin subclasses the Thor frontend but neither constructor validates the actual CUDA capability. The hardware="rtx_sm87" argument is currently descriptive rather than enforced. Please reject non-SM87 devices before checkpoint loading, weight quantization, and large CUDA allocation, with an optional development override only if it is explicit and documented.

  4. Make the precision defaults and evidence internally consistent

    The source comments label use_int8_vlm_ffn and use_int8_exp as experimental and not validated at cosine >= 0.999, while both are part of the documented default path and the document reports that this default passes the gate. Please establish one authoritative contract: update the comments if the default path is validated, and commit the exact fixed-noise precision test that proves it. Features documented as failing the gate (use_int8_vlm, use_int8_vit) should remain clearly opt-in and must never be enabled indirectly by the standard API.

  5. Commit the tests referenced by the documentation

    The Orin document references test_orin_hyvla05_e2e_check.py, test_orin_hyvla05_graphsafe.py, and test_orin_hyvla05_stageprof.py, but none of these files are present. The only committed test is a nine-line dispatch check. Please add at least:

    • fixed-noise BF16 and default-INT8 reference cosine gates
    • eager-versus-graph and repeated-replay stability
    • fused-versus-unfused attention-prep and ViT fusion checks
    • hardware fail-fast and missing-symbol behavior
    • input-shape boundaries inherited from the Thor frontend

    Benchmark/profiling scripts can remain outside pytest, but correctness and graph-safety gates need to be versioned with the implementation.

  6. Validate inherited public inputs and clean the patch

    The Orin override inherits the same assertion-based prompt check and accepts oversized state vectors or arbitrary noise shapes before graph execution. Please convert these to explicit contract checks. git diff --check also currently reports an extra blank line at EOF in flash_rt/frontends/torch/hyvla_orin.py; please clean that before merge.

Pre-merge checklist

  • feat(hyvla): Hy-Embodied-0.5-VLA Thor SM110 — dynamic FP8 + fused megakernels #167 is corrected and merged; this PR is rebased to contain only the Orin delta
  • HyVLA OFF leaves the default SM87 build and symbol surface unchanged
  • HyVLA ON + SM87 build, import, and expected-symbol checks pass
  • Non-SM87 devices fail before checkpoint loading or quantization
  • Default INT8 flags, comments, docs, and public API routing describe the same validated tier
  • Below-gate INT8 experiments remain explicit opt-ins
  • Fixed-noise cosine, graph/eager equivalence, and replay-stability tests are committed and pass on Orin
  • Fused/unfused kernel reference tests and missing-symbol behavior are covered
  • Prompt, image, state, and noise boundary tests pass
  • git diff --check, Python compilation, dispatch tests, SM87 build, and real-checkpoint smoke pass

Please refer to the repository's PR Review Checklist and Adding a New Model guides.

This is a Codex-assisted maintainability review. The Orin separation is directionally good; the build isolation inherited from #167, hardware enforcement, precision contract, and missing reproducibility gates need to be completed before merge.

DXICM and others added 4 commits August 7, 2026 13:06
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).
Jetson Orin SM87 port using INT8 W8A8 quantization with the shared
fused RoPE+QK-Norm+KV-write megakernel from the Thor path.

- frontends/torch/hyvla_orin.py — HyVLATorchFrontendOrin (subclasses
  the Thor frontend, overrides quantization and GEMM dispatch)
- models/hyvla/pipeline_orin.py — Orin compute path (INT8 GEMM via
  cutlass_sm80_int8_rowwise, BF16 fallback for unquantized ops)
- _PIPELINE_MAP: ("hyvla","torch","rtx_sm87") + _SM87_ALLOWED entry
- docs/hyvla05_orin_sm87.md (English), docs/stable_api.md updated
- tests/test_orin_hyvla05_dispatch.py — dispatch resolution smoke test

Performance (real image, Orin SM87): 277.5 ms E2E (~11.3x vs reference
eager). Action cosine vs reference: >= 0.999.
…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.
@DXICM
DXICM force-pushed the feat/hyvla-orin branch from dfdd463 to 1eea7f1 Compare August 7, 2026 08:23
@DXICM

DXICM commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The Orin delta has been corrected and rebased onto the fixed #167 head (1eea7f1); once #167 merges, this PR will be rebased onto main so the review surface contains only the Orin additions. Item-by-item:

1. Stacking — done as above; the branch now carries #167's corrected commits plus one Orin fix commit.

2. SM87 shared kernels behind the HyVLA option — inherited from the corrected #167: FLASHRT_ENABLE_HYVLA AND GPU_ARCH STREQUAL "87" gates the shared fused RoPE/QK-Norm/KV-write and ViT fusion sources with matching pybind guards. Production Orin matrix re-verified: OFF build exports no HyVLA symbols; ON build exports exactly hyvla_rope_qknorm_kvwrite_bf16 / hyvla_vit_add_layer_norm_bf16, and Thor-only symbols stay absent.

3. SM87 fail-fastHyVLATorchFrontendOrin now sets _REQUIRED_CAPABILITY = (8, 7) / _ARCH_NAME = "Jetson Orin SM87" and reuses the inherited _require_arch() gate, which runs before checkpoint loading, quantization, and CUDA allocation. The dev override is the same documented FLASHRT_HYVLA_FORCE_ARCH env var. Covered by tests/test_orin_hyvla05_arch_gate.py (mocked CUDA, no device needed): rejects no-CUDA and non-SM87 capabilities, accepts SM87, honors the env override, and confirms FP4 is rejected before any CUDA work.

4. Precision contract consistency — one authoritative contract now: use_int8_vlm_ffn and use_int8_exp are labeled the validated default tier (cosine >= 0.999), matching the doc and the standard API routing; use_int8_vlm and use_int8_vit are labeled below-gate opt-ins and are never enabled by the default path. The default tier was re-validated on production Orin: INT8 vs local BF16 action cosine 0.999162 (>= 0.999 gate), MAE 6.39e-3.

5. Committed tests — the gates the doc references are now versioned:

  • tests/test_orin_hyvla05_e2e_check.py — fixed-noise BF16-vs-default-INT8 cosine gate (>= 0.999), default-tier fusion-flag checks, eager determinism, oversized-state and wrong-noise-size boundaries (checkpoint-gated via FLASHRT_HYVLA_CHECKPOINT, sequential BF16-then-INT8 loads to respect Orin unified memory);
  • tests/test_orin_hyvla05_graphsafe.py — graph-vs-eager (>= 0.9999), replay stability (bitwise), fused-vs-unfused attention-prep and ViT add+LayerNorm checks;
  • tests/test_orin_hyvla05_arch_gate.py — hardware fail-fast and FP4 rejection, checkpoint-free.
    The doc's file table and Verification section now point only at committed files; stage-profiling remains outside pytest and is no longer referenced as an in-tree script.

6. Inherited contracts and patch hygiene — the Orin predict_actions now uses a stable RuntimeError for the missing-prompt state (deterministic under python -O), rejects oversized state vectors, and validates noise element count before graph lookup. The EOF blank line in hyvla_orin.py is removed; git diff --check is clean.

Production Orin re-test of this branch is queued (pull + FLASHRT_HYVLA_CHECKPOINT=/mnt/models/Hy-Embodied-0.5-VLA-RoboTwin pytest run); results will be reported here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants