Files
LTX-2/docs/tasks.md
T
indigo e03cc62548 Add SCAIL-2 training integration (Phase 3, ltx-trainer FlexibleStrategy)
Wire SCAIL-2 driving + in-context mask conditioning into the trainer via the
unified FlexibleStrategy, so the widened patchify_proj (Phase 2) can be trained.

- flexible.py: new DrivingConditionConfig (driving-latent concat with a RoPE
  width offset ΔW) and MaskChannelsConditionConfig (semantic masks -> per-token
  channels), added to the condition union and get_data_sources. Driving is
  prepended (cond-first, target stays at the tail for loss slicing); mask
  channels are written onto the driving tokens via Modality.cond_channels,
  reusing ltx-core encode_mask_channels. The noisy target keeps a zero mask.
- model_loader.load_transformer gains mask_conditioning_channels, widening the
  video patchify_proj with zero-init columns via a new live-module helper
  (widen_module_patchify_proj_for_mask_channels). ModelConfig exposes the field.
- trainer unfreezes patchify_proj in LoRA mode when mask channels are active
  (the new input columns are new base params LoRA cannot reach).
- configs/scail_animation_lora.yaml plus README / training-modes table rows.

Verified on CPU (verify_phase3_trainer.py): config round-trips, prepare_training
_inputs builds cond_channels [B,T,56] with the mask on the driving tokens, a tiny
widened model forwards and compute_loss returns a finite [B] loss, and the widen
helper is output-preserving at zero init. Real training needs Linux+GPU+checkpoint;
dataset preprocessing (driving latents + semantic masks) and validation-runner
wiring are left for later.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 10:09:40 +08:00

5.5 KiB
Raw Blame History

SCAIL-2 → LTX-2 移植任務追蹤

狀態圖例: 完成 🔄 進行中 未開始 ⏸️ 暫緩

相關計畫見 plan.md

Phase 1 — Driving 串接 item(推論期 PoC

# 任務 狀態 產出 / 備註
1.1 新增 VideoConditionByDrivingLatent + DrivingMode packages/ltx-core/src/ltx_core/conditioning/types/driving_video_cond.py,以 reference_video_cond.py 為藍本,實作 ΔW width 偏移、時間對齊 target、max_pos 防呆、token 數防呆
1.2 匯出新 conditioning 類別 conditioning/types/__init__.pyconditioning/__init__.py
1.3 免-GPU 資料流驗證腳本 序列長度、ΔW 不重疊、時間對齊、frozen denoise_mask、attention_mask=None、clear_conditioning 剝除、超界/token 數防呆 — 全通過;ruff clean
1.4 (選配)端到端 smoke run 本機 CPU-only、無 checkpoint,改用小型真實 LTXModel(隨機權重)跑 pipeline 實走路徑:create_noised_state(含 driving cond)→ modality_from_latent_state真 transformer forwardseq 160=target 80+driving 80)→ clear_conditioning(→80)。ANIMATION/REPLACEMENT 皆通過:不 crash、輸出 finite、driving frozen 且正確剝除。僅驗證整合,不評估畫質

Phase 2 — In-context mask channelcheckpoint 手術)

決策mask channel 時間編碼採忠實堆疊——每 latent 幀對應 8 個 pixel 子幀沿 channel 堆疊,8×(K+1)=56 channelLTX 時間因子 8K=6)。非 Wan 的 4×(K+1)=28。

# 任務 狀態 備註
2.1 patchify_proj 加寬(config-gated LTXModel(mask_conditioning_channels=0)>0 時 patchify_proj=Linear(in+mask, inner)。預設不變
2.2 LatentState/Modalitycond_channels 欄位 types.pymodality.pycond_channels: Tensor|None=Nonepatchified [B,T,C]);tools.clear_conditioning 裁切;helpers.modality_from_latent_state 帶入
2.3 投影前 concat/zero-pad cond_channels transformer_args.py _apply_patchify_proj:寬度不足時用 cond_channels 補齊,None 則補零
2.4 checkpoint zero-init 加寬轉換 mask_channels_checkpoint.py widen_patchify_proj_for_mask_channels:尾端補零欄,載入舊權重行為不變
2.5 VideoConditionByMaskChannels56ch mask_channels_cond.py:1 環境開關 + K=6 綁定槽 → 空間下採樣 + 時間 8× 堆疊(causal 首幀複製)=56ch,寫入尾端 driving tokentarget 保持零
2.6 token-append conditioning 延伸 cond_channels cond_channels.py extend_cond_channelsreference_video/reference_audio/driving/keyframe 皆接上
2.7 Phase 2 驗證(免訓練) verify_mask_channels.pymask=0 向後相容;zero-init 加寬 forward == baseline(任意 cond_channels);driving+mask pipeline forward 不 crash、cond_channels 形狀/placement 正確、clear_conditioning 剝除
2.8 Replacement Mode z_ref 高度位移 ΔH_ref 仍暫緩(Phase 1 divergence,需獨立 reference token group

Phase 3 — 訓練整合(ltx-trainer

決策:完整整合到 FlexibleStrategy;訓練方式 = LoRA + 解凍 patchify_proj(新 mask 欄位無法純 LoRA 訓練)。本機無 GPU/Linux/checkpoint,只做到 CPU 單元驗證,實訓需在 GPU 機器跑。

# 任務 狀態 備註
3.1 新增 Driving/MaskChannels ConditionConfig flexible.pyDrivingConditionConfig(latents_dir/mode/width_offset) + MaskChannelsConditionConfig(mask_dir/num_slots),加入 union + get_data_sources
3.2 strategy 接線 driving concat + cond_channels _apply_driving_condition(cond-first concat + ΔW width 偏移) + _build_mask_channels(重用 encode_mask_channels,寫前 N driving token) → Modality.cond_channels
3.3 model_loader + ModelConfig 支援加寬 widen_module_patchify_proj_for_mask_channels(live module zero-init) + load_transformer(mask_conditioning_channels=) + ModelConfig.mask_conditioning_channels
3.4 LoRA 模式解凍 patchify_proj trainer._unfreeze_patchify_projmask_channels>0 時把 video patchify_proj 設 trainable,讓新欄位隨 LoRA 一起訓
3.5 範例 config + docs configs/scail_animation_lora.yamlconfigs/README.mddocs/training-modes.md 表格 row
3.6 CPU 單元驗證 verify_phase3_trainer.pyconfig round-trip、prepare_training_inputs 建 cond_channels[B,T,56]、driving 前置/mask placement、widened model forward + compute_loss finite、widen helper zero-init 等價
3.7 dataset 前處理(產 driving latents + 語意 mask 需 process_dataset 產出 driving_latents/(同 target 形狀)與 char_masks/(mask=[K+1,F_pix,H,W]);語意 mask 需分割模型,屬資料工程,未做
3.8 validation runner 接 driving/mask 驗證期取樣尚未接 SCAIL 條件(config 內 validation 先停用),與 Phase 4 一起
3.9 實機訓練跑通 需 Linux + GPU + checkpoint,本機無法

Phase 4 — Pipeline + CLI

# 任務 狀態 備註
4.1 scail_animation.py pipeline + arg parser 仿 lipdub.py

決議紀錄

  • 範圍:先只做 Phase 1(推論期 PoC)。Phase 2+ 待 Phase 1 驗證後再討論。
  • 架構前提SCAIL-2 建構於 Wan 2.1,本移植為跨架構移植。