Skip to content

FP8 Sol-Attn with Examples of Dense&Sol-sparse Wan2.1 and Minimax-H3 - #30

Open
Uxito-Ada wants to merge 16 commits into
Tele-AI:mainfrom
Uxito-Ada:fp8_quant_and_sol
Open

FP8 Sol-Attn with Examples of Dense&Sol-sparse Wan2.1 and Minimax-H3#30
Uxito-Ada wants to merge 16 commits into
Tele-AI:mainfrom
Uxito-Ada:fp8_quant_and_sol

Conversation

@Uxito-Ada

@Uxito-Ada Uxito-Ada commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add (1) FP8-Dense and (2) FP8-Sol sparse Wan 2.1, built on (a) optimized FP8 QKV and (c) FP8 fused Sol-attn kernels.

Implementation

  • All 300 Wan layers to dynamic W8A8 E4M3 tf-kernel GEMMs.
  • Optimized FP8 QKV:
    • Self-attention Q/K/V projections reuse one activation quantization across three GEMMs, while text encoding and VAE execution remain BF16. Previous each FP8Linear.forward() calls tf_kernel.tf_per_token_quant_fp8 independently, namely, input activation needs to be quanted three times for Q, K and V seperately. Here it is optimized to be quanted only once and reused.
    • Add fused Q/K/V quantizer with RoPE. QK use one E4M3 scale per block (64 tokens), and V uses per-channel.
  • FP8 fused Sol-attn:
    • Add an SM90 CuTe Sol-attn: E4M3 QK and PV with FP32 accumulation. Dequantization are fused inside, and it consumes FP8 inputs directly.
    • Correctness for Wan with masking: tail padding, two-way KV splitting, and route-length restoration for FP8 PV.
  • Expose BF16 Dense, BF16 Sol, FP8 Dense, and FP8 Sol through one example. FP8 Dense uses the same E4M3 Q/K/V CuTe QK/PV as FP8 Sol.

Benchmark

Environment and parameters:

  • GPU: one NVIDIA H100 80GB
  • Model: Wan2.1 T2V-1.3B, Minimax-H3
  • Resolution: 832x480
  • Frames: 81
  • Inference steps: 50
  • Solver: UniPC
  • CFG scale: 5.0
  • Sigma shift: 5.0
  • Seed: 42
  • SOL dense timesteps: 10
  • SOL dense layers: 1
  • SOL tau: 1.0
  • Each configuration runs in a separate process
  • Timing starts after pipeline loading and includes first-execution kernel/JIT
    costs
wan21_fp8_sol_h100_benchmark The bars show peak allocated GPU memory. The line shows generation throughput. @lzx1413

It is seen that :

  • FP8 Sol-Attn is the best overall configuration: 36.2% faster than BF16 Dense, while using 0.417 GiB less peak memory (-2.6%).
  • FP8 also improves the dense: FP8 Dense is 2.9% faster than BF16 Dense and reduces peak allocation by 0.417 GiB (-2.6%).
  • FP8 removes the Sol memory overhead and adds incremental speed: FP8 Sol is 4.3% faster and uses 1.293 GiB less peak memory (-7.6%) than BF16 Sol.
  • Different from native Sol, FP8 Sol shows equal peak allocation to FP8 dense in the help of our sol CuTe kernel, and FP8 Sol is 32.3% faster than FP8 Dense.
minimax_h3_fp8_sol_benchmark

The performance of Minimax-H3 shows that:

  • FP8 Dense: +12.1% throughput and 45.3% lower memory.
  • FP8 Sol-Attn vs. FP8 Dense: +47.1% throughput, with a 6.1% memory increase.

Video Generation Comparsion

Wan2.1:

Prompt:

Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage.

wan_clean_frame40_comparison_corrected
Dense Sol
BF16 https://github.com/user-attachments/assets/2a338e71-3d3d-4c0c-ab01-851a0b3684b0 https://github.com/user-attachments/assets/9dcd44f7-6d49-42c4-916c-d683dcee0051
FP8 https://github.com/user-attachments/assets/c40b3114-8c99-4f4c-91fa-2f091c030ca7 https://github.com/user-attachments/assets/31068c1c-62e0-42ba-9588-4bb174e97f9b

Minimax-H3:

Prompt: Official 768p T2VA's long prompt

minimax_h3_frame60_comparison
Dense Sol
BF16 https://github.com/user-attachments/assets/50c2daf3-eb04-4c75-8493-3ac3489dc236 https://github.com/user-attachments/assets/a6ee797a-32d8-411a-8c8f-5c1f672a8677
FP8 https://github.com/user-attachments/assets/2f2a939a-86e3-493c-8f2c-1b99729b6429 https://github.com/user-attachments/assets/5b8c0fc0-c51e-43ad-9df0-d8219003f95f

Testing

  • Unit tests pass
  • Manual H100 video generation performed for all four ablations
  • Throughput, peak-memory, PSNR, and SSIM benchmarks added

Commands and results:

ruff check telefuser tests examples/wan_video/wan21_1_3b_text_to_video_optimized_h100.py
# All checks passed

ruff format --check telefuser tests examples/wan_video/wan21_1_3b_text_to_video_optimized_h100.py
# 526 files already formatted

pytest tests/unit -q
# 1631 passed, 11 skipped

Checklist

  • Code follows the project coding standards and passes PR-scoped Ruff lint and format checks
  • Repository-wide pre-commit run --all-files passes:
  • Unit tests pass locally
  • New tests cover the added functionality
  • English and Chinese attention documentation and the Wan README are updated
  • Commit messages are clear and descriptive
  • Proposed PR title follows the [TYPE] Brief description convention

Related Issues

N/A

GPU Architecture Support

  • SM80 (Ampere/Ada): native FP8 Sol-Attn is not enabled
  • SM90 (Hopper H100): native E4M3 CuTe QK/PV mainloop
  • SM100+ (Blackwell): existing BF16 Sol-Attn remains unchanged; native FP8 path is not enabled

Performance Impact

See the benchmark section.

Add tf-kernel and TorchAO online FP8 choices for Wan2.1 transformer blocks, with dense and Sol-Attn runnable examples.

Keep active Sol-Attn Q/K/V in BF16 while preserving Wan residual dtypes, and cover the quantization and attention interaction with focused tests.

Document the H100 ablation setup and results, including a peak-memory bar and throughput line benchmark chart.

Verified with 18 focused pytest cases (including the H100 Sol-Attn kernel), both example --help entry points, pre-commit hooks, and git diff --check.
Mock the FP8 wrapping entry points so the Wan quantization unit test validates filter and option wiring without requiring the optional tf-kernel package.

Remove the benchmark PNG asset and its README reference while retaining the benchmark table and reproduction details.

Verified the previously failing test, the 18-test focused suite, Ruff, pre-commit, and staged diff checks.
Replace the separate dense FP8 and Sol-Attn FP8 scripts with one Wan2.1 example that independently selects attention and quantization from CLI configuration.

Document Dense/SOL and BF16/tf-kernel FP8/TorchAO FP8/NF4 combinations, and rename the focused tests around the consolidated interface.

Verified the direct --help entry point, 18 focused tests including the H100 SOL kernel, pre-commit hooks, PR-scope diff checks, and stale-reference audit.
@Uxito-Ada
Uxito-Ada requested a review from lzx1413 August 12, 2026 09:13
@Uxito-Ada
Uxito-Ada marked this pull request as draft August 13, 2026 10:12
@Uxito-Ada Uxito-Ada changed the title Add Wan FP8 quantization with Sol-Attn Implementation of FP8 Sol-Attn on Wan2.1 Aug 14, 2026
@Uxito-Ada Uxito-Ada changed the title Implementation of FP8 Sol-Attn on Wan2.1 FP8 GEMM and FP8 Sol-Attn with example of Wan2.1 Aug 17, 2026
@Uxito-Ada Uxito-Ada changed the title FP8 GEMM and FP8 Sol-Attn with example of Wan2.1 FP8 GEMM and FP8 Sol-Attn with Examples of Dense&Sol-sparse Wan2.1 Aug 17, 2026
@Uxito-Ada Uxito-Ada changed the title FP8 GEMM and FP8 Sol-Attn with Examples of Dense&Sol-sparse Wan2.1 FP8 GEMM, FP8 QKV and FP8 Sol-Attn with Examples of Dense&Sol-sparse Wan2.1 Aug 17, 2026
@Uxito-Ada
Uxito-Ada marked this pull request as ready for review August 17, 2026 02:57
@Uxito-Ada Uxito-Ada changed the title FP8 GEMM, FP8 QKV and FP8 Sol-Attn with Examples of Dense&Sol-sparse Wan2.1 FP8 Sol-Attn with Examples of Dense&Sol-sparse Wan2.1 Aug 19, 2026
Add sparse runtime state and packed-sequence sink handling for MiniMax H3, with FP8 QKV dispatch on active Sol layers and dense FA4 guards for protected steps and layers. Reuse tf-kernel FP8 Linear GEMMs, expose unified example flags, and extend the benchmark matrix and documentation.

Verification: ruff format and lint checks passed; the full unit suite passed with 1639 tests and 11 skips; the H100 BF16/FP8 Dense/Sol generation matrix completed.
@Uxito-Ada Uxito-Ada changed the title FP8 Sol-Attn with Examples of Dense&Sol-sparse Wan2.1 FP8 Sol-Attn with Examples of Dense&Sol-sparse Wan2.1 and Minimax-H3 Aug 19, 2026
@Uxito-Ada

Copy link
Copy Markdown
Collaborator Author

Appended Minimax-H3 support @lzx1413

Document the FP8 Linear and attention ownership boundary, post-RoPE QKV quantization, SM90 CuTe routed/exact mainloop, model-specific quality guards, and validated Wan and MiniMax-H3 ablations. Add English and Chinese pages, indexes, navigation, and attention-guide cross-links.

Verification: bilingual MkDocs build passed; git diff --check passed.
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