FA3 attention processor comes from https://gist.github.com/sayakpaul/ff715f979793d4d44beb68e5e08ee067.
Results from an H100:
latency=36.606 seconds. (AoT regional compilation)
latency=36.555 seconds. (JiT regional compilation)| # /// script | |
| # requires-python = ">=3.12,<3.13" | |
| # dependencies = ["kernels==0.18.2", "huggingface-hub==1.32.0", "torch==2.10.0+cu128"] | |
| # [tool.uv.sources] | |
| # torch = { index = "pytorch-cu128" } | |
| # [[tool.uv.index]] | |
| # name = "pytorch-cu128" | |
| # url = "https://download.pytorch.org/whl/cu128" | |
| # explicit = true | |
| # /// |
| """ | |
| NVFP4 Quantization Benchmark for Flux.1-Dev on Modal B200 GPU | |
| This script benchmarks NVFP4 (4-bit floating point) quantization performance | |
| for the Flux.1-Dev image generation model on NVIDIA B200 GPUs. | |
| B200 GPUs have native FP4 Tensor Core support, making them ideal for | |
| this workload. | |
| Usage: |
| import torch | |
| from diffusers import DiffusionPipeline | |
| import spaces | |
| from spaces.zero.torch.aoti import ZeroGPUCompiledModel, ZeroGPUWeights | |
| from time import perf_counter | |
| import argparse | |
| CKPT_ID = "black-forest-labs/Flux.1-Dev" |
FA3 attention processor comes from https://gist.github.com/sayakpaul/ff715f979793d4d44beb68e5e08ee067.
Results from an H100:
latency=36.606 seconds. (AoT regional compilation)
latency=36.555 seconds. (JiT regional compilation)| # Make sure you are using the latest `bitsandbytes` (at least 0.46.0) and PyTorch nightlies (at least 2.8). | |
| # Put together by sayakpaul and anijain2305 | |
| from diffusers.quantizers import PipelineQuantizationConfig | |
| from diffusers import FluxPipeline | |
| import argparse | |
| import json | |
| import torch | |
| import time | |
| from functools import partial |
| from diffusers import DiffusionPipeline | |
| import torch.utils.benchmark as benchmark | |
| import torch | |
| import psutil | |
| import os | |
| import json | |
| import argparse | |
| def benchmark_fn(f, *args, **kwargs): | |
| t0 = benchmark.Timer( |
| from google import genai | |
| from google.genai import types | |
| import typing_extensions as typing | |
| from PIL import Image | |
| import requests | |
| import io | |
| import json | |
| import os |
| """ | |
| Implementation of the label generation part in https://danielvanstrien.xyz/posts/2025/deepseek/distil-deepseek-modernbert.html | |
| using `transformers` and DeepSeek. | |
| """ | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import torch | |
| import re | |
| import contextlib | |
| import math |
| from moviepy.editor import VideoFileClip, clips_array | |
| import glob | |
| def create_video_collage(video_paths, output_path="collage.mp4"): | |
| """ | |
| Combine four videos of the same resolution into a 2×2 collage. | |
| Args: | |
| video_paths (list[str]): List of paths to the four video files. | |
| output_path (str): Filename for the output collage video. |
| from diffusers import DiffusionPipeline | |
| from diffusers import FluxTransformer2DModel, BitsAndBytesConfig | |
| from transformers import T5EncoderModel, BitsAndBytesConfig as BnbConfig | |
| from offloader import ModelOffloaderV2 | |
| import torch.utils.benchmark as benchmark | |
| from pathlib import Path | |
| import os | |
| import sys | |
| import torch | |
| import json |