Skip to content

Commit f77d1e2

Browse files
[bugfix]: correct hardware claims and arch handling in QAD 5090 example scripts
1 parent 652f90f commit f77d1e2

4 files changed

Lines changed: 55 additions & 7 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""Shared GPU-arch helpers for the QAD 5090 example scripts.
2+
3+
The default (non ``--bf16``) path of the NVFP4 scripts runs DiT linears through
4+
flashinfer's cutlass FP4 gemm, which ships sm_120a cubins only (RTX 5090-class
5+
consumer Blackwell). These helpers pick the right FLASHINFER_CUDA_ARCH_LIST and
6+
fail fast with a readable error instead of an opaque flashinfer ValueError.
7+
"""
8+
9+
import torch
10+
11+
# Capabilities the flashinfer FP4 gemm path has cubins for.
12+
FP4_CAPABILITIES = ((12, 0), (12, 1))
13+
14+
15+
def flashinfer_arch_list() -> str:
16+
"""FLASHINFER_CUDA_ARCH_LIST derived from the local GPU, defaulting to 12.0a."""
17+
if torch.cuda.is_available():
18+
major, minor = torch.cuda.get_device_capability()
19+
if (major, minor) in FP4_CAPABILITIES:
20+
return f"{major}.{minor}a"
21+
return "12.0a"
22+
23+
24+
def require_fp4_capable_gpu() -> None:
25+
"""Exit with a one-line error if the GPU cannot run the NVFP4 gemm path."""
26+
cap = torch.cuda.get_device_capability() if torch.cuda.is_available() else None
27+
if cap not in FP4_CAPABILITIES:
28+
raise SystemExit(
29+
f"The default NVFP4 path requires an sm_120a GPU (RTX 5090-class Blackwell, "
30+
f"compute capability 12.0/12.1); found {cap}. Re-run with --bf16 on other GPUs.")

examples/inference/optimizations/fp8_wan2_1_1_3b.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
Requirements:
77
- GPU: sm89+ (H100, L40S, RTX 4090, Ada Lovelace, or newer)
88
Falls back to a bf16 dequant path on older GPUs.
9+
- sageattention: pip install sageattention (the script defaults to the
10+
SAGE_ATTN attention backend)
911
- TAEHV (optional): Follow install instructions at https://github.com/madebyollin/taehv
1012
1113
Usage:
@@ -35,7 +37,7 @@ def __init__(self, checkpoint_path: str, device: str = "cuda",
3537
@torch.no_grad()
3638
def decode(self, latents: torch.Tensor):
3739
latents = latents.permute(0, 2, 1, 3, 4).to(self.device, self.dtype)
38-
decoded = self.model.decode_video(latents, parallel=False, show_progress_bar=False)
40+
decoded = self.model.decode_video(latents, parallel=True, show_progress_bar=False)
3941
frames = (decoded[0].clamp(0, 1) * 255).to(torch.uint8)
4042
return frames.permute(0, 2, 3, 1).cpu().numpy()
4143

examples/inference/optimizations/nvfp4_qat_wan2_1_1_3b.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
NVFP4QATConfig quantization. Uses ATTN_QAT_INFER attention backend.
55
66
Requirements:
7-
- GPU: Blackwell (B200/B300, sm100a+) for the FP4 linear path
7+
- GPU (default NVFP4 mode): RTX 5090-class Blackwell (sm_120a). The FP4
8+
linear path uses flashinfer's sm_120a cubins, which do not run on
9+
sm_100 (B200/B300), and the attn_qat_infer kernel hard-gates on sm_120.
10+
- GPU (--bf16 baseline): any supported GPU (the ATTN_QAT_INFER backend
11+
falls back to Flash Attention off sm_120).
812
- TAEHV (optional): Follow install instructions at https://github.com/madebyollin/taehv
913
1014
Usage:
@@ -33,7 +37,7 @@ def __init__(self, checkpoint_path: str, device: str = "cuda",
3337
@torch.no_grad()
3438
def decode(self, latents: torch.Tensor):
3539
latents = latents.permute(0, 2, 1, 3, 4).to(self.device, self.dtype)
36-
decoded = self.model.decode_video(latents, parallel=False, show_progress_bar=False)
40+
decoded = self.model.decode_video(latents, parallel=True, show_progress_bar=False)
3741
frames = (decoded[0].clamp(0, 1) * 255).to(torch.uint8)
3842
return frames.permute(0, 2, 3, 1).cpu().numpy()
3943

@@ -51,9 +55,14 @@ def main():
5155
parser.add_argument("--infer_steps", type=int, default=3)
5256
args = parser.parse_args()
5357

58+
from _qad_common import flashinfer_arch_list, require_fp4_capable_gpu
59+
60+
if not args.bf16:
61+
require_fp4_capable_gpu()
62+
5463
os.environ.setdefault("FASTVIDEO_ATTENTION_BACKEND", "ATTN_QAT_INFER")
5564
os.environ["FASTVIDEO_DISABLE_ATTENTION_COMPILE"] = "0"
56-
os.environ["FLASHINFER_CUDA_ARCH_LIST"] = "12.0a"
65+
os.environ.setdefault("FLASHINFER_CUDA_ARCH_LIST", flashinfer_arch_list())
5766

5867
from fastvideo import VideoGenerator
5968
from fastvideo.configs.pipelines.base import PipelineConfig

examples/inference/optimizations/nvfp4_sa2_wan2_1_1_3b.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
NVFP4QATConfig quantization. Uses the SAGE_ATTN attention backend.
55
66
Requirements:
7-
- GPU: sm89+ (H100, L40S, RTX 4090, Ada Lovelace, or newer)
7+
- GPU (default NVFP4 mode): RTX 5090-class Blackwell (sm_120a). The NVFP4
8+
linear path uses flashinfer's cutlass FP4 gemm, which has no fallback.
9+
- GPU (--bf16 baseline): sm89+ (H100, L40S, RTX 4090, Ada Lovelace, or newer)
810
- sageattention: pip install sageattention
911
- TAEHV (optional): Follow install instructions at https://github.com/madebyollin/taehv
1012
@@ -34,7 +36,7 @@ def __init__(self, checkpoint_path: str, device: str = "cuda",
3436
@torch.no_grad()
3537
def decode(self, latents: torch.Tensor):
3638
latents = latents.permute(0, 2, 1, 3, 4).to(self.device, self.dtype)
37-
decoded = self.model.decode_video(latents, parallel=False, show_progress_bar=False)
39+
decoded = self.model.decode_video(latents, parallel=True, show_progress_bar=False)
3840
frames = (decoded[0].clamp(0, 1) * 255).to(torch.uint8)
3941
return frames.permute(0, 2, 3, 1).cpu().numpy()
4042

@@ -52,9 +54,14 @@ def main():
5254
parser.add_argument("--infer_steps", type=int, default=3)
5355
args = parser.parse_args()
5456

57+
from _qad_common import flashinfer_arch_list, require_fp4_capable_gpu
58+
59+
if not args.bf16:
60+
require_fp4_capable_gpu()
61+
5562
os.environ.setdefault("FASTVIDEO_ATTENTION_BACKEND", "SAGE_ATTN")
5663
os.environ["FASTVIDEO_DISABLE_ATTENTION_COMPILE"] = "0"
57-
os.environ["FLASHINFER_CUDA_ARCH_LIST"] = "12.0a"
64+
os.environ.setdefault("FLASHINFER_CUDA_ARCH_LIST", flashinfer_arch_list())
5865

5966
from fastvideo import VideoGenerator
6067
from fastvideo.configs.pipelines.base import PipelineConfig

0 commit comments

Comments
 (0)