Use AIUnderstand AIBuild with AI
Build with AI·Model deep dive·· 5 min read

Run PAN 2: a 29B World Model That Simulates Actions as Video

IFM's Apache-2.0 world model turns a starting image plus text actions into up to 20 seconds of video. Here is the setup, sampler defaults and limits.

The code in this post comes from the model's docs and hasn't been run in our CI yet. If something breaks, let us know.

PAN 2 is a general-purpose world model from the Institute of Foundation Models (IFM) at MBZUAI. Given a current observation (an optional image plus text) and actions described in text, it simulates the outcome as a video of up to 20 seconds. The notable idea is simulative reasoning: an agent can simulate each candidate plan with PAN 2 and act on the one whose simulated outcome looks best. Code and weights are Apache-2.0.

Key specs

Item From the card
Architecture Generative Latent Prediction: an LLM “conceptual reasoning backbone” plus a latent diffusion “perceptual reasoning backbone”
Diffusion model 29B-parameter MMDiT, trained from scratch on hundreds of millions of annotated videos
Tasks Text-to-video (t2v) and image-to-video (i2v) from one checkpoint
Output 704x1248 at 24 fps, up to 20 s
Precision BF16
Frozen parts Text encoder Qwen/Qwen3.5-9B; VAE Wan-AI/Wan2.2-TI2V-5B-Diffusers
Also supported in Diffusers and vLLM (the card links to their docs)

The diffusion model is conditioned on a structured, time-grounded description of events, timed actions bound to actors, and camera motion. A free-text prompt is first rewritten into that format by a “conceptual reasoner”, which can be any instruction-following LLM.

Install

The card’s environment uses Python 3.14, with these pinned versions (CUDA 13 wheels):

setup.sh
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

requirements.txt and the scripts below live in the GitHub repo, so clone it first and run these from the repo root. The card also points to docs/environment.md there.

Download the frozen components and the checkpoint, then convert the weights once. The released weights are in the diffusers layout (PAN2Transformer3DModel), and this repo’s generate.py needs the native layout:

download.sh
export HF_HOME=YOUR_HF_PATH
hf download Qwen/Qwen3.5-9B
hf download Wan-AI/Wan2.2-TI2V-5B-Diffusers
hf download IFM/PAN2 --include "transformer/*" --local-dir /path/to/PAN2
python scripts/convert_checkpoint.py to-native \
--input /path/to/PAN2/transformer --output <DIR>/transformer

Use <DIR>/transformer as CKPT_PATH below.

Run it

One command runs the bundled example prompts (one t2v and one i2v record):

generate.sh
bash inference/inference.sh <CKPT_PATH> <OUTPUT_DIR> [PROMPTS_JSON]

PROMPTS_JSON defaults to inference/prompts/examples.json. Each worker is one generate.py process per GPU, holds the full 29B model, and takes every N-th prompt. Videos land in <OUTPUT_DIR>/{t2v,i2v}/, each next to a *_config.json. A rerun into the same directory skips finished clips.

Default sampler, per the card:

Control Value
Steps / flow shift 50 / 9
Classifier-free guidance 2.5 on every step
Frames 241 (about 10 s) when an entry has no duration; up to 481 (20 s)
Seed 123
I2V temporal latent 0 uses the positive prediction without guidance

Use case 1: image-to-video from your own start frame

Any entry with an image_path (or type: i2v) runs as image-to-video. Add your own record to a copy of the examples file, using the bundled inference/prompts/examples.json as the template (the card doesn’t spell out the schema, and the format is documented in docs/inference.md), then point the script at it:

i2v.sh
cp inference/prompts/examples.json my_prompts.json
# edit my_prompts.json: add a record with your image_path and a world-state caption
bash inference/inference.sh <CKPT_PATH> ./out my_prompts.json

Per the card, image-to-video conditions the diffusion model on the VAE latent of your starting image.

Use case 2: tune the sampler without editing code

Defaults can be overridden through environment variables. The card names NUM_STEPS, FLOW_SHIFT, GUIDANCE_SCALE, VIDEO_LENGTH, SEED and NUM_GPUS. Extra generate.py flags (CFG windows, skip-layer guidance, timestep schedules) go in EXTRA_ARGS:

tune.sh
NUM_GPUS=8 SEED=7 NUM_STEPS=50 GUIDANCE_SCALE=2.5 \
bash inference/inference.sh <CKPT_PATH> ./out my_prompts.json

Check docs/inference.md for what each variable accepts before changing VIDEO_LENGTH. The card does not state its units.

Use case 3: the full workflow from a free-text prompt

The conceptual reasoner turns a plain prompt into a structured world-state caption. The card offers two routes: the “PAN 2 Conceptual Reasoner (Prompt Rewriter)” agent skill for Codex or Claude Code, or an offline script that uses a local instruction-tuned model:

full_workflow.sh
python inference/prompts_rewritter.py
bash inference/inference.sh <CKPT_PATH> <OUTPUT_DIR> <REWRITTEN_JSON>

The rewriter adds a refined_prompts field to each record. Captions have a text-encoder token budget (soft limit 1,480, hard capacity 1,536 tokens), and the skill includes a validator for it. The card’s reasoner comparison, ordered by full-plan completion, was Claude Opus 5.5, GPT-6 Astra (medium effort), Kimi K3 and Qwen 3.8 Flash. Its technical report uses Kimi K3 unless stated otherwise.

Gotchas

  • Weights need converting. generate.py won’t read the downloaded diffusers-layout weights directly. Run convert_checkpoint.py to-native first.
  • Hardware is not specified. The card says each worker holds the full 29B model, and BF16 means roughly 2 bytes per parameter (about 58 GB for the transformer alone, by simple arithmetic). It does not list a minimum GPU, so plan for large-memory GPUs and test on one.
  • Prompt format matters. Free text should be rewritten before generation, and the model is sensitive to wording. The card says the beyond-training examples and agent case studies used hand-refined prompts.
  • Long plans often fail. About two in three simulated plans contain at least one step that isn’t carried out.
  • Physics shortcuts. Simulations can progress while violating physical constraints, such as pasta appearing in a colander before it’s drained.
  • Drift across clips. Each clip starts from at most one frame plus text, so appearance drifts in long interactions.
  • Guardrails are separate. The card strongly recommends running PAN 2 behind pan2-guardrail, which screens the request with Qwen3Guard-Gen-4B and the output with the Q16 frame classifier. In the card’s internal evaluation, it reduced harmful T2V requests yielding an unsafe video from 33.9% to 1.5%, and it also stopped 11.5% of benign T2V requests and 3.3% of benign I2V requests.
  • Out of scope. Impersonating real people, misinformation, sexual content involving minors, and safety-critical decisions without human review are listed as out of scope. Disclose AI-generated video where it could mislead.
  • Third-party licenses. Wan 2.2 and Qwen3.5-9B stay under their own licenses.

When to pick it

Choose PAN 2 if you’re researching world models, agent planning or video physics and want an open 29B model that takes an action description and returns a 704x1248 clip of up to 20 seconds. It’s also a reasonable pick for educational or creative clips where you control the prompts.

Skip it if you need a quick, cheap video generator on a single consumer GPU, because the card requires a heavy setup and gives no small-hardware path. Don’t use it where fidelity matters: its simulations are predictions, not records, and the card says they shouldn’t be treated as evidence of what happened or will happen.

Related