Elastic-forcing commited on
Commit
4faf4b4
·
verified ·
1 Parent(s): f92158b

Delete docs

Browse files
docs/first-step-comparison.md DELETED
@@ -1,76 +0,0 @@
1
- > Historical validation record: this comparison predates removal of the disabled auxiliary loss branches. Its source identifiers and field counts describe that earlier snapshot. Use scripts/check_readability.py and scripts/check_loss_parity.py for the cleaned release.
2
-
3
- # Readability refactor: first optimizer-step comparison
4
-
5
- The refactored 1.3B three-encoder code completed one full optimizer update on four H200 GPUs. Initial state, sampled inputs, forward features, loss and feature gradients match the earlier public-source run bitwise. The first recorded numerical difference is in `encoder_and_vae_backward`. Compare against the same-source repeated-run control below.
6
-
7
- ## Source and run identity
8
-
9
- - Refactor base: `7985874ff49de326b8350a66516c50645a604f45`; the GPU comparison used a source snapshot captured before committing the refactor.
10
- - Tested source snapshot manifest SHA-256: `a806daa28aa2aa75c5adbe1e6bb930dbae822aee07cbfaf830980f6f8111b001`.
11
- - Previous public trace commit: `985ebec542b1c2bdb7af95a4a7404b3069cc15e7`. Its code tree is byte-identical to the pre-refactor 1.3B code tree: `60b92b4230405641d8d65a048d7b7cf842a653cf`.
12
- - Original-source control commit: `e8ec87e10c4825dfaaec993643724c5e8a2e28e9`.
13
- - Base seed **1862643**, with rank seeds **1862643–1862646**, matching the recovered historical effective seed. A legacy setting of `seed: 0` requests seed randomization and is not the effective seed.
14
- - Distribution / differentiation / reference batches: **256 / 128 / 128**. Four ranks, 64 forward samples and 32 backward samples per rank, microbatch size 1.
15
- - Encoder weights **10:1:1**, loss divisor **3**, fixed-reference / Monte Carlo reference weights **2:1**.
16
- - Same physical model/reference assets and four physical GPUs as the earlier runs. Independently queried software versions match.
17
- - All **173** readable input configuration fields resolve to the previous values in the same order. The new config loader and `--training-updates 1` alias were exercised. The configured cosine schedule remains steps 0–125, initial learning-rate setting 2.5e-6, floor 5e-7.
18
- - Observation hooks use the renamed methods and otherwise preserve the earlier observer. No production computation was changed for this run.
19
-
20
- ## Scalar observations
21
-
22
- | Quantity | Previous public source | Readable source | Original A | Original B |
23
- |---|---:|---:|---:|---:|
24
- | Loss | 3.994718074798584 | 3.994718074798584 | 3.994718074798584 | 3.994718074798584 |
25
- | Gradient norm before clipping | 48.80884552001953 | 48.82303619384766 | 48.82280349731445 | 48.81880187988281 |
26
-
27
- ## Full-vector differences
28
-
29
- | Quantity | Public → readable | Original A → readable | Original A → original B |
30
- |---|---:|---:|---:|
31
- | Latent gradient — relative L2 | 0.507891% | 0.508414% | 0.508167% |
32
- | Latent gradient — cosine similarity | 0.999987102368 | 0.99998707571 | 0.999987088324 |
33
- | Latent gradient — maximum absolute difference | 4.95910644531e-05 | 6.103515625e-05 | 6.103515625e-05 |
34
- | Generator gradient before clipping — relative L2 | 0.299963% | 0.301090% | 0.312999% |
35
- | Generator gradient before clipping — cosine similarity | 0.999995544683 | 0.999995467272 | 0.999995104525 |
36
- | Generator gradient before clipping — maximum absolute difference | 0.0146789550781 | 0.00958251953125 | 0.0114288330078 |
37
- | Generator gradient after clipping — relative L2 | 0.298507% | 0.301089% | 0.312905% |
38
- | Generator gradient after clipping — cosine similarity | 0.999995544684 | 0.999995467273 | 0.999995104526 |
39
- | Generator gradient after clipping — maximum absolute difference | 0.00274252891541 | 0.0019583106041 | 0.00238353013992 |
40
- | Actual Adam parameter update — relative L2 | 7.580502% | 7.667867% | 7.707839% |
41
- | Actual Adam parameter update — cosine similarity | 0.997126798637 | 0.997060191614 | 0.99702946052 |
42
- | Actual Adam parameter update — maximum absolute difference | 5.00679016113e-06 | 5.00679016113e-06 | 5.00679016113e-06 |
43
-
44
- Relative L2 means `||right - left||₂ / ||left||₂`, accumulated across all four ranks. Adam update differences compare `weights_after - initial_weights`; they are not normalized by the much larger model weight norm. Initial parameters are byte-identical across all variants.
45
-
46
- ## Exact comparison with the previous public source
47
-
48
- | Recorded stage | Bitwise equality |
49
- |---|---|
50
- | effective_configuration | Exact |
51
- | initial_weights | Exact |
52
- | initial_rng | Exact |
53
- | forward_inputs_and_features | Exact |
54
- | mmd_result | Exact |
55
- | encoder_and_vae_backward | Different (645/2304 tensors) |
56
- | gradients_before_clip | Different (918/918 tensors) |
57
- | gradients_after_clip | Different (918/918 tensors) |
58
- | optimizer_state | Different (1836/2754 tensors) |
59
- | updated_weights | Different (916/3300 tensors) |
60
- | post_step_rng | Exact |
61
-
62
- All **424 tensor archives** (106 per rank) were compared, including all 256 forward samples and 128 selected backward samples. Equality checks compare raw bytes, including signed zeros. Configuration comparison excludes only output-directory and input-file-location fields. Timings and the final process-completion event are excluded from numerical comparison. All non-timing tensor values and structural fields remain compared.
63
-
64
- ## Interpretation and scope
65
-
66
- The first recorded numerical difference is in `encoder_and_vae_backward`. The earlier same-source repeat has nonidentical encoder/VAE backward, generator gradients and Adam updates. The control demonstrates backward execution variability in this GPU configuration; it does not identify a specific nondeterministic kernel or establish a statistical tolerance from one control pair.
67
-
68
- The public-to-readable gradient relative L2 difference is 0.9583 times the measured same-source control difference; for the Adam update it is 0.9835 times. These ratios contextualize the observed discrepancies; they do not define a pass/fail tolerance or guarantee matching long-run trajectories.
69
-
70
- The readable-source run completed backward, clipping, Adam, native checkpoint saving, and all four ranks successfully (exit code 0). The previous public run also completed successfully. Original A completed the first update and every compared trace, then failed at checkpoint saving because its audit output directory was absent; original B completed normally.
71
-
72
- This comparison concerns reruns under the historical settings, not tensors captured during the original historical first step. It covers 1.3B only and does not evaluate 14B training, all training updates, generated-video quality, or VBench.
73
-
74
- ## Software environment
75
-
76
- `{"cuda": "12.1", "cudnn": 90100, "flash_attn": "2.7.4.post1", "numpy": "1.26.4", "python": "3.10.12", "torch": "2.5.1+cu121", "torchvision": "0.20.1+cu121", "transformers": "4.53.3"}`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/paper-to-code.md DELETED
@@ -1,158 +0,0 @@
1
- # Reading the Anonymous Video Generation implementation
2
-
3
- Start with the training update, then follow the loss and replay calls. The paper's
4
- Sections 3.1–3.3 describe the objective and the separation between estimating a
5
- distribution and differentiating selected rollouts. Appendix C.4 and Algorithm 1
6
- describe the replay procedure. The notes below distinguish that mathematical
7
- presentation from the numerical choices retained in this release.
8
-
9
- Both releases contain one active distribution objective: the three-encoder MMD described below. The historical code/video_fd directory name is retained because its encoder adapters and replay VJPs are part of that active pipeline; it does not select an additional FD loss.
10
-
11
- ## Reading order
12
-
13
- The two model directories have the same main entry points and both use DINOv3,
14
- V-JEPA 2 and VideoMAEv2. Start with 1.3B when reading the shared flow; the 14B
15
- release adds its evaluated step-80 schedule and memory-management details.
16
-
17
- | Read | Purpose | 1.3B | 14B |
18
- |---|---|---|---|
19
- | Configuration | Batch sizes, encoders, loss weights, initialization and optimizer | [three_encoder.yaml](../1.3B/configs/three_encoder.yaml) | [train.yaml](../14B/configs/train.yaml) |
20
- | Training entry | Load configuration and start distributed training | [train.py](../1.3B/code/train.py) | [train.py](../14B/code/train.py) |
21
- | `DistributionMatchingTrainer` | Assemble one complete update: collect rollouts, compute feature gradients, replay and update the generator | [trainer/distribution_matching.py](../1.3B/code/trainer/distribution_matching.py) | [trainer/distribution_matching.py](../14B/code/trainer/distribution_matching.py) |
22
- | `FeatureGradientReplay` | Gather the distribution batch and compute gradients with respect to selected features | [trainer/feature_gradient_replay.py](../1.3B/code/trainer/feature_gradient_replay.py) | [trainer/feature_gradient_replay.py](../14B/code/trainer/feature_gradient_replay.py) |
23
- | `MultiEncoderMMD` | Combine the independently scaled encoder losses | [losses/multi_encoder_mmd.py](../1.3B/code/losses/multi_encoder_mmd.py) | [losses/multi_encoder_mmd.py](../14B/code/losses/multi_encoder_mmd.py) |
24
- | `VideoNystromMMD` | Evaluate generated–generated repulsion and hybrid reference attraction | [losses/video_nystrom_mmd.py](../1.3B/code/losses/video_nystrom_mmd.py) | [losses/video_nystrom_mmd.py](../14B/code/losses/video_nystrom_mmd.py) |
25
- | `DistributionMatchingModel` | Connect rollout generation, frozen encoders, VAE decoding and generator replay | [model/distribution_matching.py](../1.3B/code/model/distribution_matching.py) | [model/distribution_matching.py](../14B/code/model/distribution_matching.py) |
26
-
27
- The previous module paths remain compatibility shims. Read the implementations
28
- linked above rather than the shims. Low-level network definitions in `wan/` are
29
- useful after the training flow is clear.
30
-
31
- In `DistributionMatchingTrainer`, start at `_run_distribution_matching_step` and
32
- follow `_collect_rollout_microbatch`. In `DistributionMatchingModel`, the corresponding
33
- stages are `collect_rollout_features`, `prepare_latent_gradients` and
34
- `replay_generator_gradients`.
35
-
36
- ## Three different batch sizes
37
-
38
- | Paper symbol | Meaning | Released settings |
39
- |---|---|---|
40
- | $B$ | **Distribution batch:** generated videos that participate in the loss | 256 globally; 64 per GPU on 1.3B, 32 per GPU on 14B |
41
- | $b$ | **Differentiation batch:** generated videos replayed for generator backpropagation | 128 globally; 32 per GPU on 1.3B, 16 per GPU on 14B |
42
- | $B_{\mathrm{ref}}$ | **Reference minibatch:** stored reference-video features used by the Monte Carlo term | 128 globally |
43
-
44
- The readable configuration calls these `distribution_batch_size`,
45
- `distribution_samples_per_rank`, `differentiation_samples_per_rank` and
46
- `reference_minibatch_size`. `differentiation_gradient_scale` is $B/b$;
47
- `encoder_loss_divisor` is the final loss divisor. `utils/config.py` translates
48
- these names into the compatible runtime fields without changing their values.
49
-
50
- A microbatch is the smaller group processed at once; it is not $B$ or $b$.
51
- All 256 generated videos affect the loss, including the 128 whose generator
52
- computation is not replayed. Computing independent MMD losses on microbatches
53
- would omit their cross-microbatch interactions.
54
-
55
- Compatibility names can be misleading: `student_reference` means the full
56
- **generated** population, while `current_teacher` means the **reference
57
- minibatch**. Reference features are read from a frozen feature bank; this path
58
- does not run an online diffusion teacher.
59
-
60
- ## One optimizer update
61
-
62
- ```text
63
- Prompts + noise
64
- → generate B videos without retained generator graphs
65
- → extract frozen-encoder features and retain replay state
66
- → gather the complete distribution batch across GPUs
67
- → combine persistent Nyström statistics with a reference minibatch
68
- → compute feature gradients for the b selected videos
69
- → replay encoders: feature gradients → pixel gradients
70
- → replay VAE: pixel gradients → latent gradients
71
- → replay generator: latent gradients → parameter gradients
72
- → accumulate contributions, clip gradients, update once
73
- ```
74
-
75
- A **cotangent** is the incoming gradient used in a vector–Jacobian product. For
76
- example, a feature cotangent is $g_i^e=\partial L/\partial z_i^e$; replay passes it
77
- back through the corresponding encoder and generator. Frozen encoder and VAE
78
- parameters are not optimized, but derivatives with respect to their inputs are
79
- still required. Replay restores the original noise, random choices and segment
80
- inputs so that the gradient is paired with the intended computation.
81
-
82
- Two scaling factors have different purposes. The configured $B/b=2$ compensates
83
- for replaying only part of the distribution batch. Multiplication by the number
84
- of GPUs compensates for FSDP averaging parameter gradients across ranks.
85
-
86
- ## Connecting the loss to the paper
87
-
88
- Section 3.1 compares generated and reference distributions in frozen encoder
89
- spaces. Section 3.2 combines two estimates of the reference kernel mean:
90
-
91
- - **Persistent Nyström mean:** landmark kernels multiplied by precomputed
92
- coefficients, as in Equation (8) and Appendix C.2, Equations (18)–(21).
93
- - **Monte Carlo mean:** average kernel similarity to a sampled reference
94
- minibatch, as in Equation (6).
95
-
96
- The released Nyström:Monte Carlo weights are 2:1, so the mixture in Equation (9)
97
- has $\alpha_e=1/3$. The tensor saved under the legacy name `alpha` is instead
98
- the **Nyström coefficient vector**, denoted $\boldsymbol\beta_e$ in Equation
99
- (19). These are different quantities.
100
-
101
- For each encoder, the released implementation evaluates
102
-
103
- $$
104
- M_e=\frac{1}{B^2}\sum_{i,j}k_e(z_i,z_j)
105
- -\frac{2}{B}\sum_i\left[\frac{2}{3}m^e_{\mathrm{Nys}}(z_i)
106
- +\frac{1}{3}\widehat m^e_{\mathrm{MC}}(z_i)\right]+C_e,
107
- $$
108
-
109
- where $C_e$ is the retained reference–reference contribution. It then applies
110
- detached per-encoder loss scaling:
111
-
112
- $$
113
- L=\frac{1}{d}\sum_e w_e
114
- \frac{M_e}{\operatorname{stopgrad}(M_e)+\epsilon}.
115
- $$
116
-
117
- Here $d$ is the explicit aggregation divisor; it is not inferred from the sum
118
- of the weights. Both 1.3B and the human/VLM-evaluated 14B use
119
- DINOv3:V-JEPA 2:VideoMAEv2 = 10:1:1. Both configurations use $d=3$ and
120
- $\epsilon=10^{-4}$.
121
-
122
- ## Details to preserve when reviewing or refactoring
123
-
124
- - **Self-pairs and constants.** Paper Equations (11)/(13) use the off-diagonal
125
- denominator $B(B-1)$ and omit reference–reference constants. This release
126
- retains self-pairs with denominator $B^2$ and retains the constants. Although
127
- a reference constant has no direct generator derivative, it affects the
128
- detached normalization denominator above. Changing either convention changes
129
- the released numerical objective.
130
- - **Replay selection.** Algorithm 1 uniformly samples a subset. The released
131
- implementation selects a fixed suffix of each rank's generated batch and
132
- creates feature-gradient leaves for those selected samples. Their gradients
133
- still include interactions with the full distribution batch. The conditional
134
- unbiasedness statement in Equation (27) assumes uniform subset sampling;
135
- it should not be claimed for this fixed-suffix implementation.
136
- - **VAE temporal derivatives.** The active model paths call `replay_decoder_vjp`,
137
- which carries temporal-cache values but detaches their gradients between latent
138
- frames. This preserves decoded values while truncating cross-frame cache
139
- derivatives. The 14B tree also provides `replay_decoder_vjp_exact` and
140
- `wan_recurrent_decoder_vjp.py`, which propagate future-state cotangents; their
141
- presence does not mean the released training path selects them. Appendix C.4
142
- distinguishes prescribed gradient truncation from exact replay.
143
- - **Compatibility.** Resource-pack keys, checkpoint parameter names and legacy
144
- configuration fields remain supported. Their historical wording is not an
145
- additional training objective or a requirement to instantiate score models.
146
-
147
- ## Instrumentation and compatibility names
148
-
149
- Old imports and direct calls remain available as aliases. New training code
150
- calls the readable method names, so observers that intercept methods should
151
- patch `_collect_rollout_microbatch`, `_run_distribution_matching_step`,
152
- `collect_rollout_features`, `prepare_latent_gradients`, and
153
- `replay_generator_gradients`. Patching an old method alias does not intercept
154
- calls dispatched through the new name.
155
-
156
- Edit the public YAML when changing experiment settings. `prepare_config.py`
157
- resolves those readable fields and writes the legacy runtime schema to
158
- `configs/local.yaml`; this preserves resource and checkpoint identities.