| # AdaptiveDetailCache on MAGI-1 (dev6-adaptive) |
|
|
| 基于 [FlowCache4MAGI-1-dev4-detail](../FlowCache4MAGI-1-dev4-detail) 的扩展分支,在 MotionDetailCache(motion + detail 双度量)之上,增加 **chunk 级 AR 难度预测 → 动态阈值 τ**。 |
|
|
| ## 与 dev4 的差异 |
|
|
| | 维度 | dev4 MotionDetailCache | dev6 AdaptiveDetailCache | |
| |------|------------------------|--------------------------| |
| | Phase 2 阈值 | 全局固定 `τ` | 每个 chunk 独立 `τ_eff` | |
| | 难度信号 | — | motion / detail / delta / 历史 active / 历史 reuse | |
| | 调参方式 | 手动 sweep `rel_l1_thresh` | `τ_base` + `beta` + `[τ_min, τ_max]` | |
|
|
| ## 动态 τ 公式 |
|
|
| 每个 chunk 进入 Phase2 时(chunk 内固定,避免 step 间抖动): |
|
|
| ``` |
| d = weighted(motion, detail, delta, hist_active, hist_reuse) ∈ [0, 1] |
| τ_eff = clamp(τ_base * exp(-β * (d - 0.5)), τ_min, τ_max) |
| active[p] = A[p] > τ_eff |
| ``` |
|
|
| 难度高 → τ 降低 → 更常计算;难度低 → τ 升高 → 更敢 reuse。 |
|
|
| ## 默认超参 |
|
|
| 继承 dev4 best,并新增: |
|
|
| | 参数 | 默认值 | 说明 | |
| |------|--------|------| |
| | `rel_l1_thresh` | 0.012 | τ 基准(dev4 best) | |
| | `use_adaptive_tau` | true | 开启动态 τ | |
| | `adaptive_tau_beta` | 0.8 | 难度→τ 灵敏度 | |
| | `adaptive_tau_min` | 0.008 | τ 下界 | |
| | `adaptive_tau_max` | 0.020 | τ 上界 | |
|
|
| ## 快速运行 |
|
|
| ```bash |
| cd FlowCache4MAGI-1-dev6-adaptive |
| conda activate magi |
| export CUDA_VISIBLE_DEVICES=0 |
| export MASTER_ADDR=localhost |
| bash scripts/single_run/adaptive_t2v.sh |
| ``` |
|
|
| ## dev4 vs dev6 对比 |
|
|
| ```bash |
| FRAMES=120 bash tools/run_compare_dev4_dev6.sh |
| FRAMES=240 bash tools/run_compare_dev4_dev6.sh |
| ``` |
|
|
| ## 代码结构 |
|
|
| ``` |
| inference/pipeline/cache/ |
| ├── motiondetailcache.py # dev4 基类(含 τ hook) |
| └── adaptivedetailcache.py # dev6 AdaptiveDetailCache |
| |
| yaml_config/single_run/adaptive_config_best.yaml |
| scripts/single_run/adaptive_t2v.sh |
| tools/run_compare_dev4_dev6.sh |
| ``` |
|
|
| 其余 sparse forward、KV cache、integrate 逻辑与 dev4 完全一致。 |
|
|