[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-112680":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":19,"compositeScore":20,"rankGlobal":9,"rankLanguage":9,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":9,"pushedAt":25,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":15,"starSnapshotCount":15,"syncStatus":16,"lastSyncTime":29,"discoverSource":30},112680,"PAN2","ifm-ai\u002FPAN2","ifm-ai","Training code for PAN2, a open foundation world model for physical intelligence ",null,"Python",109,14,61,1,0,2,26,39,8,64.43,"Apache License 2.0",false,"main",[],"2026-11-05 20:15:42","2026-11-23 19:26:35","\u003C!-- ============================================================\n     HERO\n     ============================================================ -->\n\u003Cdiv align=\"center\">\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"assets\u002Fpan2-logo-dark.png\">\n  \u003Cimg alt=\"PAN 2\" src=\"assets\u002Fpan2-logo-light.png\" width=\"420\">\n\u003C\u002Fpicture>\n\n\n\u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002FIFM\u002FPAN2\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FHugging%20Face-FFD21E?logo=huggingface&logoColor=black\" alt=\"Hugging Face\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fmain\u002Fen\u002Fapi\u002Fpipelines\u002Fpan2\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDiffusers-FF9D00?logo=huggingface&logoColor=white\" alt=\"Diffusers\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Frecipes.vllm.ai\u002FIFM\u002FPAN2\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FvLLM-30A2FF?logoColor=white\" alt=\"vLLM\">\u003C\u002Fa>\n\u003Ca href=\"MODEL_CARD.md\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FModel%20card-ffd21e?logo=huggingface&logoColor=black\" alt=\"Model card\">\u003C\u002Fa>\n\u003Ca href=\"#documentation\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDocs-4f8cff?logo=readthedocs&logoColor=white\" alt=\"Docs\">\u003C\u002Fa>\n\u003Ca href=\"LICENSE\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLICENSE-Apache%202.0-4CAF50?logo=apache&logoColor=white\" alt=\"LICENSE\">\u003C\u002Fa>\n\u003Ca href=\"docs\u002Fenvironment.md\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPyTorch-2.12%20%7C%20CUDA%2013.2-ee4c2c?logo=pytorch&logoColor=white\" alt=\"PyTorch\">\u003C\u002Fa>\n\u003Ca href=\"docs\u002Fcompatibility.md\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FFlashAttention-4-76b900\" alt=\"FlashAttention 4\">\u003C\u002Fa>\n\n[**Quickstart**](#quickstart) · [**Find your path**](#find-your-path) · [**Examples**](#examples) · [**Model**](#model) · [**Docs**](#documentation)\n\n\u003C\u002Fdiv>\n\n# PAN 2\n\nDeveloped by the Institute of Foundation Models (IFM) at MBZUAI.\n\n---\n\n## Table of contents\n\n- [What is PAN 2?](#what-is-pan-2)\n- [Find your path](#find-your-path)\n- [Quickstart](#quickstart)\n- [Examples](#examples)\n- [Model](#model)\n- [Repository map](#repository-map)\n- [Documentation](#documentation)\n- [Results](#results)\n- [License and Attribution](#license-and-attribution)\n- [Citation](#citation)\n\n## What is PAN 2?\n\nPAN 2 is a general-purpose world model: it simulates how the world will change in response to actions. 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. This supports *simulative reasoning*: an agent can imagine the outcomes of its candidate actions before choosing among them, by simulating each plan with PAN 2 and acting on the one whose simulated outcome is best.\n\nPAN 2 follows the Generative Latent Prediction (GLP) architecture formalized in [Critique of World Models](https:\u002F\u002Farxiv.org\u002Fabs\u002F2507.05169) and couples **conceptual reasoning** by a large language model with **perceptual reasoning** by a latent diffusion model. The language model, the **conceptual reasoner**, writes the next world state as a structured, time-grounded description of events, timed actions bound to actors, and camera motion. The 29B-parameter MMDiT, the **perceptual reasoning backbone**, predicts the video latents that realize that state, and the Wan 2.2 VAE decoder renders them as the next observation.\n\nThis repository holds the **training code** for the perceptual reasoning backbone: a token-budget packed dataloader over\nprecomputed latents, FSDP2 hybrid sharding, optional context\nparallelism, and Muon. No\npixel decoding and no VAE forward happen during training; everything the loader\nreads is produced offline and read from local disk. It also holds the **inference code** and the conceptual reasoner's prompt and agent skill. PAN 2 is also supported in [Diffusers](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fmain\u002Fen\u002Fapi\u002Fpipelines\u002Fpan2) and [vLLM](https:\u002F\u002Frecipes.vllm.ai\u002FIFM\u002FPAN2).\n\n## Find your path\n\n\u003Ctable>\n  \u003Ctr>\u003Cth align=\"left\" width=\"46%\">I want to…\u003C\u002Fth>\u003Cth align=\"left\">Go to\u003C\u002Fth>\u003C\u002Ftr>\n  \u003Ctr>\u003Ctd>\u003Cb>Set up the environment\u003C\u002Fb>\u003C\u002Ftd>\u003Ctd>\u003Ca href=\"docs\u002Fenvironment.md\">Environment setup\u003C\u002Fa> — conda, FA4, quack, model downloads\u003C\u002Ftd>\u003C\u002Ftr>\n  \u003Ctr>\u003Ctd>\u003Cb>Set up H200\u003C\u002Fb>\u003C\u002Ftd>\u003Ctd>\u003Ca href=\"docs\u002Fenvironment_h200.md\">H200 setup\u003C\u002Fa> — installation, training and inference\u003C\u002Ftd>\u003C\u002Ftr>\n  \u003Ctr>\u003Ctd>\u003Cb>Train on a small debug set\u003C\u002Fb>\u003C\u002Ftd>\u003Ctd>\u003Ca href=\"#quickstart\">Quickstart ↓\u003C\u002Fa>\u003C\u002Ftd>\u003C\u002Ftr>\n  \u003Ctr>\u003Ctd>\u003Cb>Prepare my own data\u003C\u002Fb> — latents, CSVs, image tars\u003C\u002Ftd>\u003Ctd>\u003Ca href=\"docs\u002Fdata.md\">Data\u003C\u002Fa>\u003C\u002Ftd>\u003C\u002Ftr>\n  \u003Ctr>\u003Ctd>\u003Cb>Pretrain or SFT at scale\u003C\u002Fb>\u003C\u002Ftd>\u003Ctd>\u003Ca href=\"docs\u002Ftraining.md\">Training\u003C\u002Fa> — YAML, launch scripts, checkpoints, resume\u003C\u002Ftd>\u003C\u002Ftr>\n  \u003Ctr>\u003Ctd>\u003Cb>Fit long sequences on smaller GPUs\u003C\u002Fb>\u003C\u002Ftd>\u003Ctd>\u003Ca href=\"docs\u002Ftraining.md#6-context-parallelism-cp_size\">Context parallelism\u003C\u002Fa>\u003C\u002Ftd>\u003C\u002Ftr>\n  \u003Ctr>\u003Ctd>\u003Cb>Generate videos from a checkpoint\u003C\u002Fb>\u003C\u002Ftd>\u003Ctd>\u003Ca href=\"docs\u002Finference.md\">Inference\u003C\u002Fa> — launcher, sampler controls, prompt JSON, rewriting\u003C\u002Ftd>\u003C\u002Ftr>\n  \u003Ctr>\u003Ctd>\u003Cb>Run the conceptual reasoner with a coding agent\u003C\u002Fb>\u003C\u002Ftd>\u003Ctd>\u003Ca href=\"inference\u002Fpan-prompt-rewriter\u002FSKILL.md\">PAN 2 Conceptual Reasoner (Prompt Rewriter) skill\u003C\u002Fa> — Codex \u002F Claude Code skill: caption policy, fixed negative, token validation\u003C\u002Ftd>\u003C\u002Ftr>\n  \u003Ctr>\u003Ctd>\u003Cb>See results, safety guardrails and limitations\u003C\u002Fb>\u003C\u002Ftd>\u003Ctd>\u003Ca href=\"MODEL_CARD.md\">Model card\u003C\u002Fa>\u003C\u002Ftd>\u003C\u002Ftr>\n  \u003Ctr>\u003Ctd>\u003Cb>Upgrade torch \u002F FA4 \u002F quack\u003C\u002Fb>\u003C\u002Ftd>\u003Ctd>\u003Ca href=\"docs\u002Fcompatibility.md\">Compatibility\u003C\u002Fa>\u003C\u002Ftd>\u003C\u002Ftr>\n\u003C\u002Ftable>\n\n## Quickstart\n\nTrain the 29B model on a one-node debug set. Full detail for each step is one\nclick away.\n\n> **H200 GPUs:** see the [H200 setup guide](docs\u002Fenvironment_h200.md) for installation, training and inference.\n\n**1. Environment** ([docs\u002Fenvironment.md](docs\u002Fenvironment.md))\n\n```bash\nconda create -n pan python=3.14 -y && conda activate pan\npip install torch==2.12.1 torchvision==0.27.1 --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu132\npip install --pre \"flash-attn-4[cu13]==4.0.0b29\" --no-build-isolation\npip install \"quack-kernels[cu13]==0.6.4\"\npip install -r requirements.txt\n```\n\n**2. Models** (text encoder for training; the VAE for encoding data and inference)\n\n```bash\nexport HF_HOME=YOUR_HF_PATH\nhf download Qwen\u002FQwen3.5-9B\nhf download Wan-AI\u002FWan2.2-TI2V-5B-Diffusers\n```\n\n**3. Data.** Encode video clips with the Wan 2.2 VAE and list them in CSVs; the\nformats are shown by `python scripts\u002Fmake_sample_data.py`, which writes a random-latent\n`sample_data\u002Fvideos.csv` and `sample_data\u002Fimages.tar`. About\n8 CSVs with 100 video latents and 8 image tars serve one node; point the `data`\npaths in the YAML at them. See [docs\u002Fdata.md](docs\u002Fdata.md).\n\n```yaml\n# config\u002Fpretrain_29B_720p.yaml\ndata:\n  packed_dataloader_meta_csv_path: [\u002Fpath\u002Fto\u002Fcsvs\u002F]      # one CSV per data-parallel rank\n  image_tar_path: [\u002Fpath\u002Fto\u002Fimage_tars\u002F]                 # optional\n  image_sample_prob: 0.2\n```\n\n**4. Launch**\n\n```bash\nsbatch scripts\u002Fpretrain.sh      # config\u002Fpretrain_29B_720p.yaml\nsbatch scripts\u002Fsft.sh           # warm-started from a pretrain checkpoint\n```\n\nEverything about a run lives in the YAML; the script only owns the cluster\nside. A run always resumes from the latest checkpoint in its own `output_dir`.\nSee [docs\u002Ftraining.md](docs\u002Ftraining.md).\n\n**5. Generate** (single node, one worker per GPU)\n\n```bash\nbash inference\u002Finference.sh \u003CCKPT_PATH> \u003COUTPUT_DIR> [PROMPTS_JSON]   # or sbatch, same arguments\n```\n\n`CKPT_PATH` is a training `checkpoint-N\u002Ftransformer` directory, a\n`model_state.pt`, or a directory of `*.safetensors`; the architecture comes\nfrom `config\u002Fsft_29B_720p.yaml`, the VAE and text encoder from the Hugging\nFace cache (step 2). The launcher starts one `generate.py` worker per GPU,\nshards the prompts across them, and samples with the default recipe: 50 steps, flow shift 9, CFG 2.5, 704x1248 at 24 fps, bf16. `PROMPTS_JSON` defaults\nto `inference\u002Fprompts\u002Fexamples.json` (one t2v and one i2v record). Videos land\nin `\u003COUTPUT_DIR>\u002F{t2v,i2v}\u002F` next to a `*_config.json`; a rerun into the same\ndirectory skips finished clips. Override any default through environment\nvariables (`NUM_STEPS`, `FLOW_SHIFT`, `GUIDANCE_SCALE`, `VIDEO_LENGTH`,\n`SEED`, `NUM_GPUS`, ...) or pass extra `generate.py` flags in `EXTRA_ARGS`.\nSee [docs\u002Finference.md](docs\u002Finference.md).\n\n**6. Convert checkpoints** (diffusers layout \u003C-> this repository)\n\nThe released weights (e.g. `IFM\u002FPAN2`) are in the diffusers layout\n(`PAN2Transformer3DModel`). `scripts\u002Fconvert_checkpoint.py` converts them for\n`generate.py` and training warm starts, and converts a training checkpoint back\nto the diffusers layout for release:\n\n```bash\n# Released diffusers weights -> this repository; then pass \u003CDIR>\u002Ftransformer as CKPT_PATH.\nhf download IFM\u002FPAN2 --include \"transformer\u002F*\" --local-dir \u002Fpath\u002Fto\u002FPAN2\npython scripts\u002Fconvert_checkpoint.py to-native \\\n    --input \u002Fpath\u002Fto\u002FPAN2\u002Ftransformer --output \u003CDIR>\u002Ftransformer\n\n# Training checkpoint -> diffusers transformer\u002F folder (architecture from the YAML).\npython scripts\u002Fconvert_checkpoint.py to-diffusers \\\n    --input \u002Fpath\u002Fto\u002Fcheckpoint-N\u002Ftransformer --output \u002Fpath\u002Fto\u002Frelease\u002Ftransformer \\\n    --training_config config\u002Fsft_29B_720p.yaml --dtype bf16\n```\n\nTo warm start training from the converted weights, set both keys in the YAML:\n\n```yaml\nmodel:\n  pretrained_transformer_path: \u003CDIR>\u002Ftransformer\n  load_transformer_weights: true    # the pretrain YAML ships false\n```\n\nThe conversion only renames, splits and concatenates tensors, so it is exact in\nboth directions. See [docs\u002Finference.md](docs\u002Finference.md#7-converting-checkpoints).\n\n## Examples\n\n### Prompts\n\nTraining captions are structured, and prompts work best in the same style.\n`inference\u002Fprompts\u002Fexamples.json` ships one t2v and one i2v record in that\nformat, each with its structured negative prompt, duration and (for i2v) a\nreference image. Free-text prompts like these two also work:\n\n> A muscular male swimmer in his early 30s, wearing a sleek professional swim\n> cap and mirrored goggles, stands poised on a starting block. With an\n> explosive burst of energy, he leans forward and dives headfirst into the\n> crystalline blue water of an Olympic-sized swimming pool. The camera captures\n> the moment of impact in a dynamic shot, showing a massive plume of white\n> spray and chaotic bubbles erupting around him […]\n\n> A wide, cinematic shot opens in a high-end, minimalist showroom characterized\n> by polished white marble floors that mirror the overhead soft-box lighting\n> and stark, charcoal-grey walls. In the center of the frame, a futuristic\n> concept car is unveiled […] Luminous neon-blue accents trace the contours of\n> the chassis and the thin, blade-like LED headlights, which pulse slowly with\n> a breathing light effect […]\n\nA conceptual reasoner expands them into the training caption style in two ways: offline with\n`inference\u002Fprompts_rewritter.py` and a local instruction-tuned model, or\ninteractively through the [PAN 2 Conceptual Reasoner (Prompt Rewriter)](inference\u002Fpan-prompt-rewriter\u002FSKILL.md)\nagent skill, which carries the same caption policy and fixed negative prompt\nand validates the result against the text encoder's token budget. See\n[docs\u002Finference.md](docs\u002Finference.md#5-prompt-rewriting).\n\n### Training data row\n\nOne CSV row per clip: the latent path and the caption.\n`scripts\u002Fmake_sample_data.py` writes ten of these with random latents.\n\n```csv\n\"latent_path\",\"caption\"\n\"\u002Fdata\u002Flatents\u002Fvideo_00.safetensors\",\"{\"\"video_style\"\": \"\"...\"\", \"\"lighting\"\": \"\"...\"\", \"\"perspective_view\"\": \"\"...\"\", \"\"events\"\": [...], ...}\"\n```\n\n### Image-to-video\n\nSet `image_cond_prob` in the `tasks:` section of the YAML (0.3 in the shipped\nconfigs). Per row the loader draws i2v with that probability and conditions on\nthe first latent frame through channel concatenation, so one model serves both\ntasks. At generation time any prompt-JSON entry with an `image_path` (or\n`type: i2v`) is run as image-to-video by the same launcher; the shipped\n`examples.json` has one of each.\n\n## Model\n\n| | |\n| --- | --- |\n| Parameters | 29.2B |\n| Backbone | 44 dual-stream (video + state) joint-attention blocks, hidden size 4096, 32 heads, RMS qk-norm, 3-D RoPE |\n| Latent space | Wan 2.2 VAE, 48 channels, 16x spatial \u002F 4x temporal downsampling, patch `[1, 2, 2]` |\n| Text encoder | Qwen3.5-9B hidden states (last 2 layers dropped), caption-encoder projection, up to 1,536 caption tokens |\n| Resolution | 704x1248 at 24 fps: a 44x78 latent grid, 858 tokens per latent frame; up to 481 frames (20 s) |\n| Objective | flow matching, fixed timestep shift 9; logit-normal timestep sampling in pretraining, uniform in SFT |\n| Tasks | t2v, i2v, channel-concat conditioning: 48 noisy + 48 condition + 1 mask = 97 input channels |\n| Training | three stages: 480p pretraining, 720p continued pretraining, 720p SFT |\n\n\nThis repository covers pretraining and SFT. Reward learning and the model soup\nthat produce the released weights are described in the technical report and are\nnot part of the training code.\n\n\n| Config | Purpose |\n| --- | --- |\n| [`config\u002Fpretrain_29B_720p.yaml`](config\u002Fpretrain_29B_720p.yaml) | dense 720p pretraining \u002F continued pretraining |\n| [`config\u002Fsft_29B_720p.yaml`](config\u002Fsft_29B_720p.yaml) | SFT, warm-started from a pretrain checkpoint, image mixing off |\n\nResults, safety guardrails and limitations: [MODEL_CARD.md](MODEL_CARD.md).\n\n## Repository map\n\n```text\npan2\u002F\n├── train.py            # entry point\n├── config\u002F             # training YAMLs\n├── scripts\u002F            # Slurm launchers: pretrain.sh, sft.sh; convert_checkpoint.py (diffusers \u003C-> native weights);\n│                       #   make_sample_data.py (random-latent data in the training formats)\n├── dataset\u002F            # packed dataloader: CSV stream, latent reads, image\u002Fvideo mixing, bin packing\n├── pan\u002F                # model, inference pipeline, text encoder, optimizer\n│   ├── models\u002F         # PanVideoDiffusionTransformer, Qwen3.5 text encoder\n│   ├── optim\u002F          # Muon, patched LR schedulers\n│   ├── pipelines\u002F      # inference pipeline\n│   └── utils\u002F          # Ulysses CP, guidance controls\n├── generate.py         # inference entry point (one process per GPU, prompt sharding)\n├── inference\u002F          # single-node launcher, example prompts, prompt rewriter, pan-prompt-rewriter\u002F agent skill\n├── docs\u002F               # the guides linked below\n├── assets\u002F             # logo and demo media\n└── MODEL_CARD.md       # overview, usage, results, safety guardrails, limitations\n```\n\n## Documentation\n\n| Guide | Covers |\n| --- | --- |\n| [Environment setup](docs\u002Fenvironment.md) | conda env, CUDA stack install order, install check, model downloads |\n| [Data](docs\u002Fdata.md) | Wan 2.2 VAE encoding and normalization, CSV and image-tar formats, image\u002Fvideo mixing, token budgets, debug set |\n| [Training](docs\u002Ftraining.md) | launching, the YAML sections, pretrain vs SFT, launch scripts and kernel caches, checkpoints and resume, context parallelism |\n| [Inference](docs\u002Finference.md) | launcher, default sampler, guidance controls, prompt JSON format, resume |\n| [Compatibility](docs\u002Fcompatibility.md) | version pins, FA4\u002Fquack upgrade contract, cu12 vs cu13 |\n| [Model card](MODEL_CARD.md) | overview, usage, results, safety guardrails, limitations |\n\n\n## Results\n\nPAN 2 with Kimi K3 as the conceptual reasoner, from the technical report; benchmarks, human evaluation and the evaluation protocols are in the [model card](MODEL_CARD.md#headline-results).\n\n\u003Cp align=\"center\">\n  \u003Cpicture>\n    \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"assets\u002Freport\u002Fresults_capabilities_dark.png\">\n    \u003Cimg alt=\"Capability and multi-step plan results, PAN 2 highlighted\" src=\"assets\u002Freport\u002Fresults_capabilities_light.png\" width=\"100%\">\n  \u003C\u002Fpicture>\n\u003C\u002Fp>\n\n## License and Attribution\n\nPAN 2 is developed by the Institute of Foundation Models (IFM) at MBZUAI.\n\nPAN 2's own code and weights are released by MBZUAI under the [Apache License, Version 2.0](LICENSE).\n\nPAN 2 includes or is used with third-party components, each under its own license. The license files are:\n\n- [LICENSE](LICENSE): the license for PAN 2's own code and weights.\n- [NOTICE](NOTICE): MBZUAI's copyright notice and attribution for the third-party components.\n- [THIRD_PARTY_LICENSES](THIRD_PARTY_LICENSES): the full license text of each third-party component, with its original copyright line.\n\n### Modifications\n\nThe Wan 2.2 and Qwen (Qwen3.5-9B) files and weights are used as released by their authors and have not been modified or fine-tuned by MBZUAI. Third-party code adapted in this repository keeps its original copyright and license header and, where MBZUAI has changed the code, a notice describing the changes.\n\n## Citation\n\n```bibtex\n@misc{pan2_2026,\n  title        = {PAN 2},\n  author       = {{PAN Team}},\n  organization = {Institute of Foundation Models, Mohamed bin Zayed University of Artificial Intelligence},\n  year         = {2026},\n  month        = oct,\n  howpublished = {\\url{https:\u002F\u002Fgithub.com\u002Fifm-ai\u002FPAN2\u002Ftree\u002Fmain}},\n  url          = {https:\u002F\u002Fgithub.com\u002Fifm-ai\u002FPAN2\u002Ftree\u002Fmain}\n}\n```\n","PAN 2 是一个通用世界模型，用于根据当前观测（可选图像+文本）和文本描述的动作，生成长达20秒的视频以模拟动作引发的世界状态变化。其核心技术采用生成式潜在预测（GLP）架构，协同大语言模型（执行概念化推理与事件时序建模）与潜在扩散模型（执行感知化视频生成），支持基于仿真的决策推理。适用于具身智能体规划、机器人任务预演、AI代理行动评估等需要因果性环境推演的场景。","2026-11-24 04:43:48","CREATED_QUERY"]