[docs] [kernel] Migrate to uv (#1127)

This commit is contained in:
Junda (David) Su
2026-02-25 14:13:50 -08:00
committed by GitHub
parent f8d9a0c57f
commit e315657066
9 changed files with 194 additions and 96 deletions
+5 -5
View File
@@ -44,15 +44,15 @@ FastVideo has the following features:
## Getting Started
We recommend using an environment manager such as `Conda` to create a clean environment:
We recommend using [uv](https://docs.astral.sh/uv/) to create a clean environment. If you previously used Conda, switching to uv generally gives faster and more stable installs.
```bash
# Create and activate a new conda environment
conda create -n fastvideo python=3.12
conda activate fastvideo
# Create and activate a new uv environment
uv venv --python 3.12 --seed
source .venv/bin/activate
# Install FastVideo
pip install fastvideo
uv pip install fastvideo
```
Please see our [docs](https://hao-ai-lab.github.io/FastVideo/getting_started/installation/) for more detailed installation instructions.
+18 -17
View File
@@ -14,24 +14,11 @@ improving performance, or fixing a bug.
For a full install checklist, see `docs/getting_started/installation/gpu.md`.
## Local development (Conda + editable install)
## Local development (UV + editable install)
Install Miniconda:
If you previously used Conda for local setup, switch to uv for a faster and more stable development environment.
```bash
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc
```
Create and activate a Conda environment:
```bash
conda create -n fastvideo python=3.12 -y
conda activate fastvideo
```
Install `uv` (optional, but recommended):
Install `uv`:
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
@@ -39,6 +26,20 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
wget -qO- https://astral.sh/uv/install.sh | sh
```
Create and activate a uv environment (recommended):
```bash
uv venv --python 3.12 --seed
source .venv/bin/activate
```
Conda alternative (supported):
```bash
conda create -n fastvideo python=3.12 -y
conda activate fastvideo
```
Clone the repo:
```bash
@@ -51,7 +52,7 @@ Install FastVideo in editable mode and set up hooks:
uv pip install -e .[dev]
# Optional: FlashAttention (builds native kernels)
uv pip install flash-attn --no-build-isolation
uv pip install flash-attn --no-build-isolation -v
# Linting, formatting, static typing
pre-commit install --hook-type pre-commit --hook-type commit-msg
+18 -15
View File
@@ -8,17 +8,9 @@ FastVideo supports the following hardware platforms:
## Quick Installation
### Using pip
### Using uv (recommended)
```bash
# Create and activate a new conda environment
conda create -n fastvideo python=3.12
conda activate fastvideo
pip install fastvideo
```
### Using uv
Use uv as the default environment manager for faster and more stable installs.
```bash
# Create and activate a new uv environment
@@ -28,21 +20,32 @@ source .venv/bin/activate
uv pip install fastvideo
```
### Using Conda (alternative)
```bash
# Create and activate a new conda environment
conda create -n fastvideo python=3.12 -y
conda activate fastvideo
pip install fastvideo
```
### From source
```bash
git clone https://github.com/hao-ai-lab/FastVideo.git
cd FastVideo
pip install -e .
# or if you are using uv
uv pip install -e .
# optional: install flash-attn
uv pip install flash-attn --no-build-isolation -v
```
Also optionally install flash-attn:
Alternative with Conda environment:
```bash
pip install flash-attn --no-build-isolation
pip install -e .
pip install flash-attn --no-build-isolation -v
```
## Hardware Requirements
+44 -22
View File
@@ -12,8 +12,20 @@ Instructions to install FastVideo for NVIDIA CUDA GPUs.
## Set up using Python
### Create a new Python environment
#### Conda
You can create a new python environment using [Conda](https://docs.conda.io/projects/conda/en/stable/user-guide/getting-started.html)
#### uv
Recommended default: use [uv](https://docs.astral.sh/uv/) for faster and more stable environment setup.
Please follow the [documentation](https://docs.astral.sh/uv/#getting-started) to install `uv`. After installing `uv`, create a new environment using:
```console
# (Recommended) Create a new uv environment. Use `--seed` to install `pip` and `setuptools`.
uv venv --python 3.12 --seed
source .venv/bin/activate
```
#### Conda (alternative)
You can also create a Python environment using [Conda](https://docs.conda.io/projects/conda/en/stable/user-guide/getting-started.html).
##### 1. Install Miniconda (if not already installed)
```bash
@@ -25,34 +37,35 @@ source ~/.bashrc
##### 2. Create and activate a Conda environment for FastVideo
```bash
# (Recommended) Create a new conda environment.
# Create and activate a Conda environment
conda create -n fastvideo python=3.12 -y
conda activate fastvideo
```
#### uv
Or you can create a new Python environment using [uv](https://docs.astral.sh/uv/), a very fast Python environment manager. Please follow the [documentation](https://docs.astral.sh/uv/#getting-started) to install `uv`. After installing `uv`, you can create a new Python environment using the following command:
```console
# (Recommended) Create a new uv environment. Use `--seed` to install `pip` and `setuptools` in the environment.
uv venv --python 3.12 --seed
source .venv/bin/activate
```
### Installation
```bash
pip install fastvideo
#### With uv (recommended)
# or if you are using uv
```bash
uv pip install fastvideo
```
Also optionally install flash-attn:
Also optionally install FlashAttention:
```bash
pip install flash-attn --no-build-isolation
uv pip install flash-attn --no-build-isolation -v
```
#### With Conda environment (alternative)
```bash
pip install fastvideo
```
Also optionally install FlashAttention:
```bash
pip install flash-attn --no-build-isolation -v
```
### Installation from Source
@@ -68,18 +81,27 @@ git clone https://github.com/hao-ai-lab/FastVideo.git && cd FastVideo
Basic installation:
```bash
pip install -e .
# or if you are using uv
uv pip install -e .
```
Alternative with Conda environment:
```bash
pip install -e .
```
### Optional Dependencies
#### Flash Attention
```bash
pip install flash-attn --no-build-isolation
uv pip install flash-attn --no-build-isolation -v
```
Alternative with Conda environment:
```bash
pip install flash-attn --no-build-isolation -v
```
## Set up using Docker
+27 -19
View File
@@ -11,9 +11,20 @@ Instructions to install FastVideo for Apple Silicon.
### Create a new Python environment
#### Conda
#### uv
Recommended default: use [uv](https://docs.astral.sh/uv/) for faster and more stable environment setup.
You can create a new python environment using [Conda](https://docs.conda.io/projects/conda/en/stable/user-guide/getting-started.html)
Please follow the [documentation](https://docs.astral.sh/uv/#getting-started) to install `uv`. After installing `uv`, create a new environment using:
```console
# (Recommended) Create a new uv environment. Use `--seed` to install `pip` and `setuptools`.
uv venv --python 3.12 --seed
source .venv/bin/activate
```
#### Conda (alternative)
You can also create a Python environment using [Conda](https://docs.conda.io/projects/conda/en/stable/user-guide/getting-started.html).
##### 1. Install Miniconda (if not already installed)
@@ -26,21 +37,10 @@ source ~/.zshrc
##### 2. Create and activate a Conda environment for FastVideo
```bash
# (Recommended) Create a new conda environment.
conda create -n fastvideo python=3.12.4 -y
conda activate fastvideo
```
#### uv
Or you can create a new Python environment using [uv](https://docs.astral.sh/uv/), a very fast Python environment manager. Please follow the [documentation](https://docs.astral.sh/uv/#getting-started) to install `uv`. After installing `uv`, you can create a new Python environment using the following command:
```console
# (Recommended) Create a new uv environment. Use `--seed` to install `pip` and `setuptools` in the environment.
uv venv --python 3.12 --seed
source .venv/bin/activate
```
### Dependencies
```
@@ -49,11 +49,16 @@ brew install ffmpeg
### Installation
#### With uv (recommended)
```bash
uv pip install fastvideo
```
#### With Conda environment (alternative)
```bash
pip install fastvideo
# or if you are using uv
uv pip install fastvideo
```
### Installation from Source
@@ -69,12 +74,15 @@ git clone https://github.com/hao-ai-lab/FastVideo.git && cd FastVideo
Basic installation:
```bash
pip install -e .
# or if you are using uv
uv pip install -e .
```
Alternative with Conda environment:
```bash
pip install -e .
```
## Development Environment Setup
If you're planning to contribute to FastVideo please see the following page:
+5 -5
View File
@@ -7,18 +7,18 @@ Get up and running with FastVideo in minutes!
First, install FastVideo:
```bash
# Create and activate a new conda environment
conda create -n fastvideo python=3.12
conda activate fastvideo
# If you previously used Conda, use uv instead for a faster, more stable setup
uv venv --python 3.12 --seed
source .venv/bin/activate
# Install FastVideo
pip install fastvideo
uv pip install fastvideo
```
Also optionally install flash-attn:
```bash
pip install flash-attn --no-build-isolation
uv pip install flash-attn --no-build-isolation -v
```
## Basic Usage
+5 -5
View File
@@ -11,15 +11,15 @@ This page contains step-by-step instructions to get you quickly started with vid
## Installation
We recommend using an environment manager such as `Conda` to create a clean environment:
If you previously used Conda, we recommend using [uv](https://docs.astral.sh/uv/) instead for a faster and more stable environment setup:
```bash
# Create and activate a new conda environment
conda create -n fastvideo python=3.12
conda activate fastvideo
# Create and activate a new uv environment
uv venv --python 3.12 --seed
source .venv/bin/activate
# Install FastVideo
pip install fastvideo
uv pip install fastvideo
```
For advanced installation options, see the [Installation Guide](../getting_started/installation.md).
+9
View File
@@ -7,6 +7,13 @@ CUDA kernels for FastVideo video generation.
### Standard Installation (Local Development)
This will automatically detect your GPU architecture. If an NVIDIA Hopper (H100/sm_90a) GPU is detected, ThunderKittens kernels will be enabled. Otherwise, they will be skipped, and the package will use Triton fallbacks at runtime.
Before installation, set CUDA toolchain paths:
```bash
export CUDA_HOME=/usr/local/cuda
export CUDACXX=$CUDA_HOME/bin/nvcc
```
```bash
git submodule update --init --recursive
cd fastvideo-kernel
@@ -62,6 +69,8 @@ This package also includes kernels from [TurboDiffusion](https://github.com/thu-
- Any CUDA GPU for Triton-based fallbacks.
- **Build**:
- CUDA Toolkit 12.3+
- `CUDA_HOME` must be set (for example, `/usr/local/cuda`)
- `CUDACXX` must be set (for example, `$CUDA_HOME/bin/nvcc`)
- C++20 compatible compiler (GCC 10+, Clang 11+)
## Acknowledgement
+63 -8
View File
@@ -3,8 +3,10 @@ set -ex
# Simple build script wrapping uv/pip
# Usage:
# ./build.sh # local dev build (auto-detect / skip TK kernels when not available)
# ./build.sh --release # force-enable Hopper/TK kernels for release builds (no GPU required)
# ./build.sh # local build (torch-based arch detection, TK only on SM90)
# Environment overrides (if set, they win over auto-detection):
# TORCH_CUDA_ARCH_LIST
# CMAKE_ARGS (for FASTVIDEO_KERNEL_BUILD_TK / CMAKE_CUDA_ARCHITECTURES / GPU_BACKEND)
echo "Building fastvideo-kernel..."
@@ -12,7 +14,7 @@ echo "Building fastvideo-kernel..."
git submodule update --init --recursive
# Install build dependencies
pip install scikit-build-core cmake ninja
uv pip install scikit-build-core cmake ninja
RELEASE=0
GPU_BACKEND=CUDA
@@ -24,15 +26,68 @@ for arg in "$@"; do
esac
done
# Force-enable ThunderKittens kernels and compile for Hopper.
export TORCH_CUDA_ARCH_LIST="9.0a"
export CMAKE_ARGS="${CMAKE_ARGS:-} -DFASTVIDEO_KERNEL_BUILD_TK=ON -DCMAKE_CUDA_ARCHITECTURES=90a"
has_cmake_arg() {
local key="$1"
[[ "${CMAKE_ARGS:-}" =~ (^|[[:space:]])-D${key}(=|$) ]]
}
export CMAKE_ARGS="${CMAKE_ARGS:-} -DGPU_BACKEND=${GPU_BACKEND}"
detect_with_torch() {
uv run --active --no-project python -c "import torch
if not torch.cuda.is_available():
raise RuntimeError('torch.cuda.is_available() is false')
mj, mn = torch.cuda.get_device_capability(0)
print(f'{mj}.{mn}')"
}
if [ "${GPU_BACKEND}" = "CUDA" ]; then
detected_cc="$(detect_with_torch)" || {
echo "ERROR: torch-based CUDA arch detection failed in uv environment." >&2
echo " Ensure torch is installed and CUDA is available in the uv-selected Python." >&2
exit 1
}
cc_major="${detected_cc%%.*}"
cc_minor="${detected_cc##*.}"
cmake_arch="${cc_major}${cc_minor}"
echo "Detected compute capability via torch: ${detected_cc} (sm_${cmake_arch})"
# Respect explicit overrides.
if [ -z "${TORCH_CUDA_ARCH_LIST:-}" ]; then
if [ "${cc_major}" = "9" ] && [ "${cc_minor}" = "0" ]; then
export TORCH_CUDA_ARCH_LIST="9.0a"
else
export TORCH_CUDA_ARCH_LIST="${cc_major}.${cc_minor}"
fi
fi
# ThunderKittens build targeting:
# - SM90: compile Hopper/TK kernels with 90a.
# - Others (e.g., SM100): compile non-TK path with detected arch.
if ! has_cmake_arg "CMAKE_CUDA_ARCHITECTURES"; then
if [ "${cc_major}" = "9" ] && [ "${cc_minor}" = "0" ]; then
CMAKE_ARGS="${CMAKE_ARGS:-} -DCMAKE_CUDA_ARCHITECTURES=90a"
else
CMAKE_ARGS="${CMAKE_ARGS:-} -DCMAKE_CUDA_ARCHITECTURES=${cmake_arch}"
fi
fi
if ! has_cmake_arg "FASTVIDEO_KERNEL_BUILD_TK"; then
if [ "${cc_major}" = "9" ] && [ "${cc_minor}" = "0" ]; then
CMAKE_ARGS="${CMAKE_ARGS:-} -DFASTVIDEO_KERNEL_BUILD_TK=ON"
else
CMAKE_ARGS="${CMAKE_ARGS:-} -DFASTVIDEO_KERNEL_BUILD_TK=OFF"
fi
fi
fi
if ! has_cmake_arg "GPU_BACKEND"; then
CMAKE_ARGS="${CMAKE_ARGS:-} -DGPU_BACKEND=${GPU_BACKEND}"
fi
export CMAKE_ARGS
echo "TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST:-<unset>}"
echo "CMAKE_ARGS: ${CMAKE_ARGS:-<unset>}"
echo "GPU_BACKEND: ${GPU_BACKEND:-<unset>}"
# Build and install
# Use -v for verbose output
pip install . -v --no-build-isolation
uv pip install . -v --no-build-isolation