Skip to content

Restore SM89 FP8 NT path and fix Pi0.5 autotune scratch selection - #93

Merged
LiangSu8899 merged 2 commits into
flashrt-project:mainfrom
heiheiha798:fix/sm89-pi05-fp8-autotune
Jun 19, 2026
Merged

LiangSu8899 merged 2 commits into
flashrt-project:mainfrom
heiheiha798:fix/sm89-pi05-fp8-autotune

Conversation

@heiheiha798

@heiheiha798 heiheiha798 commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the current SM89 Pi0.5 FP8 regression and keeps the scope tight:

  1. restore the missing SM89 nk -> fp8_nt_dev / autotune_fp8_nt_dev binding and cuBLASLt path in GemmRunner
  2. fix Pi0.5 FP8 autotune scratch selection to use the existing size-based scratch helpers instead of the old K == *_H heuristic
  3. apply the same size-based autotune scratch fix to the batched RTX path and add a minimal B=2 autotune one-shot guard
  4. add regression coverage for base/batched scratch selection, SM89 nk dispatch, the B=2 one-shot guard, and the pybind symbol surface

Closes #91.

Scope

  • fixes the default SM89 Pi0.5 FP8 path and the matching batched RTX autotune path
  • intentionally does not expand into pipeline_rtx_fp16.py, because the public FP16 path explicitly rejects use_fp8=True and that dormant branch is outside the supported runtime contract for this PR
  • does not include local-only debugging assets, profiling artifacts, or eval_libero.py follow-up work

Validation Environment

  • GPU: NVIDIA GeForce RTX 4090
  • compute capability: SM89 (8.9)
  • driver: 550.54.14
  • CUDA toolkit: 12.4 (nvcc 12.4.99)
  • PyTorch: 2.6.0+cu124
  • framework path validated here: torch

Validation

Kernel binding / import check

Confirmed the locally built extension imports from the source tree and exposes the restored symbols:

python - <<'PY'
from flash_rt import flash_rt_kernels as fvk
print(fvk.__file__)
print(hasattr(fvk.GemmRunner, 'fp8_nt_dev'))
print(hasattr(fvk.GemmRunner, 'autotune_fp8_nt_dev'))
PY

Observed result:

  • imports from flash_rt/flash_rt_kernels.cpython-310-x86_64-linux-gnu.so
  • has_fp8_nt_dev == True
  • has_autotune_fp8_nt_dev == True

Focused regression test

python -m pytest tests/test_pi05_rtx_autotune_scratch.py -q

Observed result:

  • 5 passed in 0.17s

Precision comparison

Base path: FP8 vs FP16 baseline on the same fixed noise

Ran two isolated subprocesses through the public API on the same checkpoint,
same observation, same prompt, and the same injected (10, 32) diffusion noise.
Compared the final (10, 7) action outputs.

Observed result:

  • action cosine (fp8 vs fp16 baseline): 0.998742
  • max abs diff: 0.064743
  • mean abs diff: 0.013287

Batched path: B=2 slot-0 vs serial B=1

PI05_LIBERO_PYTORCH_CHECKPOINT=/data/home/tianjianyang/models/vla/pi05-libero \
python -m pytest tests/test_pi05_batched_precision.py -q -s

Observed result:

  • 1 passed in 38.75s
  • this gate asserts batched Pi0.5 slot-0 cosine vs serial B=1 remains >= 0.99

Runtime quickstart: FP8

python examples/quickstart.py \
  --checkpoint /data/home/tianjianyang/models/vla/pi05-libero \
  --config pi05 \
  --framework torch \
  --hardware rtx_sm89 \
  --benchmark 5 \
  --warmup 20

Observed result:

  • output sanity: PASS
  • prompt reuse: OK
  • wall-clock benchmark: P50 41.3 ms (24 Hz)
  • min/mean/max: 37.5 / 42.2 / 49.5 ms

Runtime quickstart: FP16 baseline

python examples/quickstart.py \
  --checkpoint /data/home/tianjianyang/models/vla/pi05-libero \
  --config pi05 \
  --framework torch \
  --hardware rtx_sm89 \
  --use_fp16 \
  --benchmark 5 \
  --warmup 20

Observed result:

  • output sanity: PASS
  • prompt reuse: OK
  • wall-clock benchmark: P50 51.1 ms (20 Hz)
  • min/mean/max: 46.4 / 49.4 / 51.4 ms

Limitations / Not Covered Here

  • This PR was validated locally on SM89 / RTX 4090 only.
  • I did not run per-architecture rebuild/import checks for other GPU_ARCH families in this environment.
  • I did not run the larger precision suites that require additional local fixtures / checkpoints beyond this Pi0.5 runtime path.
  • pipeline_rtx_fp16.py contains a dormant internal FP8 branch with similar old heuristic logic, but the public FP16 path explicitly rejects use_fp8=True; that branch is intentionally left out of scope for this PR.

@heiheiha798
heiheiha798 requested a review from LiangSu8899 as a code owner June 19, 2026 13:34
Copilot AI review requested due to automatic review settings June 19, 2026 13:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores the SM89 (Ada) FP8 nk (transpose-B) GEMM path and fixes Pi0.5 FP8 autotune scratch selection by switching from the old K == *_H heuristic to the existing size-based scratch pickers, for both base and batched RTX pipelines. It also adds regression tests covering scratch selection, nk dispatch, the batched B=2 one-shot autotune guard, and the pybind symbol surface.

Changes:

  • Reintroduce fp8_nt_dev / autotune_fp8_nt_dev in GemmRunner (cuBLASLt cached descriptor path) and expose them via pybind.
  • Update Pi0.5 RTX autotune to choose FP8 scratch buffers via _pick_fp8_scratch / _pick_fp8_scratch_b2 (size-based), and add a B=2 autotune one-shot guard for the batched path.
  • Add tests for scratch selection, layout dispatch behavior, the batched autotune guard, and the existence of the new GemmRunner bindings.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_pi05_rtx_autotune_scratch.py Adds regression tests for scratch selection, nk dispatch, batched one-shot autotune behavior, and pybind symbol presence.
flash_rt/models/pi05/pipeline_rtx.py Switches FP8 autotune scratch selection from K==*_H to _pick_fp8_scratch(..., M*K) and passes pointers directly.
flash_rt/models/pi05/pipeline_rtx_batched.py Applies the same size-based scratch selection for B=2 autotune and adds a _gemms_autotuned_b2 guard.
csrc/gemm/gemm_runner.h Declares fp8_nt_dev and autotune_fp8_nt_dev and introduces a cached GEMM type for FP8 transpose-B.
csrc/gemm/gemm_runner.cu Implements FP8 transpose-B cached descriptors + runtime/autotune entrypoints using cuBLASLt.
csrc/bindings.cpp Exposes fp8_nt_dev and autotune_fp8_nt_dev on the pybind GemmRunner.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_pi05_rtx_autotune_scratch.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@LiangSu8899
LiangSu8899 merged commit ee0d974 into flashrt-project:main Jun 19, 2026
@heiheiha798
heiheiha798 deleted the fix/sm89-pi05-fp8-autotune branch June 21, 2026 09:52
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.

fp8_nt_dev missing on SM89 (regression of #21)

3 participants