Skip to content

v0.2.0 — GROOT N1.7 Thor inference + lerobot HF compatibility + FA2 i… - #1

Merged
LiangSu8899 merged 1 commit into
mainfrom
sync/v0.2.0-n17-lerobot
Apr 30, 2026
Merged

LiangSu8899 merged 1 commit into
mainfrom
sync/v0.2.0-n17-lerobot

Conversation

@LiangSu8899

Copy link
Copy Markdown
Member

…nstall note

This release lands three feature blocks on top of the v0.1.0 baseline:

GROOT N1.7 Thor inference path

Adds a complete inference pipeline for the GR00T-N1.7-3B model on Jetson AGX Thor (SM110) using FlashRT's static-CUDA-Graph composition pattern. End-to-end Pi0.7-style flow: HF Qwen3-VL backbone (24 ViT blocks + 3 DeepStack mergers + 16 truncated LLM layers + 4 vlsa self-attn) feeds a 32-layer DiT action head running 4-step flow-matching diffusion at bf16-native, capped by per-embodiment state / action encoders + decoder. Production data path:

GrootN17TorchFrontendThor(ckpt, num_views=2, embodiment_tag="...")
.set_prompt(aux=...) # 0.5 s: M-RoPE / ViT-rope tables,
# visual-pos masks, calibration
# shadow + alpha bake, JSON cache,
# warmup
.calibrate(aux_list, percentile=99.9) # optional N>=2 percentile
# reduce of FP8 act-scale alphas
.infer(state, initial_noise=...) # ~46 ms eager / 38 ms with
# per-step DiT graph capture
.denormalize_action(...) # SE3-aware HF processor
# inverse for relative-action
# embodiments

  • 4 FP8 stages (vit / dsm / llm / vlsa) calibrated via per-quant -point amax shadow; DiT runs bf16 native (its bf16 weights are pre-dequantized at load time, no FP8 alpha needed).
  • Lerobot-style precision_spec snapshot (206 entries with stage -prefixed keys: vit_<q|o|fc1|fc2>, dsm<fc1|fc2>, llm<qkv|o|gate|up|down>, vlsa_<q|k|v|o|fc1|fc2>).
  • Per-step CUDA Graph capture of the 32-layer DiT inner loop with pre-built modulator buffers; sa_embs.copy_ + 4 graph replays per inference. Eager fallback retained for debug.
  • 5-site attention backend protocol (vit / llm / vl_self_attn / dit_self / dit_cross) — dit_self uses the new bf16 attention path, llm uses the new causal-mha kernel.
  • N>=2 multi-frame calibration: calibrate(aux_list, percentile= 99.9) runs per-aux shadow forwards, percentile-reduces amax via core.calibration.accumulate_amax, re-bakes alphas. N=1 short -circuits as a no-op (alphas already baked by set_prompt).

New csrc kernels (R0-clean — pure additions, no signature changes to existing symbols):

  • csrc/kernels/dit_bf16.cu (5 helpers — layer-norm-no-affine, ada-layer-norm, residual-add, add-bias, gelu-inplace; bf16 mirrors of the existing fp16 ops).
  • csrc/kernels/attention_dit_bf16.cu (softmax_bf16, attention_mha_bf16 with caller-provided logits_kv_stride).
  • csrc/kernels/attention_mha_causal.cu (attention_mha_causal_fp16 — strict upper-triangular mask).
  • csrc/kernels/softmax.cu appended softmax_causal_fp16 _kernel for the causal MHA path.

New Python stack:

  • flash_vla/models/groot_n17/ — pipeline_thor (DiT main path), calibration (4 shadow stages + amax aggregation), embodiments (per-tag slot table), mrope_table (Qwen3-VL 2D ViT rope builder).
  • flash_vla/frontends/torch/groot_n17_thor.py — production frontend (1300+ lines).
  • flash_vla/frontends/torch/_groot_n17_thor_spec.py — declarative weight spec covering vit / dsm / llm / vlsa / dit + per-embodiment encoders / decoder.
  • flash_vla/hardware/thor/attn_backend_groot_n17.py — 5-site attention dispatcher.
  • flash_vla/configs/groot_n17.yaml — embodiment tag table.

New tests:

  • tests/test_groot_n17_{e2e,latency,precision,calibration, attn_backend,weight_loader}.py — pytest suite (66 cells).
  • tests/test_thor_groot_n17_calibrate.py — N=1 / N=8 multi -frame calibration regression with subprocess isolation.
  • tests/_helpers/groot_n17/ — gen_reference, capture_llm_aux, capture_aux_multi, debug bisect tools.

Lerobot HF policy compatibility

The Hugging Face lerobot releases of Pi0 / Pi0.5 (e.g. lerobot/pi05_libero_finetuned_v044) ship checkpoints in two formats that diverge from the openpi-converted layout the v0.1.0 loaders assumed:

  1. Norm stats in policy preprocessor / postprocessor safetensors pairs at <ckpt>/policy_preprocessor_step_*_normalizer _processor.safetensors and policy_postprocessor_step_* _unnormalizer_processor.safetensors with flat <feature>.<stat> keys (action.q01, observation.state.q99, ...). v0.1.0 only knew assets/physical-intelligence/<task>/ norm_stats.json.
  2. Weight tensors wrapped under an extra model. namespace (model.paligemma_with_expert.gemma_expert.lm_head.weight vs the openpi bare key form).

This release adds:

  • flash_vla/core/utils/norm_stats.py — unified loader walking a list of candidates AND optionally scanning a checkpoint dir for the lerobot policy safetensors pair. Auto-translates lerobot schema to openpi shape so downstream unnormalize_actions stays schema-agnostic. Also accepts the lerobot dataset meta/stats.json form for completeness.
  • _autodetect_strip_prefix in flash_vla/executors/torch_weights.py — flags the lerobot model. wrap by probing for known family sentinels (covers Pi0 / Pi0.5 paligemma_with_expert.* and Pi0-FAST paligemma.model.*). SafetensorsSource / MultiSafetensorsSource learn a strip_prefix constructor arg and serve openpi-style spec keys against either layout.
  • Wiring through all 7 frontends (5 torch + 2 jax) — both the SafetensorsSource path and the few direct safe_open sites (pi05_thor / pi0_thor / pi05_rtx / pi0_rtx / pi0fast / pi05_thor_fp4) auto-detect and prepend the prefix.
  • tests/test_norm_stats_adapter.py (12 cases) + tests/test_torch_weights_prefix.py (11 cases) covering schema detection / translation, openpi flat / wrapped, lerobot stats / safetensors, autodetect across model families.
  • tests/_helpers/validate_lerobot_norm_stats.py — manual real-data harness that pulls the published HF safetensors and runs the loader end-to-end.

Verified end-to-end on the published
lerobot/pi05_libero_finetuned_v044 checkpoint:

Pi05TorchFrontendThor(ckpt, num_views=2, autotune=0,
use_cuda_graph=False)
.set_prompt("pick up the alphabet soup and place it in the basket")
.infer(obs)
-> actions shape=(10, 7), dtype=float32, all_finite=True,
range~[-0.4, 0.5]

The full Pi-family regression on the openpi-converted checkpoints (test_thor_calibrate_matrix.py) sees zero behaviour change: 12/12 cells PASS at or above their published cosine thresholds.

FA2 build note for CUDA < 12.8

The default Flash-Attention 2 vendor build emits a compute_120 PTX fallback that nvcc < 12.8 rejects (Value 'compute_120' is not defined). Cloud users on older CUDA images (e.g. an L40S running CUDA 12.4) can set FA2_ARCH_NATIVE_ONLY=ON to drop the cross-arch fallback and build SASS for the detected arch only — ~66 % faster build, works on any CUDA toolchain that supports the target arch. The flag has been in CMakeLists since the build -slimming work; docs/INSTALL.md §6.1 now surfaces it.

…nstall note

This release lands three feature blocks on top of the v0.1.0 baseline:

GROOT N1.7 Thor inference path
==============================

Adds a complete inference pipeline for the GR00T-N1.7-3B model on
Jetson AGX Thor (SM110) using FlashRT's static-CUDA-Graph composition
pattern. End-to-end ``Pi0.7``-style flow: HF Qwen3-VL backbone (24 ViT
blocks + 3 DeepStack mergers + 16 truncated LLM layers + 4 vlsa
self-attn) feeds a 32-layer DiT action head running 4-step
flow-matching diffusion at bf16-native, capped by per-embodiment
state / action encoders + decoder. Production data path:

  GrootN17TorchFrontendThor(ckpt, num_views=2, embodiment_tag="...")
    .set_prompt(aux=...)            # 0.5 s: M-RoPE / ViT-rope tables,
                                    #   visual-pos masks, calibration
                                    #   shadow + alpha bake, JSON cache,
                                    #   warmup
    .calibrate(aux_list, percentile=99.9)  # optional N>=2 percentile
                                    #   reduce of FP8 act-scale alphas
    .infer(state, initial_noise=...)       # ~46 ms eager / 38 ms with
                                    #   per-step DiT graph capture
    .denormalize_action(...)               # SE3-aware HF processor
                                    #   inverse for relative-action
                                    #   embodiments

  * 4 FP8 stages (vit / dsm / llm / vlsa) calibrated via per-quant
    -point amax shadow; DiT runs bf16 native (its bf16 weights are
    pre-dequantized at load time, no FP8 alpha needed).
  * Lerobot-style precision_spec snapshot (206 entries with stage
    -prefixed keys: vit_<i>_<q|o|fc1|fc2>, dsm_<j>_<fc1|fc2>,
    llm_<i>_<qkv|o|gate|up|down>, vlsa_<i>_<q|k|v|o|fc1|fc2>).
  * Per-step CUDA Graph capture of the 32-layer DiT inner loop with
    pre-built modulator buffers; sa_embs.copy_ + 4 graph replays per
    inference. Eager fallback retained for debug.
  * 5-site attention backend protocol (vit / llm / vl_self_attn /
    dit_self / dit_cross) — dit_self uses the new bf16 attention
    path, llm uses the new causal-mha kernel.
  * N>=2 multi-frame calibration: ``calibrate(aux_list, percentile=
    99.9)`` runs per-aux shadow forwards, percentile-reduces amax via
    ``core.calibration.accumulate_amax``, re-bakes alphas. N=1 short
    -circuits as a no-op (alphas already baked by ``set_prompt``).

New csrc kernels (R0-clean — pure additions, no signature changes
to existing symbols):

  * ``csrc/kernels/dit_bf16.cu`` (5 helpers — layer-norm-no-affine,
    ada-layer-norm, residual-add, add-bias, gelu-inplace; bf16
    mirrors of the existing fp16 ops).
  * ``csrc/kernels/attention_dit_bf16.cu`` (softmax_bf16,
    attention_mha_bf16 with caller-provided logits_kv_stride).
  * ``csrc/kernels/attention_mha_causal.cu``
    (attention_mha_causal_fp16 — strict upper-triangular mask).
  * ``csrc/kernels/softmax.cu`` appended ``softmax_causal_fp16
    _kernel`` for the causal MHA path.

New Python stack:

  * ``flash_vla/models/groot_n17/`` — pipeline_thor (DiT main path),
    calibration (4 shadow stages + amax aggregation), embodiments
    (per-tag slot table), mrope_table (Qwen3-VL 2D ViT rope builder).
  * ``flash_vla/frontends/torch/groot_n17_thor.py`` — production
    frontend (1300+ lines).
  * ``flash_vla/frontends/torch/_groot_n17_thor_spec.py`` — declarative
    weight spec covering vit / dsm / llm / vlsa / dit + per-embodiment
    encoders / decoder.
  * ``flash_vla/hardware/thor/attn_backend_groot_n17.py`` — 5-site
    attention dispatcher.
  * ``flash_vla/configs/groot_n17.yaml`` — embodiment tag table.

New tests:

  * ``tests/test_groot_n17_{e2e,latency,precision,calibration,
    attn_backend,weight_loader}.py`` — pytest suite (66 cells).
  * ``tests/test_thor_groot_n17_calibrate.py`` — N=1 / N=8 multi
    -frame calibration regression with subprocess isolation.
  * ``tests/_helpers/groot_n17/`` — gen_reference, capture_llm_aux,
    capture_aux_multi, debug bisect tools.

Lerobot HF policy compatibility
===============================

The Hugging Face ``lerobot`` releases of Pi0 / Pi0.5 (e.g.
``lerobot/pi05_libero_finetuned_v044``) ship checkpoints in two
formats that diverge from the openpi-converted layout the v0.1.0
loaders assumed:

  1. Norm stats in policy preprocessor / postprocessor safetensors
     pairs at ``<ckpt>/policy_preprocessor_step_*_normalizer
     _processor.safetensors`` and ``policy_postprocessor_step_*
     _unnormalizer_processor.safetensors`` with flat
     ``<feature>.<stat>`` keys (action.q01, observation.state.q99,
     ...). v0.1.0 only knew ``assets/physical-intelligence/<task>/
     norm_stats.json``.
  2. Weight tensors wrapped under an extra ``model.`` namespace
     (``model.paligemma_with_expert.gemma_expert.lm_head.weight``
     vs the openpi bare key form).

This release adds:

  * ``flash_vla/core/utils/norm_stats.py`` — unified loader walking
    a list of candidates AND optionally scanning a checkpoint dir
    for the lerobot policy safetensors pair. Auto-translates lerobot
    schema to openpi shape so downstream ``unnormalize_actions``
    stays schema-agnostic. Also accepts the lerobot dataset
    ``meta/stats.json`` form for completeness.
  * ``_autodetect_strip_prefix`` in
    ``flash_vla/executors/torch_weights.py`` — flags the lerobot
    ``model.`` wrap by probing for known family sentinels (covers
    Pi0 / Pi0.5 ``paligemma_with_expert.*`` and Pi0-FAST
    ``paligemma.model.*``). ``SafetensorsSource`` /
    ``MultiSafetensorsSource`` learn a ``strip_prefix`` constructor
    arg and serve openpi-style spec keys against either layout.
  * Wiring through all 7 frontends (5 torch + 2 jax) — both the
    SafetensorsSource path and the few direct ``safe_open`` sites
    (pi05_thor / pi0_thor / pi05_rtx / pi0_rtx / pi0fast /
    pi05_thor_fp4) auto-detect and prepend the prefix.
  * ``tests/test_norm_stats_adapter.py`` (12 cases) +
    ``tests/test_torch_weights_prefix.py`` (11 cases) covering
    schema detection / translation, openpi flat / wrapped, lerobot
    stats / safetensors, autodetect across model families.
  * ``tests/_helpers/validate_lerobot_norm_stats.py`` — manual
    real-data harness that pulls the published HF safetensors and
    runs the loader end-to-end.

Verified end-to-end on the published
``lerobot/pi05_libero_finetuned_v044`` checkpoint:

  Pi05TorchFrontendThor(ckpt, num_views=2, autotune=0,
                         use_cuda_graph=False)
    .set_prompt("pick up the alphabet soup and place it in the basket")
    .infer(obs)
  -> actions shape=(10, 7), dtype=float32, all_finite=True,
     range~[-0.4, 0.5]

The full Pi-family regression on the openpi-converted checkpoints
(test_thor_calibrate_matrix.py) sees zero behaviour change: 12/12
cells PASS at or above their published cosine thresholds.

FA2 build note for CUDA < 12.8
==============================

The default Flash-Attention 2 vendor build emits a ``compute_120``
PTX fallback that ``nvcc`` < 12.8 rejects (``Value 'compute_120' is
not defined``). Cloud users on older CUDA images (e.g. an L40S
running CUDA 12.4) can set ``FA2_ARCH_NATIVE_ONLY=ON`` to drop the
cross-arch fallback and build SASS for the detected arch only —
~66 % faster build, works on any CUDA toolchain that supports the
target arch. The flag has been in CMakeLists since the build
-slimming work; ``docs/INSTALL.md`` §6.1 now surfaces it.
@LiangSu8899
LiangSu8899 merged commit 43f2863 into main Apr 30, 2026
tzutoo added a commit to tzutoo/FlashRT that referenced this pull request Jun 18, 2026
Two related fixes for the "Stream ended without finish_reason" failure users
hit when a pi/coding-agent session grows large (e.g. pasting whole articles):

1. Overflow no longer crashes the SSE stream (the real bug).

   _effective_max_tokens and validate_request_bounds clip max_tokens against
   len(prompt_tokens) — the freshly-rendered prompt from req.messages. But the
   engine is often fed a LONGER token stream on the message_append / capsule
   path: the hot session journal can include hidden control tokens (Qwen3.6
   non-thinking <think></think> blocks, tool-call boundaries) that OpenAI-
   compatible clients never resend. The rendered-prompt clip under-counts, the
   prefill hits the max_seq ceiling mid-request, raises ValueError, and for an
   SSE stream that surfaces to the client as a broken response instead of a
   clean error.

   New _reclip_max_tokens_for_engine re-derives the bound from the ACTUAL
   engine token count right before prefill (both _complete and _stream_openai).
   If the journal still fits, max_tokens is clipped down and the request
   succeeds normally. If the journal has grown so large that even one output
   token won't fit, it raises a clear ValueError that the HTTP layer maps to a
   400: "the active conversation is N tokens long, which already fills
   --max-seq; start a new session ...".

   Verified end-to-end on the live server:
   - large session + 8192 out (the crash case): now HTTP 200, output clipped
   - streaming variant: clean [DONE] + finish_reason (was broken stream)
   - prompt alone > max_seq: clean HTTP 400 with actionable message

2. Default --max-seq raised 131072 (128K) -> 196608 (192K).

   128K overflowed on real paste-heavy sessions (95K+). 192K fits a 95K
   session + multi-turn growth + 8192 output with measured ~108-120 tok/s
   steady-state. The overflow fix (flashrt-project#1) makes the edge case return a clean 400
   instead of crashing, so 192K is safe as the default. ~1.3 GB idle free VRAM
   (borderline on WSL2; docker restart recovers). Dockerfile.server CMD,
   BUILD_NOTES.md, and benchmarks/qwen36_graph_results.md updated.
@LiangSu8899 LiangSu8899 mentioned this pull request Jun 21, 2026
LiangSu8899 added a commit that referenced this pull request Jun 21, 2026
The M=16/N=8 MoE tile (nexn2_moe_m16_mma) was the #1 prefill cost after the WY
GDN landed (28.6%, ~8x off the HBM roofline). Its total traffic ~ (1/M_tile +
1/N_tile) is dominated by re-reading the activation rows once per N-block and
each expert weight once per 16-row tile. This kernel widens the tile to 64 rows
x 16 cols (4 row-blocks x 2 col-blocks sharing every loaded K chunk, one warp,
32 fp32 accumulators) -> traffic 1/64 + 1/16, 2.07x the M16 throughput at 1024
rows standalone, cos identical (same FP4 block-scaled mma). New additive kernel;
the M16 path is untouched and kept as a fallback. Forward gains _moe_experts_m64
(64-row expert tiling), default for S >= 64.

E2E prefill @s=2048 6969 -> 7836 tok/s, @s=512 5362 -> 5471, cos preserved
(0.9945 vs HF golden). Toward the llama.cpp NVFP4 prefill target (9.5k).
LiangSu8899 added a commit that referenced this pull request Jun 21, 2026
…nse-proj path

The prefill dense projections (fp32/TF32 cutlass) became the #1 wall (33%)
after the GDN + MoE work. Two paths added:

1. nexn2_w4a16_gemm (new, additive): true W4A16 -- BF16 activation x NVFP4
   weight, dequanted to bf16 in smem, bf16 m16n8k16 tensor-core mma, multi-warp
   CTA tile + cp.async. Precise (bf16 activation, red-line-safe for in_proj) and
   reads 4-bit weight. cos=1.0 vs the dequant reference. Currently ~compute-
   roofline-bound at 25% occupancy (28KB smem) so only ~1x the fp32 path -- the
   remaining work is occupancy tuning (drop the sW staging buffer / ldmatrix) to
   reach the ~4x the bf16 mma should give. Correct; perf in progress.

2. _gemm_fp4 / _DENSE_FP4 (frontend, default OFF): routes the non-red-line
   projections through the existing fp4 W4A4 GEMM -- crosses the llama.cpp 9.5k
   prefill target (9686 tok/s) but the fp4 activation drops cos to 0.987 (within
   the 0.984 red line, tight). Available behind the flag; default stays the
   precision-safe fp32 path (8541 tok/s, cos 0.994) pending the W4A16 perf tune.

All add-only; existing kernels untouched.
chenping9999 added a commit to chenping9999/FlashRT that referenced this pull request Jul 9, 2026
Three quality-neutral fusion points on the default FP8+NVFP4-VAE path
(steady-state 5.86s -> 5.73s; end-to-end 6.71s -> 6.56s, 2.64x vs fp16
ref). PSNR unchanged at 35.2 dB mean vs the fp16 reference.

* NVFP4 fused norm+silu+NVFP4-quant + FP4 cache reuse (flashrt-project#1): the sister
  norm of each fully-NVFP4 WanResidualBlock emits the FP4 activation
  directly via fp16_rms_silu_quant_nvfp4_cl_ndhwc (no fp16 round-trip)
  and the conv reuses Direction-2's rolling 2-frame FP4 cache. Mirrors
  diffusers' [prev, current] cache padding required by the WanVAE
  per-frame decode streaming loop. Gated by FLASHRT_NVFP4_FUSED_NORMQUANT
  (default 1).

* FP8 fused norm+silu+running-amax+FP8-quant (flashrt-project#2): same idea for the
  FP8-conv residual blocks via fp16_rms_silu_amax_quant_fp8_ndhwc_nozero
  (accumulates into the running amax so the new-x scale stays consistent
  with the causal cache). Gated by FLASHRT_FP8_FUSED_NORMQUANT (default 1).

* Q/K bias fused into rmsnorm+RoPE+int8-quant (flashrt-project#3): cuBLASLt's
  CUBLASLT_EPILOGUE_BIAS is NOT_SUPPORTED for FP8 (e4m3) GEMMs, so the
  Q/K projection bias is added pre-norm inside the downstream
  fp16_rmsnorm_rope_quant_int8 kernel (fp32 add, slightly more precise
  than the fp16 add it replaces). Eliminates 720 of 1092 add_bias_vec8
  calls per denoise; V and proj_out keep their bias. Adds
  gemm_from_fp8_ext_nobias to feed the no-bias Q/K GEMM output.

Also: steady-state uses the eager manual denoise path by default
(FLASHRT_FP8_EAGER_MANUAL=1, avoids per-step torch.cat + scheduler
sync); remove dead Triton wan_rms_norm_ncdhw kernel; update
docs/minimax_remover_usage.md with the new numbers, env vars and
fusion notes.
LiangSu8899 added a commit that referenced this pull request Jul 12, 2026
…used VAE and transformer kernels (#142)

* feat(minimax-remover): add NVFP4 kernelized video inpainting pipeline

Performance highlights (RTX 5060 Ti, SM120, CUDA 13):
- End-to-end: 2.6× speedup (30.7s → 11.9s for 123 frames, 3 segments)
- RTF improvement: 6.0 → 2.3 (processing-time / clip-duration)
- Per-layer GEMM: 1.14–1.30× speedup vs fp16 matmul
- FP4 GEMM with quantize overhead: 4–9× faster than fp16 on large FFN projections
- Precision: PSNR 52.0 dB (mean) / 45.2 dB (worst frame) vs fp16

Optimizations:
- NVFP4 W4A4 quantization with dynamic per-call activation (no offline calibration)
- Fused LayerNorm + adaLN + gate-residual in single fp32-stat Triton kernel
- Fused FFN-up GEMM + bias + GELU → FP4 output (skip re-quantization for FFN-down)
- QKV quantize-once optimization (reuse quantized norm output for Q/K/V projections)
- Manual graph-capturable denoise loop with CUDA Graph support
- BF16 transformer (NVFP4-native, eliminates fp16↔bf16 casts)
- SageAttention / FA2 backend integration

* feat(minimax-remover): lazy-load runtime deps and improve build docs

* fix(minimax-remover): share attention mode dispatch

* docs(minimax-remover): mention scipy extra

* feat(minimax-remover): add FP8 W8A8 kernelized inference pipeline

- Add FlashRTFp8Linear with static calibration for FP8 GEMM acceleration
- Add MiniMaxRemoverPipelineFP8 for full-frame inpainting with FP8
- Add fused kernel blocks (adaLN, gate-residual, GELU)
- Add Triton Flash Attention (fp16/fp8 variants)
- Add Triton fused LayerNorm with fp32 statistics
- Add Triton RoPE for native [B,S,H,D] layout
- Add shared utilities for kernel loading and validation

* docs(minimax-remover): add FP8 pipeline and update documentation for precision paths

- Add MiniMaxRemoverPipelineFP8 as default full-frame pipeline (FP8 W8A8)
- Clarify NVFP4 is only suitable for small cropped regions
- Add performance comparison table and correctness metrics
- Update quickstart example with --use-fp4 flag
- Refactor kernel loading into shared _utils module

* refactor(minimax-remover): unify attention dispatch and consolidate triton kernels

- Make _attention the single source of truth for FLASHRT_ATTN_MODE routing
  (sage_*/triton_fp8/triton_fp16/fa2); _kern_block now reuses it via
  install_attention (with install_fa2_attention back-compat alias) instead
  of duplicating the dispatch and FA2 processor.
- Consolidate _triton_fused_norm.py and _triton_rope.py into _kernels.py.
- Add triton_fp8/triton_fp16 modes to the shared attention_forward dispatch.
- Fail fast when FLASHRT_NORM_MODE=fp16 but the ada_layer_norm_fp16 kernel
  symbol is absent in the current flash_rt_kernels build.
- Fix _fp8_linear docstring to match the set_calibration/freeze_calibration API.

* fix(minimax-remover): avoid FP8 class call patch

* feat(minimax-remover): add fp16-native fused RMS_norm VAE optimization

Add a fp16-native fused RMS_norm kernel that replaces diffusers'
WanRMS_norm.forward (4 full-tensor fp32 passes) with a single-pass
kernel keeping fp16 in/out with fp32 internal stats (~6x faster per
call, preserving ~40 dB PSNR vs fp16 reference).

- csrc/quantize/fp16_rms_norm_ncdhw.{cu,cuh}: new CUDA kernel
- csrc/bindings.cpp + CMakeLists.txt: register fp16_rms_norm_ncdhw
- flash_rt/models/minimax_remover/_kernels.py: Triton wan_rms_norm_ncdhw
- flash_rt/models/minimax_remover/_vae_opt.py: VAE optimization patcher
- examples/minimax_remover_quickstart.py: add --vae-opt flag

* feat(minimax-remover): add fused fp16 RMS_norm+SiLU kernel and standalone module

Add fp16_rms_silu_ncdhw CUDA kernel that fuses RMSNorm + SiLU into a
single pass for WanResidualBlock, eliminating one full tensor read/write
and one kernel launch per site (~522 sites/decode). Single-kernel cosine
>= 0.9999999 vs fp32 reference.

Move both fp16 VAE kernels (fp16_rms_norm_ncdhw, fp16_rms_silu_ncdhw)
from csrc/quantize/ into a dedicated csrc/kernels/minimax_remover/
folder and build them as a standalone flash_rt_minimax_remover pybind
module (FLASHRT_ENABLE_MINIMAX_REMOVER=ON, OFF by default), following
the flash_rt_omnivoice opt-in pattern. The kernels are removed from the
default flash_rt_kernels target.

Also eliminate the redundant fp32 cast in WanUpsample (nearest-exact
upsample is index-only, so fp16 == fp32 bit-for-bit) and enable
--vae-opt by default in the quickstart.

Performance (RTX 5060 Ti, tennis 70 frames 432x240):
  fp16 reference:        17.33s
  FP8 (no VAE opt):      11.78s  (1.47x)
  FP8 + VAE opt:         10.93s  (1.59x)  PSNR 40.9 dB

* feat(minimax-remover): add channels-last 3D VAE pipeline for conv3d acceleration

Add fp16_rms_norm_ndhwc / fp16_rms_silu_ndhwc CUDA kernels that
operate natively in channels-last (NDHWC) memory format, where the C
dimension is contiguous — enabling coalesced warp-level reduction
without shared memory.

Wire a full channels-last pipeline in install_vae_optimizations():
  1. Convert all 61 WanCausalConv3d weights to channels_last_3d.
  2. Patch WanCausalConv3d.forward to preserve CL through cat/pad/conv.
  3. Swap residual-block and attention-block norm kernels to NDHWC
     variants so norm output stays CL — no format break before conv.

This eliminates 97% of cuDNN's per-conv nchw<->nhwc conversion kernels
(287 ms -> 9 ms per decode) and gives ~1.3x per-conv speedup from
cuDNN's preferred CL algorithm variant.

End-to-end (tennis 70 frames 432x240, RTX 5060 Ti):
  fp16 reference:  15.60 s
  FlashRT default: 10.03 s  (1.55x speedup, PSNR 40.8 dB, VRAM 2.49 GB)

Zero precision loss: PSNR 40.8 dB vs fp16 reference, identical to the
NCDHW path within fp16 rounding.

* feat(minimax-remover): add FP8 implicit-GEMM conv3d kernel for VAE acceleration

Hand-rolled FP8 e4m3 implicit-GEMM 3x3x3 causal conv3d kernel that
replaces cuDNN fp16 conv3d for applicable layers (Ci % 32 == 0).

The kernel computes im2col indices on-the-fly inside the MMA loop via
cp.async, avoiding the 268MB intermediate matrix that made the naive
im2col + _scaled_mm approach 3.5x slower than cuDNN. Adapted from the
motus v17 kernel with three key changes: fp16 output/bias (VAE stays
fp16), per-output-channel alpha vector (act_scale * w_scale[co] for
higher PSNR), and fused activation quantization (2-pass device-side
amax + quantize, no host sync, shared scale across cache+new frames).

New files (all in csrc/kernels/minimax_remover/):
- fp8_conv3d_mm_ndhwc_fp16out.cu/.cuh: 128/128/32 tile, 8 warps,
  2-stage cp.async, virtual cache concat, direct causal output,
  bias-fused epilogue with per-channel dequant
- fp16_quant_fp8_per_tensor.cu/.cuh: amax_fp16 + atomicMax (multi-
  tensor accumulation) and quantize_fp16_fp8_with_amax (standalone
  quantize pass reading pre-computed amax from device)

Performance (RTX 5060 Ti, 70 frames 432x240):
  baseline (no flashrt):     17.33s  (1.00x)
  channels-last only:        10.01s  (1.73x, PSNR 40.85 dB)
  + FP8 conv3d (default):     8.75s  (1.98x, PSNR 39.34 dB)

49 conv3d layers quantized (encoder + decoder). Non-applicable layers
(1x1x1, 3x1x1, Ci%32!=0, Co<8) fall back to cuDNN fp16. Toggle via
--fp8-conv / --no-fp8-conv.

* feat(minimax-remover): add fused norm+silu+amax kernel and running-max amax pipeline

Add three new fused NDHWC kernels and a dual-quantize launcher to
further accelerate the FP8 conv3d VAE pipeline:

New kernels (flash_rt_minimax_remover module):
- fp16_rms_silu_amax_ndhwc: fuses amax computation into the norm+silu
  pass via warp-level reduction + atomicMax. Eliminates a separate
  full-tensor read for amax per conv layer.
- fp16_rms_silu_quant_fp8_ndhwc: fuses norm+silu with FP8 e4m3
  quantization (reads pre-computed amax from device, no fp16 write).
- fp16_rms_silu_amax_quant_fp8_ndhwc: 2-pass combined launcher that
  produces only fp8 output + scale (no fp16 intermediate).
- quantize_fp16_fp8_with_amax_dual: quantizes two fp16 buffers (cache
  + new) with a shared amax in a single kernel launch.

Pipeline optimizations (_vae_opt.py):
- Running-max amax: the norm module accumulates amax into a persistent
  device-side buffer (atomicMax) shared with the sister conv module.
  Since cache_x was a previous output of the same norm, its amax is
  already covered -- the conv skips the cache amax pass entirely,
  saving one full read of the 2-frame cache tensor per layer.
- Sister-norm linkage: each FP8-enabled conv gets a reference to its
  norm module to access the pre-computed amax (set up during
  _install_fp8_conv3d_pipeline).
- Dual-quantize: cache + new quantized in a single launch.

Result (RTX 5060 Ti, tennis 70 frames 432x240):
  Previous: 8.75s, 39.3 dB PSNR median, 1.98x vs baseline
  Current:  8.58s, 39.9 dB PSNR median, 2.02x vs baseline
Both speed and precision improved simultaneously -- the running-max
scale is temporally consistent across frames, reducing quantization
noise compared to per-frame dynamic amax.

* feat(minimax-remover): add fused FFN bias+gelu+quant epilogue kernel for transformer denoise

Collapse the 3-kernel FFN glue sequence (add_bias_fp16 + gelu_inplace_fp16
+ quantize_fp8_static_fp16) into a single-pass fp16->fp8 epilogue kernel
(bias_gelu_quant_fp16_fp8). The fp8 output is the pre-quantised input of
the next FP8 Linear, which skips its own activation quantise.

All bias+gelu arithmetic is done in fp32 before the fp8 cast, so the
result is slightly more accurate than the original path (which rounds to
fp16 twice). End-to-end PSNR improves 39.9 -> 40.0 dB vs fp16 reference.

Add mid-inference calibration freeze: a one-shot transformer forward hook
freezes FP8 scales after the first denoise step, so steps 2..N run with
static scales and the fused epilogue active -- a single-call invocation
benefits without a separate warm-up pass.

Denoise GPU time: 3.73s -> 3.16s (-15%). End-to-end: 8.58s -> 7.56s
(2.29x vs fp16 baseline). Peak VRAM unchanged at 2.51 GB.

Files:
- fp16_bias_gelu_quant_fp8.cu/.cuh: fused kernel (gelu + identity variants)
- _fp8_linear.py: FlashRTFp8Linear.gemm_no_bias / forward_from_fp8 helpers
- _kern_block.py: FFN path dispatches fused epilogue (falls back during
  calibration)
- _fp8_pipeline.py: mid-inference freeze via one-shot forward hook
- minimax_remover_extra_bindings.cpp + CMakeLists.txt: pybind + build

* feat(minimax-remover): add FP8 CUDA-graph capturable denoise path

Add a manual graph-capturable denoise loop for the FP8 (W8A8) path that
mirrors the NVFP4 _manual_denoise design but calls the installed FP8
block forwards. The diffusers denoise loop cannot be captured directly
because condition_embedder uses torch.arange (CPU op) and
FlowMatchEulerDiscreteScheduler.step mutates CPU state. The manual loop
pre-computes time embeddings + norm_out modulation + RoPE + dt outside
the graph, then runs pre-allocated buffer copies + transformer forward +
in-place Triton euler step -- all kernel launches, fully capturable.

Gated behind FLASHRT_FP8_GRAPH=1 (default off). The first call uses the
diffusers path for calibration; the graph is captured on the second call
and replayed thereafter. Requires a graph-safe attention backend
(triton_fp8/triton_fp16); the default sage_fp8 is not graph-safe.

Also fixes a transformer dtype resolution bug (next(parameters()) hits an
fp32 scale_shift_table) and uses per-channel latent normalize/denormalize
in the manual path (the shared Triton helper collapses latents_std to a
scalar via .max(), which is wrong for per-channel stats).

Performance note: graph capture is technically correct but not a net win
here -- the denoise loop is GPU-bound (graph saves only ~20ms), and the
graph-safe attention backends are ~1.1s slower than sage_fp8. Retained
for when a fast graph-safe attention backend (e.g. flash_rt_fa2) is built.

* feat(minimax-remover): add fused bias+gate+residual and fp16x8 bias-add kernels

Collapse the O-projection / FFN-down block tails
(add_bias_fp16 + gate_mul_residual_bcast) into a single fp16x8 (uint4)
kernel that reads the GEMM output once and writes straight into the
residual, eliminating the intermediate fp16 RMW pass across 720 slots
per denoise. Also add a vectorised fp16_add_bias_vec8 for the Q/K/V
projections (8x fewer memory transactions than the scalar path).

Denoise GPU kernel time 3.10 s -> 3.03 s; end-to-end 7.57 s at 2.30x
vs the fp16 reference (17.42 s). PSNR 40.0 dB median, 36.2 dB worst.
Wall time is launch-bound at 12 steps x 30 blocks. Toggle via
FLASHRT_DISABLE_BIAS_GATE=1 for A/B without a rebuild.

* feat(minimax-remover): add fused adaLN+quant (shared-scale QKV) and fused RMSNorm+RoPE kernels

Two new CUDA kernels for the MiniMax-Remover transformer denoise:

* fp16_ada_layernorm_quant_fp8: one-pass fp32-stat LayerNorm + adaLN
  modulation + per-tensor FP8 e4m3 quantise. Feeds a shared-scale FP8
  tensor into Q/K/V (one quantise for three Linears, three descales)
  via FlashRTFp8Linear.gemm_from_fp8_ext, eliminating the three
  per-Linear activation-quant passes. Shared max scale also
  suppresses per-Linear outlier saturation (PSNR 40.05 -> 40.81 dB).

* fp16_rmsnorm_rope_bshd: one-pass per-token RMSNorm (fp32 stats +
  fp16 affine) + interleaved RoPE on the native [B,S,H,Dd] fp16
  layout. Replaces the Triton rms_norm_fp32stat + rope_apply_bshd
  pair and eliminates one full fp16 R/W of Q and K per attention
  block.

End-to-end tennis clip (70 frames, 432x240, RTX 5060 Ti):
7.57 s -> 7.28 s (-4%, 2.30x -> 2.38x vs fp16 ref), PSNR mean 40.81 dB.

Toggles: FLASHRT_DISABLE_ADA_QKV=1, FLASHRT_DISABLE_RMSNORM_ROPE=1.

* feat(minimax-remover): fuse norm2+quant for FFN proj0, add VAE nozero quant variant

Transformer denoise:
* norm2 now uses fp16_ada_layernorm_quant_fp8 to produce fp8 directly
  for FFN proj0, eliminating the intermediate fp16 [S,D] write+read+
  quantize (4×S×D bytes/call × 360 calls). Toggle: FLASHRT_DISABLE_NORM2_FFN=1.

VAE kernels:
* Add fp16_rms_silu_amax_quant_fp8_ndhwc_nozero variant that skips
  zeroing amax_buf for running-max mode (retained for future use;
  direct VAE fusion blocked by WanResidualBlock cache slice needing fp16).

End-to-end tennis clip (70 frames, 432×240, RTX 5060 Ti):
7.28 s → 7.25 s (2.38x → 2.39x vs fp16 ref), PSNR mean 40.86 dB.

* feat(minimax-remover): add fused RMSNorm+RoPE+int8 quant kernels for Q/K

* docs(minimax-remover): update benchmark results with serial A/B measurements

* feat(minimax-remover): add purpose-built NVFP4 W4A4 VAE conv3d kernel

Add a WanVAE-specific NVFP4 (W4A4) conv3d path that accelerates VAE
encode/decode by ~16% on top of the existing FP8 transformer path.

New CUDA kernels (in csrc/kernels/minimax_remover/):

- nvfp4_conv3d_ndhwc_fp16out.cu: Purpose-built NVFP4 implicit-GEMM
  conv3d using mma.sync.kind::mxf4nvf4 (e2m1 x e2m1, UE4M3 block
  scales). Outputs fp16 NDHWC directly (vs motus kernel's bf16 NCDHW),
  eliminating two conversion passes per layer. Tile: BLOCK_M=128,
  BLOCK_N=128, BLOCK_K=64, 8 warps, 2-stage cp.async pipeline.
  Constraint: Ci % 64 == 0 (covers WanVAE Ci=192/384).

- fp16_quant_nvfp4_ndhwc.cu: Fused fp16 -> NVFP4 quantization kernel
  with per-16-element UE4M3 block scales. Three variants:
  (1) plain quant (NCDHW input),
  (2) plain quant (channels-last 3D input — eliminates contiguous()
      copy, coalesced channel reads),
  (3) fused RMS_norm + SiLU + NVFP4 quant (channels-last input, single
      kernel replaces 3 separate passes). kThreadsY=6 design supports
      all WanVAE channel sizes (96/192/384).

Python integration (flash_rt/models/minimax_remover/_vae_nvfp4.py):

- install_vae_nvfp4(): pre-quantizes eligible conv3d weights to NVFP4
  at install time; hooks WanCausalConv3d.forward to dispatch to the
  NVFP4 kernel for eligible layers (Ci >= 192, 3x3x3, Ci % 64 == 0).
  38 layers quantized (encode + decode).

- Rolling 2-frame FP4 cache: stores quantized FP4+SF from the previous
  call and reuses it as the causal-conv cache, eliminating per-call
  cache re-quantization. Handles T_new=1 (decode) by combining
  [prev_frame, current_frame] in a sliding window.

- Channels-last direct input: detects channels-last 3D tensors and
  uses the CL quant kernel variant, avoiding a contiguous() copy.

Quickstart integration: NVFP4 VAE is enabled by default; --no-nvfp4-vae
disables it.

Performance (RTX 5060 Ti, 70-frame tennis clip, 432x240):

  Non-FlashRT (fp16):    17.33s   1.00x   (reference)
  FlashRT FP8:            7.18s   2.41x   PSNR 40.0 dB vs fp16
  FlashRT FP8+NVFP4 VAE:  6.71s   2.58x   PSNR 34.7 dB vs fp16

  VAE encode: 1829 -> 1564 ms (-14.5%)
  VAE decode: 1664 -> 1438 ms (-13.6%)
  VAE total:  3493 -> 3002 ms (-16.4%)

The NVFP4 VAE path works correctly on full-frame inputs (unlike the
NVFP4 transformer path which is broken on full-frame due to FP4 error
accumulation over the 12-step denoise loop). The VAE is a single-pass
encoder/decoder with no iterative error accumulation.

Documentation (docs/minimax_remover_usage.md) updated to:
- Distinguish NVFP4 VAE (works, default ON) from NVFP4 transformer
  (broken on full-frame, small-region only)
- Add new kernel entries, performance row, CLI flag, env vars
- Add usage example for the NVFP4 VAE path

* feat(minimax-remover): fuse norm+quant and Q/K bias for ~2.1% speedup

Three quality-neutral fusion points on the default FP8+NVFP4-VAE path
(steady-state 5.86s -> 5.73s; end-to-end 6.71s -> 6.56s, 2.64x vs fp16
ref). PSNR unchanged at 35.2 dB mean vs the fp16 reference.

* NVFP4 fused norm+silu+NVFP4-quant + FP4 cache reuse (#1): the sister
  norm of each fully-NVFP4 WanResidualBlock emits the FP4 activation
  directly via fp16_rms_silu_quant_nvfp4_cl_ndhwc (no fp16 round-trip)
  and the conv reuses Direction-2's rolling 2-frame FP4 cache. Mirrors
  diffusers' [prev, current] cache padding required by the WanVAE
  per-frame decode streaming loop. Gated by FLASHRT_NVFP4_FUSED_NORMQUANT
  (default 1).

* FP8 fused norm+silu+running-amax+FP8-quant (#2): same idea for the
  FP8-conv residual blocks via fp16_rms_silu_amax_quant_fp8_ndhwc_nozero
  (accumulates into the running amax so the new-x scale stays consistent
  with the causal cache). Gated by FLASHRT_FP8_FUSED_NORMQUANT (default 1).

* Q/K bias fused into rmsnorm+RoPE+int8-quant (#3): cuBLASLt's
  CUBLASLT_EPILOGUE_BIAS is NOT_SUPPORTED for FP8 (e4m3) GEMMs, so the
  Q/K projection bias is added pre-norm inside the downstream
  fp16_rmsnorm_rope_quant_int8 kernel (fp32 add, slightly more precise
  than the fp16 add it replaces). Eliminates 720 of 1092 add_bias_vec8
  calls per denoise; V and proj_out keep their bias. Adds
  gemm_from_fp8_ext_nobias to feed the no-bias Q/K GEMM output.

Also: steady-state uses the eager manual denoise path by default
(FLASHRT_FP8_EAGER_MANUAL=1, avoids per-step torch.cat + scheduler
sync); remove dead Triton wan_rms_norm_ncdhw kernel; update
docs/minimax_remover_usage.md with the new numbers, env vars and
fusion notes.

* fix(minimax-remover): address PR review checklist compliance

Clean up the fused norm+quant / Q/K bias path so it satisfies
docs/pr_review_checklist.md (hot-path cleanliness, fail-fast, doc/code
consistency, no dead code, green default test suite).

* Hot-path allocation: fp16_rmsnorm_rope_quant_int8_{q,k} did a
  cudaMallocAsync + cudaFreeAsync of the per-token rstd buffer on every
  Q/K call (~720x/denoise). Add a caller-owned rstd_buf scratch
  parameter (binding default 0 -> transient fallback) and reuse a
  persistent [B*S] fp32 buffer in FlashRTFA2Processor keyed by (B,S),
  shared by Q and K on the same stream. Zero allocation in steady state.
* Fail-fast: check the kernel return code in the attention fused-quant
  path and raise a clear RuntimeError (was silently ignored, unlike the
  VAE paths).
* Docs/code consistency: remove the dead _USE_FUSED_NORMQUANT module
  variable in _vae_nvfp4.py whose "default OFF / diverges ~27 dB"
  comment contradicted the actual default-ON behaviour (35.2 dB) and the
  usage docs; fix the stale kernel name in gemm_from_fp8_ext_nobias
  docstring (fp16_rmsnorm_rope_bias_quant_int8 -> ..._quant_int8_q/k).
* Dead code: remove the unused warp_reduce_max_rq device helper (caused
  an nvcc "declared but never referenced" warning) and the never-called
  _cache_fp16_for_next nested function in the NVFP4 fused residual path.
* Tests: repair the long-failing
  test_fp8_pipeline_call_does_not_patch_pipe_class by completing the
  pipe/transformer stubs (config.eps, parameters(), vae,
  register_forward_hook that fires on the stub forward) and exercising
  the delegation path via FLASHRT_FP8_EAGER_MANUAL=0; the class-isolation
  guarantee under test is independent of the steady-state dispatch mode.

Verified on RTX 5060 Ti (SM120, CUDA 13): smoke suite 18 passed / 1
skipped; quickstart default stack 6.53s (2.66x vs fp16 ref), PSNR 35.15
dB mean / 31.63 dB worst vs the fp16 reference (matches docs 35.2/31.7).

* Fix MiniMax remover optional deps and arch gate

---------

Co-authored-by: LiangSu8899 <[email protected]>
LiangSu8899 pushed a commit that referenced this pull request Jul 24, 2026
…151)

* feat(sm89): residual-fold GEMM epilogue (idiom validation, not wired)

Add RESID template param to fp8_bs_gemm_device.cuh: D = bf16(acc) + resid,
folding the residual add into the GEMM epilogue (no separate residual_add
launch, no D HBM round-trip). if constexpr (RESID) dead-strips the residual
branch, so RESID=false stays byte-identical to the baseline kernel.

Adds 4 residual-fold tile variants (32x64 / 64x64 / 64x64_s1 / 128x128_s1)
for the prefill down-proj shapes, bound bench-only under
ENABLE_QWEN3_VL_DEV_KERNELS (additive; production dispatcher untouched).

Phase 1 finding: prefill's residual add is ALREADY fused by
residual_add_rms_norm_to_fp8 on every non-last layer, so residual-fold only
saves ~1 [S,hidden] bf16 transfer (0 launches). Validated as the
epilogue-fold idiom proof (cos 1.0 vs fp32 ref, 1-ULP reassociation diff) but
NOT wired — real prize is silu-fold (Phase 2). Bench script included.

* feat(sm89): GeGLU silu-fold megakernel for prefill gate_up (opt-in)

Fuse gate_up GEMM + silu_mul + per-token block-128 FP8 quant into one launch,
eliminating the [S, 2*inter] BF16 transient the baseline two-launch path
(gate_up GEMM -> silu_mul_merged_to_fp8) materializes. Mirrors #134's SwiGLU
epilogue fold (sm120) and sm100 flashrt_megakernel_geglu's gate-in-smem
pattern, ported to sm89's hand-written cp.async + ldmatrix.x4 + mma.m16n8k32
idiom (no TMA/tcgen05).

Two kernel variants in fp8_bs_gemm_device.cuh (additive; fp8_bs_gemm_kernel
untouched):
  - fp8_bs_geglu_silu_fold_kernel: two-pass (gate -> smem -> up), the shipped
    tile (32x128_w4_s1). Single B smem region reused across passes; only one
    accumulator live at a time (~70 regs).
  - fp8_bs_geglu_silu_fold_apersist_kernel: A-persistent interleaved
    experiment (both gate+up acc in regs, B reloaded per k-iter). Kept as a
    bench-only tile; the two-pass s1 won the e2e sweep.

ncu diagnosis (issue #1 Phase 2) isolated why naive two-pass lost: s2 occupancy
collapse (gate_smem + 2 cp.async stages -> 49.7KB -> 1 CTA/SM, 8.33% occupancy)
+ 2x pipeline drain. s1 (29.7KB, 3 CTA/SM) recovers and wins in the
launch-bound regime. The gate_up GEMM is compute-bound above the S crossover,
so the fused path is shape-gated per-inter (2B S in [96,192], 8B S=128 only);
outside the band the baseline two-launch path runs unchanged (default
byte-identical, env FLASH_RT_SM89_SILU_FOLD_PREFILL=1 opt-in).

Correctness: e2e prefill cosine 0.9992-1.0 vs baseline, argmax preserved
across S (saturating-FP8 real activations). One fewer bf16(acc) rounding than
baseline (documented). Fixed an out_scale write bug (single-thread guard left
rows 1..BM-1 unwritten -> garbage scale, correct fp8).

E2E prefill (4090, 30-iter median, fold on vs off):
  2B S=128: 6.10 -> 5.64 ms  +7.5%
  2B S=192: 6.10 -> 5.54 ms  +9.2%
  8B S=128: 13.97 -> 13.45 ms +3.7%  (stable across 3 runs)
Above the band: no regression (falls back to baseline).

Bench script scripts/test_geglu_silu_fold_correctness.py included.
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.

1 participant