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

- **GitHub URL**: https://github.com/ifm-ai/PAN2
- **Official Docs / Website**: https://ifm.ai/pan/
- **Category**: Voice, Vision & Video (语音 / 视觉 / 视频生成)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: B+ (69/100 · Maintenance 31/35 · Adoption 12/25 · Releases 6/20 · License 20/20)
- **Review Snapshot**: 2026-12-01
- **Deployment / Stack Signals**: CLI, GPU
- **Momentum**: 119 ★ total (+3 24h / +12 7d) · 15 forks
- **Topics**: `world-model`, `world-modeling`, `world-models`, `open-source`, `physical-ai`, `robotics`
- **When to Use**: Best for: Research teams with CUDA GPU infrastructure and an offline latent pipeline that want to pretrain, fine-tune, or batch-evaluate action-conditioned video models. Skip if: You need lightweight inference on commodity hardware, exact reproduction of the full released-weight recipe, or a simulator that exposes verifiable physical states.

## Overview
```text
### Architecture & Core Mechanics
`train.py` drives YAML-configured training for a 29.2B-parameter video transformer with 44 joint-attention blocks over video and state streams. The backbone uses 3D RoPE and RMS query/key normalization. Qwen3.5-9B hidden states feed the caption projection, with a budget of 1,536 caption tokens; Wan 2.2 provides the video latent representation.

The loader reads precomputed latents from local disk, packs samples to a token budget, and can mix in image data. It neither decodes pixels nor runs the VAE in the training loop. The PyTorch stack combines FSDP2 hybrid sharding, optional Ulysses context parallelism, and Muon, with FlashAttention 4 and Quack in the pinned CUDA kernel stack. YAML configurations and checkpoint conversion are the main integration points.

### Key Capabilities & Differentiators
PAN 2 generates text-to-video and image-to-video from action descriptions. A shared 97-channel input concatenates 48 noisy latent channels, 48 conditioning channels, and a mask; image-to-video uses the first latent frame as the condition. The 704 × 1248 recipe runs at 24 fps and supports up to 481 frames (roughly 20 seconds), with 858 tokens per latent frame after patching.

The trainer covers pretraining and supervised fine-tuning, with logit-normal timestep sampling for pretraining and uniform sampling for SFT under a flow-matching objective. Native inference accepts prompt JSON and offers optional rewriting into structured captions. The rewriter is a separate text step, not a physics verifier. Checkpoint tooling converts transformer weights between native and Diffusers layouts without retraining.

### Trade-offs & Limitations
Offline latents remove pixel decoding and VAE compute from each training step, but move preprocessing cost to a separate job and make local storage throughput part of the training budget. Changing the latent representation requires regenerating compatible training data. Context parallelism can help fit long sequences, with communication costs that should be tested on the intended cluster rather than inferred from a debug run.

For inference only, Diffusers or vLLM are integration paths for the same model, not substitutes for the native data and training stack. The repository covers pretraining and SFT but omits the reward learning and model soup used to produce the released weights, so it does not reproduce the full release pipeline. For robotics or planning, a plausible video is useful for proposing outcomes, not as evidence of a constraint-checked state transition.

### Hardware & Deployment Guide
The baseline CLI environment uses Python 3.14 and CUDA 13.2 wheels: install PyTorch 2.12.1 and torchvision 0.27.1 from the cu132 index first, followed by the prerelease FlashAttention 4 build and Quack kernels in the specified order. Check the H200 guide and kernel compatibility notes against the target driver and GPU. Cache Qwen3.5-9B for text encoding and Wan 2.2 for offline data preparation and inference.

Use the Slurm scripts for pretraining or SFT and `inference/inference.sh` for single-node batch generation. Training resumes from the latest checkpoint in the configured output directory, so use a separate directory for a deliberately fresh run. Size memory and local storage throughput against representative clip lengths and workloads. Single-node prompt sharding increases batch throughput; it is not pooling VRAM for one clip. No GitHub release milestone is listed; pin the code revision, model artifacts, and environment for reproducibility.
```

## Key Capabilities
```text
- Backbone: 29.2B parameters across 44 dual-stream joint-attention blocks with 3D RoPE.
- Conditioning: One 97-channel input design supports text-to-video and first-frame-conditioned image-to-video.
- Data path: Token-budget packing reads offline Wan 2.2 latents from local storage without running a VAE in the training loop.
- Distributed training: FSDP2 hybrid sharding, optional Ulysses context parallelism, and the Muon optimizer.
- Native inference: `generate.py` workers shard prompt lists across GPUs, with BF16 sampling and completed-clip skipping in the launch workflow.
- Checkpoint portability: Native and Diffusers transformer layouts convert in both directions through tensor rearrangement.
```

## Quick Start / Clone
```bash
conda create -n pan python=3.14 -y && conda activate pan
pip install torch==2.12.1 torchvision==0.27.1 --index-url https://download.pytorch.org/whl/cu132
pip install --pre "flash-attn-4[cu13]==4.0.0b29" --no-build-isolation
pip install "quack-kernels[cu13]==0.6.4"
pip install -r requirements.txt
```
