Commit Graph
878 Commits
Author SHA1 Message Date
Enderfga ef1bf25aba [docs] AnyFlow algorithm + usage guide
Single-page summary of AnyFlow's two-stage recipe:
- Algorithm intuition (u_θ(x_t, t, r) → any-step Euler)
- Stage 1 pretrain: central-difference target + (t, r) sampling
- Stage 2 on-policy DMD: multi-step rollout with grad-step broadcast
- Launch commands for both YAMLs
- Note on loading nvidia/AnyFlow-Wan2.1-T2V-* checkpoints (handled by
  param_names_mapping, no separate adapter)
- Note on fuse_guidance_scale parameterization

Registered under mkdocs nav so it surfaces in the built doc tree.
2026-07-11 18:36:14 -07:00
Enderfga fd98371ad8 [test] AnyFlow GPU smoke (pretrain + on-policy, 2 iters each)
Mirrors test_distill_dmd.py's subprocess-torchrun pattern but points at
the new YAML entrypoint (fastvideo.train.entrypoint.train). Auto-skipped
when fewer than 2 CUDA devices are visible — the new TrainingMethod
framework's distributed barriers don't tolerate single-GPU bring-up.

On Buildkite the test fires under /test distillation; on GMI we can
run it directly with NUM_GPUS=2 NUM_NODES=1 pytest -v -k anyflow_smoke.
2026-07-11 18:36:14 -07:00
Enderfga e8516c2fa2 [feat] AnyFlow YAML configs (pretrain + on-policy) for Wan 2.1 T2V 1.3B
Two reference configs slot into examples/train/configs/distribution_matching/wan/:

- anyflow_pretrain_t2v.yaml: single-student pretrain stage. Enables
  r_embedder under pipeline.dit_config, sets diffusion/consistency
  ratios, epsilon=5, weight_type=beta08, fuse_guidance_scale=3.0, lr 5e-5,
  6k steps, Wan2.1 T2V 1.3B init.

- anyflow_onpolicy_t2v.yaml: full DMD2 trio (student + Wan2.1 14B teacher
  + Wan2.1 1.3B critic). Pins the 4-step rollout schedule
  [999, 937, 833, 624, 0] from the AnyFlow paper, use_mean_velocity=true,
  generator_update_interval=5, lr 2e-6, 4k steps. The student loads from
  a path placeholder which can be either the local pretrain output or
  the published nvidia/AnyFlow-Wan2.1-T2V-1.3B-Diffusers checkpoint —
  the latter case relies on the param_names_mapping regex in
  WanVideoArchConfig to rename delta_embedder weights.
2026-07-11 18:36:14 -07:00
Enderfga 314a018002 [feat] AnyFlowMethod (on-policy DMD2 with multi-step Euler-flow rollout)
Subclasses DMD2Method and overrides _student_rollout to run
student_sample_steps Euler-flow steps from pure noise. One step is
gradient-enabled, with the chosen index broadcast from rank 0 in
distributed runs so every worker agrees (matching AnyFlow's
WanAnyFlowPipeline.training_rollout).

Method config knobs:
- student_sample_steps (default 4)
- use_mean_velocity (default True; r = t_next vs r = t at each step)
- t_list_override (optional pinned schedule, e.g. AnyFlow paper's
  [999, 937, 833, 624, 0] for 4-step Wan2.1)
- dmd_score_r_value (default 0.0; r used by the inherited DMD loss)
- real_score_guidance_scale (inherited from DMD2; default 1.0)

The inherited _dmd_loss / _critic_flow_matching_loss machinery is reused
verbatim — they call predict_x0 / predict_noise on the student, which
go through the single-timestep WanModel forward path (since DMD2 scores
against r=0 implicitly via the inherited code; if r=t is desired this
can be wired in a follow-up by overriding _dmd_loss to call
predict_velocity_with_r).

CPU-only tests via object.__new__ bypassing the full __init__ wire-up;
GPU integration coverage lives in the smoke test (Task 11).
2026-07-11 18:36:14 -07:00
Enderfga f6d78fa389 [feat] AnyFlow pretrain: central-difference target + full single_train_step
Implements AnyFlow's central-difference loss path end-to-end:

1. WanModel gains predict_velocity_with_r(noisy, t, r, batch, ...) — mirrors
   predict_noise's forward_context + autocast plumbing but injects
   r_timestep into the transformer kwargs.

2. anyflow_pretrain._central_difference_dF_dt — symmetric finite difference
   over (t ± delta) with the sample also moved along the flow trajectory by
   v_pred * (delta / num_train_timesteps), mirroring AnyFlow's reference
   trainer_wan_anyflow_pretrain.py::compute_central_difference. Wrapped in
   torch.no_grad so the two extra forwards stay out of the backward graph.

3. AnyFlowPretrainMethod.single_train_step:
   - sample (t, r) ∈ [0, 1] via _sample_pair_timesteps
   - apply scheduler shift + scale to absolute units
   - rebuild noisy with the flow-map scheduler's add_noise
   - run conditional + (optional) unconditional student forwards
   - apply guidance distillation when fuse_guidance_scale != 1
   - compute target = (eps - x0) - (t - r) * dF/dt
   - per-sample MSE * per-timestep weight
   - stop-grad scale balance so non-diffusion losses match the diffusion
     branch's magnitude
   - emit metrics for diffusion/consistency fractions + scale weight mean

4. AnyFlowPretrainMethod.backward overrides TrainingMethod.backward to
   route the loss through self.student.backward inside the correct
   forward_context, matching DMD2Method's pattern.
2026-07-11 18:36:14 -07:00
Enderfga a8b99d2113 [test] AnyFlow pretrain: cover (t, r) sampling distribution + validation 2026-07-11 18:36:14 -07:00
Enderfga ce23c5bfb1 [feat] AnyFlowPretrainMethod skeleton + (t, r) per-batch sampling
Adds the single-student AnyFlow flow-map pretrain method as a
TrainingMethod subclass. The __init__ parses and validates all method
config knobs (diffusion_ratio, consistency_ratio, epsilon, weight_type,
fuse_guidance_scale, shift), builds a FlowMapEulerDiscreteScheduler, and
wires a single optimizer+scheduler over the student.

The (t, r) sampling helper _sample_pair_timesteps lives at module scope
so it can be unit-tested without instantiating the full method. It
matches the AnyFlow paper formulation:

  - two uniform draws u1, u2; t = max, r = min
  - first diffusion_ratio * B: r := t (plain flow matching)
  - next consistency_ratio * B: r := 0 (consistency to clean data)
  - remainder: free reconstruction range

single_train_step raises NotImplementedError for now — filled in by the
next commit which adds the central-difference target and the loss
assembly (Task 7).
2026-07-11 18:36:14 -07:00
Enderfga aa5ce59016 [feat] Add FlowMapEulerDiscreteScheduler
Standalone any-step Euler scheduler implementing AnyFlow's flow-map step
formula x_r = x_t - ((t - r) / num_train_timesteps) * u(x_t, t, r). Also
provides the AnyFlow training-time helpers apply_shift (flow-matching
shift transform), get_train_weight (per-timestep loss weight with
beta08 = t * sqrt(1-t) renormalized to num_train_timesteps total mass),
and add_noise (linear flow-matching interpolation).

Subclasses BaseScheduler so it slots into the existing FastVideo
scheduler discovery surface (timesteps/order/num_train_timesteps
attributes plus set_shift/set_timesteps/scale_model_input). Has no
diffusers ConfigMixin/SchedulerMixin dependency.

set_timesteps accepts custom_timesteps so configs can pin AnyFlow's
hand-tuned schedules (e.g. [999, 937, 833, 624, 0] for the 4-step
Wan2.1 setting from the paper).
2026-07-11 18:36:14 -07:00
Enderfga fba7170ed0 [feat] Thread optional r_timestep through WanTransformer3DModel.forward
The forward signature now accepts r_timestep as an explicit kwarg (not
silently swallowed by **kwargs), gets flattened in parallel with timestep
when the input is 2-D (Wan 2.2 ti2v case), and is forwarded to the
condition_embedder.

The constructor now propagates the four arch_config flags
(r_embedder/r_embedder_fusion/r_embedder_gate_value/r_embedder_deltatime_type)
into the WanTimeTextImageEmbedding so a YAML can opt into AnyFlow's
dual-timestep conditioning through training.dit_config overrides.

Defaults preserve byte-identity with the legacy single-timestep path —
when r_timestep is omitted the delta_embedder branch is skipped entirely
(test_embedder_enabled_without_r_timestep_is_bit_identical_to_legacy).
2026-07-11 18:36:14 -07:00
Enderfga 0e042101f5 [feat] Extend WanTimeTextImageEmbedding with optional r_timestep
When r_embedder=True, allocates a delta_embedder (deep-copied from
time_embedder for matching initialization, per the AnyFlow reference's
setup_flowmap_model() pattern) and registers a non-persistent gate buffer.

Forward now accepts an optional r_timestep:
- additive (default): temb_t + g * delta_emb
- gated: (1 - g) * temb_t + g * delta_emb

Both branches are gated by r_embedder=True AND r_timestep is not None,
so existing call sites that don't pass r_timestep stay byte-identical
(verified by test_embedder_enabled_without_r_timestep_is_bit_identical_to_legacy).

The gate is a non-persistent buffer — it's a hyperparameter, not a
learned weight, and stays out of state_dict so checkpoints remain
portable across gate values.

deltatime_type controls whether the delta_embedder consumes r directly
(default, matching AnyFlow's deltatime_type='r') or (t - r).
2026-07-11 18:36:14 -07:00
Enderfga 836332786b [feat] Add r_embedder config flags to Wan (defaults preserve bit-identity)
Adds four fields to WanVideoArchConfig for AnyFlow dual-timestep conditioning:
- r_embedder: bool — enables the delta_embedder allocation
- r_embedder_fusion: 'additive' (default) or 'gated'
- r_embedder_gate_value: float — gate g in gated fusion
- r_embedder_deltatime_type: 'r' (default) or 't-r'

Also adds two regex entries to param_names_mapping so HF AnyFlow checkpoints
load delta_embedder weights into the FastVideo-internal mlp.fc_in/fc_out layout.
Both regex are no-ops on plain Wan checkpoints.

The defaults preserve bit-identity with every existing Wan-based method
(DMD2, Self-Forcing, KD, DFSFT) — no delta_embedder is allocated and no
extra computation runs on the embedder forward path.
2026-07-11 18:36:14 -07:00
Raghav K 055586703d [perf]: register a real backward for FA2 default + masked/varlen custom ops (training-under-compile) (#1388) 2026-07-12 00:45:27 +00:00
Mac Lee 5d89f86675 [ci] Stop forcing FA4 in model-load lanes (#1561) 2026-07-11 14:10:36 -07:00
Satyam Srivastava 19a51a1fe6 [ci] Trigger performance benchmarks for performance code changes (#1583) 2026-07-10 20:21:33 -07:00
William Lin d3232cea5a [ci]: gate the full-suite trigger on pre-commit and docs build (#1572) 2026-07-11 02:56:49 +00:00
Raghav KandSolitaryThinker 0c90c8c24d [bugfix] nvfp4: cast fp32 inputs to bf16 instead of asserting (#1488)
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-10 21:39:17 +00:00
Mingjia HuoandClaude Fable 5 4c08ffce49 [feat] World model training using third person games (#1443)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 05:09:07 +00:00
Atharv Ramesh af4a77553c [ci]: add SSIM reference bootstrap flow (#1522) (#1547) 2026-07-10 01:49:38 +00:00
alexzmsandSolitaryThinker c096fda1eb [docs] Add LTX-2.3 distilled inference run configs (t2v/i2v × 5+2/8+3 × resolutions) (#1568)
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-09 18:53:12 +00:00
William Lin 8f47e85be0 [bugfix]: retry remote image downloads in load_image (#1570) 2026-07-09 07:33:24 -07:00
William Lin 90d3bd19eb [infra] Deliver per-job Buildkite env to Modal CI at runtime, not as image layers (#1569) 2026-07-09 06:33:37 -07:00
Mac LeeandSolitaryThinker afb4f7d3c5 [ci]: emit v2 performance result schema (#1551)
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-09 06:11:15 +00:00
02e1143f22 [feat] Add Kandinsky-5 T2V/I2V pipeline support (#1471)
Co-authored-by: Aryan Kumar <aryan5v@users.noreply.github.com>
Co-authored-by: leffff <levnovitskiy@gmail.com>
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-07 14:43:30 -07:00
KaredandSolitaryThinker e2f4d1a7b5 [feat]: add SwanLab tracker (#1461)
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-07 08:35:38 +00:00
Kaiqin KongandSolitaryThinker f037351146 [feat] Add Clean-history Teacher Forcing and Causal Consistency Distillation (#1505)
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-07 08:13:11 +00:00
Mac LeeandSolitaryThinker 1ee11e08dc [ci]: add performance fingerprint cohorts (#1546)
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-07 07:24:00 +00:00
595f0ea60e [feat] Add DreamX-World 5B Cam and AR pipelines (#1538)
Co-authored-by: Suckl <Suckl@users.noreply.github.com>
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-07 06:16:18 +00:00
William Lin d921832cd2 [misc]: reserve CPU/memory for timing-sensitive Modal CI lanes (#1566) 2026-07-06 22:13:53 -07:00
William Lin 629697629a [bugfix]: free CUDA memory between train-framework model tests (LongCat OOM on L40S) (#1565) 2026-07-06 21:27:30 -07:00
William Lin a25313beec [ci]: wire fastvideo/tests/ops/ into the unit-test lane (#1559) 2026-07-06 12:07:26 -07:00
William Lin dbde64385b [bugfix]: bump FA4 pin to the CuTe DSL 4.6 compatible rev (#1564) 2026-07-06 12:06:59 -07:00
William Lin 9d909f5f04 [test]: remove dead and duplicate tests (-489 lines) (#1556) 2026-07-05 15:53:40 -07:00
William Lin 76b0550c15 [ci]: run pre-commit on fork PRs without manual approval (#1555) 2026-07-05 14:18:16 -07:00
William Lin 384c1e9493 [misc]: update reseed-performance-baseline skill for the hf_store move (#1545 follow-up) (#1553) 2026-07-05 14:16:55 -07:00
William Lin b1dbcc93f6 [misc]: reformat fastvideo/performance to the repo yapf config (#1554) 2026-07-05 14:16:20 -07:00
William Lin b93833772e [ci]: guard against test directories no CI lane collects (#1552) 2026-07-05 14:07:38 -07:00
Mac Lee 30b523edd6 [ci] Normalize performance stage component metrics (#1475) (#1550) 2026-07-05 14:05:26 -07:00
Mac LeeandSolitaryThinker 6aab7f3832 [ci] cover Hunyuan 1.5 chat-list text preprocessing (#1518)
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-05 12:05:25 -07:00
Mac Lee 9cd53fe5f8 [ci] Add metric-specific performance thresholds (#1545) 2026-07-05 12:04:33 -07:00
Mac Lee 6a32cf3a5e [ci]: expose LoRA extraction slash command (#1542) 2026-07-05 06:45:31 -07:00
William Lin 98be9b3da2 [bugfix]: address the three remaining #1447 review findings (#1549) 2026-07-05 06:43:27 -07:00
Mac Lee c53e85b767 [ci] Add v2 performance benchmark config identity fields (#1544) 2026-07-05 06:18:15 -07:00
William Lin 40a8bd2d3b [bugfix]: skip ThunderKittens kernels on aarch64 and document the kernel build matrix (#1548) 2026-07-05 06:13:11 -07:00
Mac LeeandSolitaryThinker 31aa115611 [bugfix]: preserve FSDP hooks for RMSNorm qk norms (#1513)
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-05 04:15:49 +00:00
zainnhandSolitaryThinker 98ac10a528 [infra] Auto-rebuild CUDA images when docker/Dockerfile changes on main (#1526)
Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com>
2026-07-04 16:25:46 -07:00
William Lin a5a6d171e5 [attn] Make FA4 explicit opt-in via FASTVIDEO_FA4 and delete the runtime fallback machinery (#1540) 2026-07-04 14:51:00 -07:00
William Lin 51ed1ea423 [build] Bump fastvideo-kernel pin to 0.3.2 (#1541) 2026-07-03 14:48:15 -07:00
Mac Lee 00ec3e7388 [bugfix]: compute VSA topk from padded blocks (#1517) 2026-07-03 14:16:51 -07:00
William Lin 0d626ef2d1 [kernel] Bump fastvideo-kernel pin to 0.3.1 and version the FA4 tile_mn port as 0.3.2 (#1539) 2026-07-03 14:11:08 -07:00
William Lin b36d0ef085 [infra] Add DGX Spark and multi-architecture CUDA support (#1447) 2026-07-03 13:41:43 -07:00