FastVideo icon indicating copy to clipboard operation
FastVideo copied to clipboard

[kernel] [Feature] NVFP4 QAT: fix broken measurement plumbing and build MFU foundations (pre-work for DGX Spark QAT kernel optimization)

Open yogyam opened this issue 3 months ago • 2 comments

Motivation

The Q3 roadmap (#1603) lists "Optimize nvfp4 QAT kernel for DGX Spark" (currently unclaimed) and "Optimize QAD MFU". While mapping the NVFP4/QAT code to prepare for that work, I found that the measurement layer those items depend on is partially broken or missing — we can't optimize what we can't measure. This issue collects the concrete gaps, attaches small PRs for the immediately fixable subset, and proposes the follow-ups.

Verified defects (file:line refs against current main)

  1. Dead FP4 quant microbenchmarks — fastvideo-kernel/attn_qat_infer/quantization/bench/bench_quant_{q,k,v}.py do import fp4quant, but the built extension is named fp4quant_cuda, so all three benchmarks fail at import.
  2. Misleading error string — fastvideo-kernel/csrc/turbodiffusion/quant/quant.cu:66 raises "Unsupported input data type for quantize_to_fp4." but the kernel quantizes to int8 (ElementOut = int8_t) and is exported as quant_cuda.
  3. smooth_q=True crashes unconditionally — in fastvideo-kernel/python/fastvideo_kernel/triton_kernels/attn_qat_train.py the backward sets q_m = None then calls q_m.repeat_interleave(...) (its dependency triton_group_mean import is commented out at the top of the file). The default smooth_q=False path is unaffected.
  4. MFU numbers are single-GPU-hardcoded — fastvideo-kernel/benchmarks/benchmark_attn_qat_train.py pins RTX_5090_DENSE_BF16_TFLOPS = 209.5, so %MFU output is meaningless on any other device (GB10, GB200, H100, ...).

Structural gaps (proposed follow-ups, seeking maintainer input)

  • No MFU instrumentation in the training loop — fastvideo/train/trainer.py logs only step_time_sec; the one end-to-end MFU calculator (fastvideo/tests/training/Vanilla/mfu_calculation.py) is unreferenced and hard-fails on anything newer than L40S. Happy to design/implement trainer-level MFU logging if maintainers agree on the approach.
  • GB10 (sm_121) build gate inconsistency — the runtime capability allowlist for ATTN_QAT_INFER already includes (12, 1), but the CMake AUTO gate only matches 12.0a and both FP4 targets hard-pin CUDA_ARCHITECTURES "120a", so a DGX Spark never actually gets the kernels it claims to support (kernel README confirms the GB10 CI leg ships with FP4 off).
  • No CI coverage for any FP4/QAT kernel — nothing in .buildkite/ exercises them; a small kernel-test leg on the GB10 cohort being built in #1632 would close that.

Attached PRs

  • [ ] Fix the three plumbing defects (1–3) — #1723
  • [ ] Device peak-TFLOPS table for the QAT benchmark (4) — #1724

Hardware request

I'm developing on Apple Silicon, so everything above is CPU-verifiable — but the actual roadmap item (kernel tuning and validation on sm_121, and honest GB10/GB200 entries for the TFLOPS table) needs Blackwell hardware. I would love access to a DGX Spark to continue this work — or to collaborate with someone who has one (e.g. the GB10 baseline work in #1632). If lab hardware access is possible for contributors, please point me at the process.

/cc @Satyam-53 (perf-CI + #1632) — related to the QAD MFU line you're tracking.

Related resources

  • Q3 roadmap: #1603 (items: "Optimize nvfp4 QAT kernel for DGX Spark", "Optimize QAD MFU")
  • GB10 perf baseline work: #1632
  • Attn-QAT design doc: docs/training/attn_qat.md; kernel build matrix: fastvideo-kernel/README.md

yogyam avatar Aug 19 '26 22:08 yogyam

Welcome to FastVideo! Thanks for opening your first issue.

To help us investigate, please include:

  • FastVideo version: pip show fastvideo
  • GPU: nvidia-smi output (GPU model, driver, CUDA version)
  • Python version: python --version
  • OS: e.g., Ubuntu 22.04

If this is a bug, a minimal reproduction script helps us fix it faster.

Useful links:

github-actions[bot] avatar Aug 19 '26 22:08 github-actions[bot]

Fixed on main.

#1723 and #1724 (merged 2026-09-25) landed all four defects: the quant benches import fp4quant_cuda, the CUDA quant error string no longer claims FP4, smooth_q=True raises an explicit NotImplementedError instead of crashing, and the MFU benchmark derives peak TFLOPS from the device instead of pinning an RTX 5090. Verified at c938a8a; the DGX Spark QAT follow-up has since landed separately (#2103).

Reopen if a case remains.

— fv-superagent · four broken measurements, two fixes, one benchmark that finally knows its GPU · run by aryan5v

fv-superagent avatar Nov 17 '26 18:11 fv-superagent