Skip to content

[misc] Clean up QAD 5090 example inference scripts - #1496

Open
kevin314 wants to merge 6 commits into
mainfrom
klin/5090-test-scripts
Open

[misc] Clean up QAD 5090 example inference scripts#1496
kevin314 wants to merge 6 commits into
mainfrom
klin/5090-test-scripts

Conversation

@kevin314

@kevin314 kevin314 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Cleans up and homogenizes the example inference scripts involved in the 5090 QAD release

Changes

  • Adds test script for NVFP4 Linear + SA2
  • Cleans up TAEHV usage
  • Updates model defaults to FastWan-QAD checkpoints
  • Use shared naming pattern

Test Plan

Tested on RTX 5090, torch=2.12, CUDA 13.0

#NVFP4 Linear + ATTN_QAT_INFER (Modified sageattn3 backend)
python nvfp4_qat_wan2_1_1_3b.py --taehv-checkpoint /path/to/taehv/taew2_1.pth

#NVFP4 Linear + SAGE_ATTN (sageattn2++)
python nvfp4_sa2_wan2_1_1_3b.py --taehv-checkpoint /path/to/taehv/taew2_1.pth

#FP8 Linear + SAGEATTN
python fp8_wan2_1_1_3b.py --taehv-checkpoint /path/to/taehv/taew2_1.pth  

Test Results

Verified visual quality + reported speeds

Checklist

  • I ran pre-commit run --all-files and fixed all issues
  • I added or updated tests for my changes
  • I updated documentation if needed
  • I considered GPU memory impact of my changes

For model/pipeline changes, also check:

  • I verified SSIM regression tests pass
  • I updated the support matrix if adding a new model

@mergify mergify Bot added type: misc Cleanup, config, dependencies scope: inference Inference pipeline, serving, CLI scope: kernel CUDA kernels, fastvideo-kernel labels Jun 25, 2026
@mergify

mergify Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 1 protections blocking · waiting on 👀 reviews and 🤖 CI

Protection Waiting on
🔴 PR merge requirements 👀 reviews and 🤖 CI

🔴 PR merge requirements

Waiting for

  • #approved-reviews-by>=1
  • check-success=full-suite-passed
This rule is failing.
  • #approved-reviews-by>=1
  • check-success=full-suite-passed
  • check-success=fastcheck-passed
  • check-success~=pre-commit
  • title~=(?i)^\[(feat|feature|bugfix|fix|refactor|perf|ci|doc|docs|misc|chore|kernel|new.?model|skill|skills|infra)\]

@mergify

mergify Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase:

git fetch origin main
git rebase origin/main
# Resolve any conflicts, then:
git push --force-with-lease

@mergify mergify Bot added the needs-rebase PR has merge conflicts label Jun 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors and updates several inference optimization scripts (FP8, NVFP4 QAT, and a new SageAttention 2 script) to use a unified TaehvDecoder class and the updated PipelineConfig system, while also updating project dependencies in pyproject.toml and adjusting a CUDA kernel. The review feedback highlights critical issues that need to be addressed: a typo in the PyTorch dependency index name in pyproject.toml, missing return_frames parameters in generator requests across multiple scripts when TAEHV is enabled (which will cause runtime crashes), and an incorrect CUDA architecture format (12.0a instead of 120a) in the environment configuration for Blackwell GPUs.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pyproject.toml Outdated
Comment thread examples/inference/optimizations/fp8_wan2_1_1_3b.py
Comment thread examples/inference/optimizations/fp8_wan2_1_1_3b.py
Comment thread examples/inference/optimizations/nvfp4_qat_wan2_1_1_3b.py
Comment thread examples/inference/optimizations/nvfp4_qat_wan2_1_1_3b.py
Comment thread examples/inference/optimizations/nvfp4_sa2_wan2_1_1_3b.py
Comment thread examples/inference/optimizations/nvfp4_sa2_wan2_1_1_3b.py
Comment thread examples/inference/optimizations/nvfp4_qat_wan2_1_1_3b.py Outdated
Comment thread examples/inference/optimizations/nvfp4_sa2_wan2_1_1_3b.py Outdated
@kevin314
kevin314 force-pushed the klin/5090-test-scripts branch from 4400eef to 58c3148 Compare June 25, 2026 11:28
@mergify mergify Bot removed the needs-rebase PR has merge conflicts label Jun 25, 2026
@kevin314

Copy link
Copy Markdown
Collaborator Author

return_frames defaults to True in OutputConfig

  • fastvideo/api/schema.py:169
  • fastvideo/api/sampling_param.py:172

@kevin314
kevin314 marked this pull request as ready for review June 26, 2026 08:18
@SolitaryThinker

Copy link
Copy Markdown
Collaborator

Maintainer review + approved fix wave pushed to this branch.

Review findings (5 majors, condensed):

  1. nvfp4_sa2_wan2_1_1_3b.py docstring claimed sm89+ (H100/L40S/4090), but its default path is flashinfer's cutlass FP4 gemm with no fallback — Blackwell sm_120a only; sm89+ is only true for --bf16.
  2. nvfp4_qat_wan2_1_1_3b.py docstring claimed "Blackwell (B200/B300, sm100a+)" — the sm_120a cubins do not run on sm100; the correct requirement is RTX 5090-class sm_120a.
  3. Both nvfp4 scripts hard-assigned FLASHINFER_CUDA_ARCH_LIST="12.0a", clobbering any user setting and baking in one arch.
  4. The TaehvDecoder ported from FastWan_QAD_TAEHV.py flipped decode_video(parallel=True) to False — slower decode than the configuration that produced the published numbers.
  5. Deleting FastWan_QAD_TAEHV.py dropped the 5-warmup / 20-run min/max/mean/std benchmark machinery that backed our numbers; plus the fp8 script defaults to SAGE_ATTN without documenting the sageattention dependency, and the nvfp4 scripts died in opaque flashinfer ValueErrors on non-Blackwell GPUs.

Owner directive: keep this cleanup exactly as shaped — the deletion stands and the examples stay lean single-run examples — but separate the benchmark machinery out as its own standalone script rather than embedding multi-run stats into the examples.

Pushed commits:

  • f77d1e2 [bugfix]: correct hardware claims and arch handling in QAD 5090 example scripts — fixes both nvfp4 docstrings (default mode = sm_120a / RTX 5090-class; --bf16 is the portable path); switches FLASHINFER_CUDA_ARCH_LIST to setdefault with the value derived from the local GPU (fallback 12.0a); adds a cheap preflight capability gate to both nvfp4 default paths that exits with a one-line error naming the sm_120a requirement and the --bf16 escape hatch (shared helpers in a minimal _qad_common.py); restores parallel=True in all TAEHV decode calls; adds the pip install sageattention note to the fp8 docstring. docs/inference/optimizations.md was checked — it references only current script names and already says sm_120 for the QAT path, so it was left untouched.
  • aa4b6b0 [feat]: standalone QAD 5090 benchmark harness (multi-run stats) — new examples/inference/optimizations/benchmark_qad_wan2_1_1_3b.py with --mode {fp8,nvfp4_qat,nvfp4_sa2}, --warmups (default 5), --runs (default 20). Mirrors the corresponding example's pipeline setup per mode and ports the deleted FastWan_QAD_TAEHV.py machinery: request-log silencing, warmup loop, timed runs (denoise + TAEHV decode split), no disk I/O inside the timing loop, and the min/max/mean/std stats table.

Validation: python3 -m py_compile passes on all five touched files. pre-commit run --files ... reports "(no files to check)" — examples/ is excluded by .pre-commit-config.yaml, which is expected. No GPU on the fix machine, so generation was not run; the harness is a faithful port of the previously-working script's loop around the examples' known-working setup.

@mergify

mergify Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Pre-commit checks failed

Hi @kevin314, the pre-commit checks have failed. To fix them locally:

# Install pre-commit if you haven't already
uv pip install pre-commit
pre-commit install

# Run all checks and auto-fix what's possible
pre-commit run --all-files

Common fixes:

  • yapf: yapf -i <file> (formatting)
  • ruff: ruff check --fix <file> (linting)
  • codespell: codespell --write-changes <file> (spelling)

After fixing, commit and push the changes. The checks will re-run automatically.

For future commits, pre-commit will run automatically on changed files before each commit.

@SolitaryThinker

Copy link
Copy Markdown
Collaborator

CI note on the current reds — neither is caused by this PR's content:

Plan: one rebase once the resolver-test fix lands on main, which clears both in a single pass. Holding until then.

SolitaryThinker added a commit that referenced this pull request Jul 13, 2026
fastvideo-kernel/benchmarks/bench_attn_kernels.py benches all four
attention kernels on the real logged Wan2.1-1.3B shapes plus an L sweep
(1k/4k/16k/32760, H=12 D=128 B=1):

  bf16_flash_attn|bf16_sdpa  high-precision baseline (labels which ran)
  fp8_sageattn               SageAttention qk-int8/pv-fp8 (PR #1496 path)
  nvfp4_local                attn_qat_infer sageattn_blackwell (sm_120a)
  nvfp4_flashinfer           flashinfer nvfp4_attention_sm120 (SM 12.0/12.1)

Per kernel x shape: CUDA-event latency (mean/std), TFLOPS
(4*B*H*L^2*D), and accuracy (cos / max abs err / mean rel err) vs a
query-chunked fp32 SDPA reference. Inputs are biased (+1.0 mean shift
on q/k) by default because zero-mean randn is blind to the flashinfer
per-block-mean qk-correction head-broadcast bug; --include-zeromean
adds the zero-mean rows for contrast. Lanes probe availability + arch
gates and skip with a printed reason; oversized shapes are preflighted
(chunked reference, qk_correction workspace check) instead of OOMing.

Replaces bench_nvfp4_fp8_attention.py (logic folded in; docs pointer
updated, CPU unit tests renamed to test_attn_kernels_bench.py and
extended for the new --shapes/--bias surface).
@SolitaryThinker SolitaryThinker mentioned this pull request Jul 15, 2026
42 tasks
@SolitaryThinker
SolitaryThinker force-pushed the klin/5090-test-scripts branch from aa4b6b0 to 4a177ef Compare July 15, 2026 18:13
@SolitaryThinker

Copy link
Copy Markdown
Collaborator

Rebased onto current main to pick up #1572's full-suite gate script and #1597's resolver-test fix; no content changes (range-diff clean).

@SolitaryThinker

Copy link
Copy Markdown
Collaborator

/test full

@mergify

mergify Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase:

git fetch origin main
git rebase origin/main
# Resolve any conflicts, then:
git push --force-with-lease

@mergify mergify Bot added the needs-rebase PR has merge conflicts label Aug 9, 2026
@mergify mergify Bot removed the needs-rebase PR has merge conflicts label Aug 11, 2026
@mergify

mergify Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase:

git fetch origin main
git rebase origin/main
# Resolve any conflicts, then:
git push --force-with-lease

@mergify mergify Bot added the needs-rebase PR has merge conflicts label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase PR has merge conflicts scope: inference Inference pipeline, serving, CLI scope: kernel CUDA kernels, fastvideo-kernel type: misc Cleanup, config, dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants