# Repository Briefing: Lakonik/LakonLab
> Source: https://repoforai.com/repo/Lakonik/LakonLab (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/Lakonik/LakonLab
- **Official Docs / Website**: https://hanshengchen.com/research#pub_diffuion
- **Category**: Voice, Vision & Video (语音 / 视觉 / 视频生成)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: A (87/100 · Maintenance 35/35 · Adoption 12/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v0.3.0 (2026-11-21) — https://github.com/Lakonik/LakonLab/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: GPU, CLI
- **Momentum**: 628 ★ total (+1 24h / +18 7d) · 39 forks
- **Topics**: `diffusion-models`, `distillation`, `flow-matching`, `generative-ai`, `generative-model`, `image-generation`, `pytorch`, `text-to-image`, `pixel`
- **When to Use**: Best for: GPU-equipped research teams reproducing or modifying few-step image and video models, comparing stochastic solvers, or running distributed LoRA distillation with explicit control over kernels and evaluation. Skip if: You only need a standard inference pipeline, a turnkey hosted API, or predictable deployment without validating model access, VRAM and CUDA compatibility.

## Overview
```text
### Architecture & Core Mechanics
LakonLab is a config-driven PyTorch research codebase that houses pi-H3, AsymFlow, pi-Flow and GMFlow under one training and evaluation stack. The tree separates configs/, data/, demo/ and the lakonlab/ package, with train.py and test.py at the root. The dependency manifest pins mmcv 1.6.1, Transformers 5.16.1, Diffusers 0.40.0 and PEFT 0.20.0. Data loaders and checkpoint I/O can use local storage or S3, and checkpoints can also be loaded directly from Hugging Face or HTTP(S).

Model configuration is the main extension point for execution: compile_forward enables per-module torch.compile, bucket_warmup compiles shape variants up front, and attention_backend_config selects attention backends by module. Distributed execution can use DDP, FSDP or FSDP2. In LoRA workflows, the teacher, student and EMA models can share underlying base-weight storage with DDP or FSDP; that compatibility is narrower than the list of available distributed modes.

### Key Capabilities & Differentiators
pi-Flow uses imitation distillation for few-step generation; AsymFlow and GMFlow provide asymmetric flow and Gaussian mixture flow-matching implementations. The pi-FLUX.2 variant supports four-step image generation and editing. pi-H3 supports video and audio generation in two or four steps, with optional Sol sparse attention on supported GPUs; the video path does not use a VAE decoder.

FlowSDEScheduler and FlowMapSDEScheduler expose the same stochasticity control for conventional flow and few-step flow maps respectively: h=0 selects ODE sampling, h=1 selects standard SDE sampling, and h='inf' selects full re-noising. Frozen linear layers can use W8A8 presets including FP8, blockwise FP8 and INT8 variants. Evaluation in v0.3.0 adds VBench, LongText-Bench and video warping error, with video and audio support in both evaluation and the media viewer.

### Trade-offs & Limitations
Choose LakonLab over a standard Diffusers inference pipeline when you need to change distillation, solver behavior or distributed training. For supported checkpoint inference in a visual workflow, the separate ComfyUI extension is a lighter entry point. The two- or four-step schedules count sampling steps, not end-to-end latency; compare at matched resolution and clip length, and measure cold and warm runs separately when compiling.

Per-module compilation and attention tuning offer control at the cost of shape warmup and GPU-specific compatibility checks. The optional CUTLASS INT8 GEMM extension is Hopper-only, with a Triton path available when that extension is not used. Frozen-layer quantization and shared LoRA base weights address specific memory costs, not the entire training footprint. Budget VRAM against the chosen checkpoint, precision, resolution, clip length and batch size rather than treating a supported sampling mode as a hardware guarantee.

### Hardware & Deployment Guide
Use a Linux GPU environment: Ubuntu 20 and newer were tested with PyTorch 2.9+, most extensively on 2.10 and 2.11. The example environment uses uv-managed Python 3.10, setuptools<74, PyTorch 2.10.0 and torchvision 0.25.0 from the cu128 index, followed by an editable install with --no-build-isolation. Optional extensions can build on first use; source builds require compatible nvcc and a supported C++ compiler. Check LD_LIBRARY_PATH if system CUDA libraries conflict with the PyTorch build. Sol attention is a separate extra, with an additional CuTe runtime dependency on CUDA 13 builds.

The CLI workflow can run locally with local data and checkpoints. S3 and remote checkpoint loading are optional; gated FLUX weights require accepting access conditions and authenticating with Hugging Face. For upgrades, v0.2.2 introduced persistent S3 caching and renamed AsymFlow's base_rank option to basis_rank, so older configs need migration. v0.3.0 added pi-H3, frozen-layer 8-bit quantization and expanded media evaluation.
```

## Key Capabilities
```text
- Few-step media: pi-H3 supports video and audio generation in 2 or 4 steps; its video path omits the VAE decoder.
- Flow solvers: FlowSDEScheduler and FlowMapSDEScheduler expose h=0 for ODE sampling, h=1 for SDE sampling and h='inf' for full re-noising.
- Distributed distillation: DDP, FSDP and FSDP2 support mixed precision and gradient accumulation; LoRA base-weight sharing is listed for DDP and FSDP.
- Kernel selection: Per-module compilation and attention settings coexist with W8A8 quantization for frozen linear layers; the optional CUTLASS INT8 GEMM extension is Hopper-only.
- Storage: Data loaders and checkpoint I/O support local files and S3, with persistent local S3 caching and direct checkpoint loading from Hugging Face or HTTP(S).
- Evaluation: v0.3.0 adds VBench, LongText-Bench and video warping error, plus video and audio support in evaluation and the media viewer.
```

## Quick Start / Clone
```bash
# Move to this repository (the folder with setup.py) after cloning
cd <PATH_TO_YOUR_LOCAL_REPO>

# Create uv environment (uv's managed Python includes the headers needed to build CUDA extensions)
uv venv --python 3.10 --managed-python
source .venv/bin/activate

# Install the build tool required by --no-build-isolation
uv pip install "setuptools<74"

# Install Pytorch. Goto https://pytorch.org/get-started/previous-versions/ to select the appropriate version
uv pip install torch==2.10.0 torchvision==0.25.0 --index-url https://download.pytorch.org/whl/cu128

# Install LakonLab in editable mode
uv pip install -e . --no-build-isolation
```
