fushinguyenex commited on
Commit
cfaf85b
·
verified ·
1 Parent(s): 7487b07

Upload completed Trace-iMF training run

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ diagnostics/dashboard.png filter=lfs diff=lfs merge=lfs -text
37
+ diagnostics/multitrace.png filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TowerClimber
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,3 +1,44 @@
1
  ---
 
2
  license: mit
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ library_name: pytorch
3
  license: mit
4
+ tags: [meanflow, multi-trace, image-generation, class-conditional, cifar10]
5
  ---
6
+
7
+ # Multi-Trace U-Net — 14,992,182 parameters
8
+
9
+ U-Net adapted from the user-provided Untitled0.ipynb and widened to approximately
10
+ 22M parameters. Trained for 50,000 optimizer updates on CIFAR-10.
11
+ Training samples K uniformly from 1..5 and a grid interval j/K;
12
+ the same u head fits the interval and diagonal, with a detached directional JVP.
13
+ Default inference weights are **ema**. Model input/output pixels
14
+ are 32x32 RGB; sampling maps the final [-1,1] image into [0,1].
15
+
16
+ This is a custom PyTorch model. Download with huggingface_hub.snapshot_download,
17
+ install the included requirements.txt, then run:
18
+
19
+ ```bash
20
+ python sample.py --model-dir . --nfe 1 --output samples_1nfe.png
21
+ python sample.py --model-dir . --nfe 5 --output samples_5nfe.png
22
+ ```
23
+
24
+ config.json describes architecture/objective; training_config.json records the
25
+ effective batch, accumulation, LR schedule, clipping and EMA decay.
26
+ Full optimizer/EMA/RNG resume checkpoints remain on the Modal Volume and, when
27
+ the Modal notebook backup option is enabled, are also stored under
28
+ training-checkpoints/<run-name>/ in this Hub repository.
29
+ best_validation.safetensors contains the selected EMA validation snapshot;
30
+ its step and fixed held-out losses are recorded in best_validation.json.
31
+ Diagnostics include gradient RMS, actual optimizer updates, losses by K,
32
+ clipping frequency, samples, throughput, ETA and TensorBoard events.
33
+ Plateau flags are heuristics, not proof of convergence or image quality.
34
+
35
+ When present, fid.json reports pytorch-fid pool3 FID against 50,000 unaugmented
36
+ CIFAR-10 training images, with the generated sample count and each NFE explicitly
37
+ recorded. This protocol differs from the reference notebook's ImageNet-feature
38
+ FID; the values must not be compared directly. No quality claim is made here.
39
+ The test split was used as fixed validation during training.
40
+
41
+ Labels: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck.
42
+ The U-Net and interval schedule follow the user-provided notebook; repository
43
+ training flow and DiT baseline are adapted from haidog-yaqub/MeanFlow (MIT).
44
+ See third_party/ for attribution.
best_validation.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "step": 50000,
3
+ "weights_source": "ema",
4
+ "loss": 0.3709731566905975,
5
+ "edge_loss": 0.19136443853378296,
6
+ "diag_loss": 0.1796087145805359,
7
+ "jvp_rms": 2.2817168676853177,
8
+ "examples": 5120,
9
+ "loss_nfe_1": 0.39239816665649413,
10
+ "edge_loss_nfe_1": 0.21810964345932007,
11
+ "diag_loss_nfe_1": 0.1742885172367096,
12
+ "jvp_rms_nfe_1": 2.700194501876831,
13
+ "loss_nfe_2": 0.3679115891456604,
14
+ "edge_loss_nfe_2": 0.18770996630191802,
15
+ "diag_loss_nfe_2": 0.18020162284374236,
16
+ "jvp_rms_nfe_2": 2.536956226825714,
17
+ "loss_nfe_3": 0.35463637113571167,
18
+ "edge_loss_nfe_3": 0.1791027843952179,
19
+ "diag_loss_nfe_3": 0.17553358674049377,
20
+ "jvp_rms_nfe_3": 2.0643750607967375,
21
+ "loss_nfe_4": 0.38753209710121156,
22
+ "edge_loss_nfe_4": 0.19491184055805205,
23
+ "diag_loss_nfe_4": 0.19262024462223054,
24
+ "jvp_rms_nfe_4": 2.4871247947216033,
25
+ "loss_nfe_5": 0.3523875594139099,
26
+ "edge_loss_nfe_5": 0.17698795795440675,
27
+ "diag_loss_nfe_5": 0.17539960145950317,
28
+ "jvp_rms_nfe_5": 1.6199337542057037,
29
+ "raw_loss": 0.37272677540779114,
30
+ "raw_edge_loss": 0.19294691383838652,
31
+ "raw_diag_loss": 0.17977986514568328,
32
+ "raw_jvp_rms": 2.4338310968875883,
33
+ "raw_loss_nfe_1": 0.39853897094726565,
34
+ "raw_edge_loss_nfe_1": 0.2240687519311905,
35
+ "raw_diag_loss_nfe_1": 0.1744702249765396,
36
+ "raw_jvp_rms_nfe_1": 2.9251581192016602,
37
+ "raw_loss_nfe_2": 0.3692192077636719,
38
+ "raw_edge_loss_nfe_2": 0.18882804214954377,
39
+ "raw_diag_loss_nfe_2": 0.18039117157459258,
40
+ "raw_jvp_rms_nfe_2": 2.7281934142112734,
41
+ "raw_loss_nfe_3": 0.35528815984725953,
42
+ "raw_edge_loss_nfe_3": 0.1796249717473984,
43
+ "raw_diag_loss_nfe_3": 0.17566319108009337,
44
+ "raw_jvp_rms_nfe_3": 2.1835286557674407,
45
+ "raw_loss_nfe_4": 0.3877676367759705,
46
+ "raw_edge_loss_nfe_4": 0.19502896666526795,
47
+ "raw_diag_loss_nfe_4": 0.1927386701107025,
48
+ "raw_jvp_rms_nfe_4": 2.6403229236602783,
49
+ "raw_loss_nfe_5": 0.3528199017047882,
50
+ "raw_edge_loss_nfe_5": 0.1771838366985321,
51
+ "raw_diag_loss_nfe_5": 0.17563606798648834,
52
+ "raw_jvp_rms_nfe_5": 1.69195237159729
53
+ }
best_validation.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e34b7db78ae343f152e18c05309ffdcaf74cf8b6bcb6f9d8d4bf98e86f260bd
3
+ size 59989568
config.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": "ConditionalMultiTraceUNet",
3
+ "model": {
4
+ "input_size": 32,
5
+ "in_channels": 3,
6
+ "num_classes": 10,
7
+ "base_channels": 69,
8
+ "channel_mult": [
9
+ 1,
10
+ 2,
11
+ 2,
12
+ 4
13
+ ],
14
+ "num_res_blocks": 1,
15
+ "cond_dim": 312,
16
+ "fourier_dim": 64,
17
+ "attn_resolutions": [
18
+ 8
19
+ ]
20
+ },
21
+ "objective": "multi_trace_imf",
22
+ "multi_trace_imf": {
23
+ "lambda_diag": 1.0,
24
+ "max_nfe": 5,
25
+ "jvp_precision": "bf16",
26
+ "channels_last": true
27
+ },
28
+ "dataset": "cifar10",
29
+ "weights_source": "ema",
30
+ "max_nfe": 5,
31
+ "training_steps": 50000,
32
+ "trainable_parameters": 14992182,
33
+ "pixel_range": [
34
+ 0,
35
+ 1
36
+ ],
37
+ "sampling_steps": 1
38
+ }
diagnostics/convergence.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "status": "plateau_candidate_late",
3
+ "required_evaluations": 5,
4
+ "warning": "Regression loss has an irreducible noise floor; these are diagnostic hints, not FID.",
5
+ "step": 50000,
6
+ "best_validation_step": 50000,
7
+ "best_validation_loss": 0.3709731566905975,
8
+ "latest_validation_loss": 0.3709731566905975,
9
+ "relative_improvement": 0.0015668281478368013,
10
+ "window_start_step": 46000,
11
+ "window_end_step": 50000,
12
+ "budget_phase": "late",
13
+ "validation_regressed_from_best": false,
14
+ "recent_clip_fraction": 0.015999999642372132
15
+ }
diagnostics/dashboard.png ADDED

Git LFS Details

  • SHA256: b918816b9d590f6c7d116ef07a99d11a95a0f58228eee189ffcd8247614e366e
  • Pointer size: 131 Bytes
  • Size of remote file: 549 kB
diagnostics/gradient_heatmap.png ADDED
diagnostics/multitrace.png ADDED

Git LFS Details

  • SHA256: d3ffa0c54a9af8b2affdec5d843580a491e3f39e87b3d8528236a6ed7a4f7477
  • Pointer size: 131 Bytes
  • Size of remote file: 234 kB
diagnostics/runtime.png ADDED
diagnostics/training.csv ADDED
The diff for this file is too large to render. See raw diff
 
fid.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "protocol": {
3
+ "implementation": "pytorch-fid==0.3.0",
4
+ "features": "FID Inception pool3 (2048)",
5
+ "input_range": [
6
+ 0,
7
+ 1
8
+ ],
9
+ "real_split": "CIFAR-10 train, unaugmented",
10
+ "real_count": 50000,
11
+ "real_data_sha256": "47af8b02cfcfb6cdf3dbbd1969ad7f1b70f4413f6f80f437b020ee4e5bc8304a",
12
+ "generated_count": 10000,
13
+ "seed": 2026,
14
+ "batch_size": 128,
15
+ "class_schedule": "balanced labels: sample index modulo 10",
16
+ "sampling_precision": "bf16",
17
+ "weights_source": "ema",
18
+ "weights_sha256": "7e739a7d2fab764f4ec8c02dac518d6c4cabab9cd5fc33e4aaf410064f93b540",
19
+ "training_step": 50000,
20
+ "nfes": [
21
+ 1,
22
+ 2,
23
+ 3,
24
+ 4,
25
+ 5
26
+ ],
27
+ "reference_notebook_comparable": false
28
+ },
29
+ "fid": {
30
+ "1": 38.301275424967,
31
+ "2": 26.30447400280991,
32
+ "3": 25.51997010873481,
33
+ "4": 25.017732838651114,
34
+ "5": 24.852908128389515
35
+ }
36
+ }
hub_checkpoints.jsonl ADDED
@@ -0,0 +1 @@
 
 
1
+ {"repo_id": "fushinguyenex/IMF", "run_name": "multitrace_unet15m_h200_b512_v3", "checkpoint": "step_0050000.pt", "step": 50000, "revision": "7487b07fea07a88eec41fa931164d65e55c6fddd", "path_in_repo": "training-checkpoints/multitrace_unet15m_h200_b512_v3/step_0050000.pt", "url": "https://huggingface.co/fushinguyenex/IMF/blob/7487b07fea07a88eec41fa931164d65e55c6fddd/training-checkpoints/multitrace_unet15m_h200_b512_v3/step_0050000.pt", "status": "uploaded", "attempts": 1}
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e06188fade7ae05fb718146517aa998b19fe4f907c921d70d0521146cac0b709
3
+ size 59989600
models/__init__.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from .dit import TraceDiT
2
+ from .unet import ConditionalMultiTraceUNet
3
+
4
+
5
+ def build_backbone(cfg):
6
+ architecture = cfg.get("architecture", "TraceDiT")
7
+ classes = {"TraceDiT": TraceDiT, "ConditionalMultiTraceUNet": ConditionalMultiTraceUNet}
8
+ if architecture not in classes:
9
+ raise ValueError(f"Unknown architecture: {architecture}")
10
+ return classes[architecture](**cfg["model"])
models/dit.py ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Adapted from haidog-yaqub/MeanFlow, MIT; see third_party/MeanFlow.LICENSE.
2
+ import torch
3
+ import torch.nn as nn
4
+ import torch.nn.functional as F
5
+ import numpy as np
6
+ import math
7
+
8
+
9
+ class RMSNorm(nn.Module):
10
+ """RMSNorm compatible with PyTorch 2.2 and forward-mode differentiation."""
11
+ def __init__(self, dim, elementwise_affine=True):
12
+ super().__init__()
13
+ self.weight = nn.Parameter(torch.ones(dim)) if elementwise_affine else None
14
+
15
+ def forward(self, x):
16
+ dtype = x.dtype
17
+ value = x.float()
18
+ value = value * torch.rsqrt(value.square().mean(-1, keepdim=True) + 1e-6)
19
+ if self.weight is not None:
20
+ value = value * self.weight
21
+ return value.to(dtype)
22
+
23
+
24
+ class PatchEmbed(nn.Module):
25
+ """Non-overlapping convolutional patch projection, equivalent to source timm usage."""
26
+ def __init__(self, input_size, patch_size, in_channels, dim):
27
+ super().__init__()
28
+ self.input_size = input_size
29
+ self.patch_size = (patch_size, patch_size)
30
+ self.num_patches = (input_size // patch_size) ** 2
31
+ self.proj = nn.Conv2d(in_channels, dim, patch_size, stride=patch_size)
32
+
33
+ def forward(self, x):
34
+ if x.shape[-2:] != (self.input_size, self.input_size):
35
+ raise ValueError(f"Expected {self.input_size}x{self.input_size} input, got {x.shape[-2:]}")
36
+ return self.proj(x).flatten(2).transpose(1, 2)
37
+
38
+
39
+ class Mlp(nn.Sequential):
40
+ def __init__(self, in_features, hidden_features, act_layer, drop=0):
41
+ super().__init__(nn.Linear(in_features, hidden_features), act_layer(),
42
+ nn.Linear(hidden_features, in_features))
43
+
44
+
45
+ def expand_ada_params(param, x):
46
+ """Expand global (B, D) adaLN params to (B, T, D); pass through token-level params."""
47
+ if param.ndim == 2:
48
+ return param.unsqueeze(1)
49
+ return param
50
+
51
+
52
+ def modulate(x, scale, shift):
53
+ """
54
+ Apply adaLN modulation.
55
+ x: (B, T, D)
56
+ scale, shift: (B, D) for global adaLN or (B, T, D) for token-level adaLN
57
+ """
58
+ scale = expand_ada_params(scale, x)
59
+ shift = expand_ada_params(shift, x)
60
+ return x * (1 + scale) + shift
61
+
62
+
63
+ class TimestepEmbedder(nn.Module):
64
+ def __init__(self, dim, nfreq=256, scale=1000.0):
65
+ super().__init__()
66
+ self.mlp = nn.Sequential(nn.Linear(nfreq, dim), nn.SiLU(), nn.Linear(dim, dim))
67
+ self.nfreq = nfreq
68
+ self.scale = scale
69
+
70
+ @staticmethod
71
+ def timestep_embedding(t, dim, max_period=10000):
72
+ half_dim = dim // 2
73
+ freqs = torch.exp(
74
+ -math.log(max_period)
75
+ * torch.arange(start=0, end=half_dim, dtype=torch.float32)
76
+ / half_dim
77
+ ).to(device=t.device)
78
+ args = t[:, None].float() * freqs[None]
79
+ embedding = torch.cat([torch.cos(args), torch.sin(args)], dim=-1)
80
+ if dim % 2:
81
+ embedding = torch.cat(
82
+ [embedding, torch.zeros_like(embedding[:, :1])], dim=-1
83
+ )
84
+ return embedding
85
+
86
+ def forward(self, t):
87
+ t = t * self.scale
88
+ t_freq = self.timestep_embedding(t, self.nfreq)
89
+ t_emb = self.mlp(t_freq)
90
+ return t_emb
91
+
92
+ def initialize_weights(self):
93
+ nn.init.normal_(self.mlp[0].weight, std=0.02)
94
+ nn.init.normal_(self.mlp[2].weight, std=0.02)
95
+
96
+
97
+ class LabelEmbedder(nn.Module):
98
+ def __init__(self, num_classes, dim):
99
+ super().__init__()
100
+ self.embedding = nn.Embedding(num_classes, dim)
101
+ self.num_classes = num_classes
102
+
103
+ def forward(self, labels):
104
+ embeddings = self.embedding(labels)
105
+ return embeddings
106
+
107
+
108
+ class Attention(nn.Module):
109
+ def __init__(self, dim, num_heads=8, qkv_bias=True, qk_norm=True):
110
+ super().__init__()
111
+ assert dim % num_heads == 0
112
+ self.num_heads = num_heads
113
+ self.head_dim = dim // num_heads
114
+ self.scale = self.head_dim ** -0.5
115
+
116
+ self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
117
+ self.q_norm = RMSNorm(self.head_dim) if qk_norm else nn.Identity()
118
+ self.k_norm = RMSNorm(self.head_dim) if qk_norm else nn.Identity()
119
+ self.proj = nn.Linear(dim, dim)
120
+
121
+ def _native_attention(self, q, k, v):
122
+ attn = (q @ k.transpose(-2, -1)) * self.scale
123
+ attn = attn.softmax(dim=-1)
124
+ return attn @ v
125
+
126
+ def _flash_attention(self, q, k, v):
127
+ return F.scaled_dot_product_attention(q, k, v, scale=self.scale)
128
+
129
+ def forward(self, x, use_flash_attention=False):
130
+ B, N, C = x.shape
131
+ qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, self.head_dim).permute(2, 0, 3, 1, 4)
132
+ q, k, v = qkv.unbind(0)
133
+ q = self.q_norm(q)
134
+ k = self.k_norm(k)
135
+
136
+ if (
137
+ use_flash_attention
138
+ and q.is_cuda
139
+ and q.dtype in (torch.float16, torch.bfloat16)
140
+ ):
141
+ x = self._flash_attention(q, k, v)
142
+ else:
143
+ x = self._native_attention(q, k, v)
144
+
145
+ x = x.transpose(1, 2).reshape(B, N, C)
146
+ return self.proj(x)
147
+
148
+
149
+ class DiTBlock(nn.Module):
150
+ def __init__(self, dim, num_heads, mlp_ratio=4.0):
151
+ super().__init__()
152
+ self.norm1 = RMSNorm(dim, elementwise_affine=False)
153
+ self.attn = Attention(dim, num_heads=num_heads, qkv_bias=True, qk_norm=True)
154
+ self.norm2 = RMSNorm(dim, elementwise_affine=False)
155
+ mlp_dim = int(dim * mlp_ratio)
156
+ approx_gelu = lambda: nn.GELU(approximate="tanh")
157
+ self.mlp = Mlp(
158
+ in_features=dim, hidden_features=mlp_dim, act_layer=approx_gelu, drop=0
159
+ )
160
+ self.adaLN_modulation = nn.Sequential(nn.SiLU(), nn.Linear(dim, 6 * dim))
161
+
162
+ def forward(self, x, c, use_flash_attention=False):
163
+ shift_msa, scale_msa, gate_msa, shift_mlp, scale_mlp, gate_mlp = (
164
+ self.adaLN_modulation(c).chunk(6, dim=-1)
165
+ )
166
+ x = x + expand_ada_params(gate_msa, x) * self.attn(
167
+ modulate(self.norm1(x), scale_msa, shift_msa),
168
+ use_flash_attention=use_flash_attention,
169
+ )
170
+ x = x + expand_ada_params(gate_mlp, x) * self.mlp(
171
+ modulate(self.norm2(x), scale_mlp, shift_mlp)
172
+ )
173
+ return x
174
+
175
+
176
+ class FinalLayer(nn.Module):
177
+ def __init__(self, dim, patch_size, out_dim):
178
+ super().__init__()
179
+ self.norm_final = RMSNorm(dim, elementwise_affine=False)
180
+ self.linear = nn.Linear(dim, patch_size * patch_size * out_dim)
181
+ self.adaLN_modulation = nn.Sequential(nn.SiLU(), nn.Linear(dim, 2 * dim))
182
+
183
+ def forward(self, x, c):
184
+ shift, scale = self.adaLN_modulation(c).chunk(2, dim=-1)
185
+ x = modulate(self.norm_final(x), scale, shift)
186
+ x = self.linear(x)
187
+ return x
188
+
189
+
190
+ class TraceDiT(nn.Module):
191
+ def __init__(
192
+ self,
193
+ input_size=32,
194
+ patch_size=2,
195
+ in_channels=3,
196
+ dim=384,
197
+ depth=8,
198
+ num_heads=6,
199
+ mlp_ratio=4.0,
200
+ num_classes=10,
201
+ ):
202
+ super().__init__()
203
+ self.in_channels = in_channels
204
+ self.out_channels = in_channels
205
+ self.patch_size = patch_size
206
+ self.num_heads = num_heads
207
+ self.num_classes = num_classes
208
+
209
+ if input_size <= 0 or patch_size <= 0 or input_size % patch_size:
210
+ raise ValueError("input_size must be positive and divisible by patch_size")
211
+ if dim <= 0 or dim % 4 or num_heads <= 0 or dim % num_heads:
212
+ raise ValueError("dim must be positive and divisible by 4 and num_heads")
213
+ if depth <= 0 or mlp_ratio <= 0:
214
+ raise ValueError("depth and mlp_ratio must be positive")
215
+ self.x_embedder = PatchEmbed(input_size, patch_size, in_channels, dim)
216
+ self.t_embedder = TimestepEmbedder(dim)
217
+ self.r_embedder = TimestepEmbedder(dim)
218
+
219
+ self.use_cond = num_classes is not None
220
+ self.y_embedder = LabelEmbedder(num_classes, dim) if self.use_cond else None
221
+
222
+ num_patches = self.x_embedder.num_patches
223
+ self.register_buffer("pos_embed", torch.zeros(1, num_patches, dim))
224
+
225
+ self.blocks = nn.ModuleList([
226
+ DiTBlock(dim, num_heads, mlp_ratio) for _ in range(depth)
227
+ ])
228
+ self.final_layer = FinalLayer(dim, patch_size, self.out_channels)
229
+
230
+ self.initialize_weights()
231
+
232
+ def initialize_weights(self):
233
+ # Initialize transformer layers:
234
+ def _basic_init(module):
235
+ if isinstance(module, nn.Linear):
236
+ torch.nn.init.xavier_uniform_(module.weight)
237
+ if module.bias is not None:
238
+ nn.init.constant_(module.bias, 0)
239
+ self.apply(_basic_init)
240
+
241
+ # Initialize (and freeze) pos_embed by sin-cos embedding:
242
+ pos_embed = get_2d_sincos_pos_embed(self.pos_embed.shape[-1], int(self.x_embedder.num_patches ** 0.5))
243
+ self.pos_embed.data.copy_(torch.from_numpy(pos_embed).float().unsqueeze(0))
244
+
245
+ # Initialize patch_embed like nn.Linear (instead of nn.Conv2d):
246
+ w = self.x_embedder.proj.weight.data
247
+ nn.init.xavier_uniform_(w.view([w.shape[0], -1]))
248
+ nn.init.constant_(self.x_embedder.proj.bias, 0)
249
+
250
+ # Initialize label embedding table:
251
+ if self.y_embedder is not None:
252
+ nn.init.normal_(self.y_embedder.embedding.weight, std=0.02)
253
+
254
+ # Initialize timestep embedding MLP (t, r):
255
+ for embedder in (self.t_embedder, self.r_embedder):
256
+ embedder.initialize_weights()
257
+
258
+ # Zero-out adaLN modulation layers in DiT blocks:
259
+ for block in self.blocks:
260
+ nn.init.constant_(block.adaLN_modulation[-1].weight, 0)
261
+ nn.init.constant_(block.adaLN_modulation[-1].bias, 0)
262
+
263
+ # Zero-out output layers:
264
+ for final_layer in (self.final_layer,):
265
+ nn.init.constant_(final_layer.adaLN_modulation[-1].weight, 0)
266
+ nn.init.constant_(final_layer.adaLN_modulation[-1].bias, 0)
267
+ nn.init.constant_(final_layer.linear.weight, 0)
268
+ nn.init.constant_(final_layer.linear.bias, 0)
269
+
270
+ def unpatchify(self, x):
271
+ """
272
+ x: (N, T, patch_size**2 * C)
273
+ imgs: (N, H, W, C)
274
+ """
275
+ c = self.out_channels
276
+ p = self.x_embedder.patch_size[0]
277
+ h = w = int(x.shape[1] ** 0.5)
278
+ assert h * w == x.shape[1]
279
+
280
+ x = x.reshape(shape=(x.shape[0], h, w, p, p, c))
281
+ x = torch.einsum('nhwpqc->nchpwq', x)
282
+ imgs = x.reshape(shape=(x.shape[0], c, h * p, h * p))
283
+ return imgs
284
+
285
+ def forward(self, x, t, r, y=None, use_flash_attention=False):
286
+ """Return u(z,r,t); API preserves source order (x,t,r).
287
+
288
+ x: (B,C,H,W); t,r: (B,); y: class indices when conditioned.
289
+ The diagonal velocity uses this same head with r=t.
290
+ """
291
+ x = self.x_embedder(x) + self.pos_embed
292
+ c = self.t_embedder(t) + self.r_embedder(r)
293
+ if self.use_cond:
294
+ if y is None:
295
+ raise ValueError("Class-conditioned model requires labels y")
296
+ c = c + self.y_embedder(y)
297
+ for block in self.blocks:
298
+ x = block(x, c, use_flash_attention=use_flash_attention)
299
+ return self.unpatchify(self.final_layer(x, c))
300
+
301
+
302
+ # Positional embedding from:
303
+ # https://github.com/facebookresearch/mae/blob/main/util/pos_embed.py
304
+
305
+ def get_2d_sincos_pos_embed(embed_dim, grid_size, cls_token=False, extra_tokens=0):
306
+ """
307
+ grid_size: int of the grid height and width
308
+ return:
309
+ pos_embed: [grid_size*grid_size, embed_dim] or [1+grid_size*grid_size, embed_dim] (w/ or w/o cls_token)
310
+ """
311
+ grid_h = np.arange(grid_size, dtype=np.float32)
312
+ grid_w = np.arange(grid_size, dtype=np.float32)
313
+ grid = np.meshgrid(grid_w, grid_h) # here w goes first
314
+ grid = np.stack(grid, axis=0)
315
+
316
+ grid = grid.reshape([2, 1, grid_size, grid_size])
317
+ pos_embed = get_2d_sincos_pos_embed_from_grid(embed_dim, grid)
318
+ if cls_token and extra_tokens > 0:
319
+ pos_embed = np.concatenate([np.zeros([extra_tokens, embed_dim]), pos_embed], axis=0)
320
+ return pos_embed
321
+
322
+
323
+ def get_2d_sincos_pos_embed_from_grid(embed_dim, grid):
324
+ assert embed_dim % 2 == 0
325
+
326
+ # use half of dimensions to encode grid_h
327
+ emb_h = get_1d_sincos_pos_embed_from_grid(embed_dim // 2, grid[0]) # (H*W, D/2)
328
+ emb_w = get_1d_sincos_pos_embed_from_grid(embed_dim // 2, grid[1]) # (H*W, D/2)
329
+
330
+ emb = np.concatenate([emb_h, emb_w], axis=1) # (H*W, D)
331
+ return emb
332
+
333
+
334
+ def get_1d_sincos_pos_embed_from_grid(embed_dim, pos):
335
+ """
336
+ embed_dim: output dimension for each position
337
+ pos: a list of positions to be encoded: size (M,)
338
+ out: (M, D)
339
+ """
340
+ assert embed_dim % 2 == 0
341
+ omega = np.arange(embed_dim // 2, dtype=np.float64)
342
+ omega /= embed_dim / 2.
343
+ omega = 1. / 10000**omega # (D/2,)
344
+
345
+ pos = pos.reshape(-1) # (M,)
346
+ out = np.einsum('m,d->md', pos, omega) # (M, D/2), outer product
347
+
348
+ emb_sin = np.sin(out) # (M, D/2)
349
+ emb_cos = np.cos(out) # (M, D/2)
350
+
351
+ emb = np.concatenate([emb_sin, emb_cos], axis=1) # (M, D)
352
+ return emb
models/unet.py ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Conditional U-Net adapted from the user-provided Untitled0.ipynb.
2
+
3
+ Architecture lineage: base channels 44, (1,2,2,4), one residual block per level.
4
+ Uses the same (z,t,r,y) API as TraceDiT so training and Hub sampling share a path.
5
+ """
6
+ import math
7
+ import torch
8
+ from torch import nn
9
+ import torch.nn.functional as F
10
+
11
+
12
+ def gn_groups(ch, max_groups=8):
13
+ for g in range(min(max_groups, ch), 0, -1):
14
+ if ch % g == 0:
15
+ return g
16
+ return 1
17
+
18
+
19
+ class JVPGroupNorm(nn.GroupNorm):
20
+ def forward(self, x):
21
+ # PyTorch 2.2 forward AD can fail on channels-last GroupNorm strides.
22
+ # Normalize a contiguous view; convolutions still use channels-last.
23
+ return super().forward(x.contiguous())
24
+
25
+
26
+ class ScalarEmbed(nn.Module):
27
+ """Sinusoidal scalar embedding with cached frequencies."""
28
+ def __init__(self, out_dim, fourier_dim=64):
29
+ super().__init__()
30
+ self.fourier_dim = fourier_dim
31
+ half = fourier_dim // 2
32
+ freqs = torch.exp(
33
+ -math.log(10_000) * torch.arange(half, dtype=torch.float32) / max(1, half)
34
+ )
35
+ self.register_buffer("freqs", freqs, persistent=False)
36
+ self.net = nn.Sequential(
37
+ nn.Linear(fourier_dim, out_dim),
38
+ nn.SiLU(),
39
+ nn.Linear(out_dim, out_dim),
40
+ )
41
+
42
+ def forward(self, x):
43
+ args = x.float()[:, None] * self.freqs[None]
44
+ emb = torch.cat([torch.cos(args), torch.sin(args)], dim=-1)
45
+ if self.fourier_dim % 2:
46
+ emb = F.pad(emb, (0, 1))
47
+ return self.net(emb)
48
+
49
+
50
+ class ResBlock(nn.Module):
51
+ def __init__(self, in_ch, out_ch, cond_dim):
52
+ super().__init__()
53
+ self.norm1 = JVPGroupNorm(gn_groups(in_ch), in_ch)
54
+ self.conv1 = nn.Conv2d(in_ch, out_ch, 3, padding=1)
55
+ self.cond = nn.Linear(cond_dim, 2 * out_ch)
56
+ self.norm2 = JVPGroupNorm(gn_groups(out_ch), out_ch)
57
+ self.conv2 = nn.Conv2d(out_ch, out_ch, 3, padding=1)
58
+ self.skip = nn.Identity() if in_ch == out_ch else nn.Conv2d(in_ch, out_ch, 1)
59
+ nn.init.zeros_(self.conv2.weight)
60
+ nn.init.zeros_(self.conv2.bias)
61
+
62
+ def forward(self, x, c):
63
+ h = self.conv1(F.silu(self.norm1(x)))
64
+ scale, shift = self.cond(F.silu(c)).chunk(2, dim=1)
65
+ h = self.norm2(h) * (1 + scale[:, :, None, None]) + shift[:, :, None, None]
66
+ return self.skip(x) + self.conv2(F.silu(h))
67
+
68
+
69
+ class AttentionBlock(nn.Module):
70
+ """Static math attention path: forward-mode-AD safe and compile-friendly."""
71
+ def __init__(self, ch, max_heads=4):
72
+ super().__init__()
73
+ heads = min(max_heads, ch)
74
+ while ch % heads:
75
+ heads -= 1
76
+ self.heads = heads
77
+ self.norm = JVPGroupNorm(gn_groups(ch), ch)
78
+ self.qkv = nn.Conv1d(ch, 3 * ch, 1)
79
+ self.proj = nn.Conv1d(ch, ch, 1)
80
+ nn.init.zeros_(self.proj.weight)
81
+ nn.init.zeros_(self.proj.bias)
82
+
83
+ def forward(self, x):
84
+ b, c, h, w = x.shape
85
+ L = h * w
86
+ z = self.norm(x).reshape(b, c, L)
87
+ q, k, v = self.qkv(z).chunk(3, dim=1)
88
+ d = c // self.heads
89
+ q = q.reshape(b, self.heads, d, L).transpose(-1, -2)
90
+ k = k.reshape(b, self.heads, d, L).transpose(-1, -2)
91
+ v = v.reshape(b, self.heads, d, L).transpose(-1, -2)
92
+ out = torch.softmax((q @ k.transpose(-1, -2)) * (d ** -0.5), dim=-1) @ v
93
+ out = self.proj(out.transpose(-1, -2).reshape(b, c, L)).reshape(b, c, h, w)
94
+ return x + out
95
+
96
+
97
+ class Downsample(nn.Module):
98
+ def __init__(self, ch):
99
+ super().__init__()
100
+ self.op = nn.Conv2d(ch, ch, 3, stride=2, padding=1)
101
+
102
+ def forward(self, x):
103
+ return self.op(x)
104
+
105
+
106
+ class Upsample(nn.Module):
107
+ def __init__(self, ch):
108
+ super().__init__()
109
+ self.op = nn.Conv2d(ch, ch, 3, padding=1)
110
+
111
+ def forward(self, x):
112
+ return self.op(F.interpolate(x, scale_factor=2.0, mode="nearest"))
113
+
114
+
115
+ class ConditionalMultiTraceUNet(nn.Module):
116
+ """One shared conditional field u_theta(z,r,t,y)."""
117
+ def __init__(self, input_size=32, in_channels=3, num_classes=10,
118
+ base_channels=84, channel_mult=(1, 2, 2, 4), num_res_blocks=1,
119
+ cond_dim=356, attn_resolutions=(8,), fourier_dim=64):
120
+ super().__init__()
121
+ cfg = dict(image_size=input_size, num_classes=num_classes,
122
+ base_channels=base_channels, channel_mult=channel_mult,
123
+ num_res_blocks=num_res_blocks, cond_dim=cond_dim,
124
+ attn_resolutions=attn_resolutions, fourier_dim=fourier_dim)
125
+ base = cfg["base_channels"]
126
+ mults = cfg["channel_mult"]
127
+ nrb = cfg["num_res_blocks"]
128
+ cd = cfg["cond_dim"]
129
+
130
+ self.attn_res = set(cfg["attn_resolutions"])
131
+ self.t_emb = ScalarEmbed(cd, cfg["fourier_dim"])
132
+ self.r_emb = ScalarEmbed(cd, cfg["fourier_dim"])
133
+ self.y_emb = nn.Embedding(cfg["num_classes"], cd)
134
+ nn.init.normal_(self.y_emb.weight, std=0.02)
135
+ self.cond_out = nn.Sequential(nn.SiLU(), nn.Linear(cd, cd))
136
+
137
+ self.in_conv = nn.Conv2d(in_channels, base, 3, padding=1)
138
+ self.down_levels = nn.ModuleList()
139
+ ch = base
140
+ res = cfg["image_size"]
141
+ skip_channels = [ch]
142
+
143
+ for li, m in enumerate(mults):
144
+ out_ch = base * m
145
+ blocks = nn.ModuleList()
146
+ atts = nn.ModuleList()
147
+ for _ in range(nrb):
148
+ blocks.append(ResBlock(ch, out_ch, cd))
149
+ ch = out_ch
150
+ atts.append(AttentionBlock(ch) if res in self.attn_res else nn.Identity())
151
+ skip_channels.append(ch)
152
+ down = Downsample(ch) if li != len(mults) - 1 else nn.Identity()
153
+ self.down_levels.append(nn.ModuleDict({"blocks": blocks, "atts": atts, "down": down}))
154
+ if li != len(mults) - 1:
155
+ skip_channels.append(ch)
156
+ res //= 2
157
+
158
+ self.mid1 = ResBlock(ch, ch, cd)
159
+ self.mid_attn = AttentionBlock(ch)
160
+ self.mid2 = ResBlock(ch, ch, cd)
161
+
162
+ self.up_levels = nn.ModuleList()
163
+ stack = list(skip_channels)
164
+ res = cfg["image_size"] // (2 ** (len(mults) - 1))
165
+ for rev_idx, m in enumerate(reversed(mults)):
166
+ li = len(mults) - 1 - rev_idx
167
+ out_ch = base * m
168
+ blocks = nn.ModuleList()
169
+ atts = nn.ModuleList()
170
+ for _ in range(nrb + 1):
171
+ skip_ch = stack.pop()
172
+ blocks.append(ResBlock(ch + skip_ch, out_ch, cd))
173
+ ch = out_ch
174
+ atts.append(AttentionBlock(ch) if res in self.attn_res else nn.Identity())
175
+ up = Upsample(ch) if li != 0 else nn.Identity()
176
+ self.up_levels.append(nn.ModuleDict({"blocks": blocks, "atts": atts, "up": up}))
177
+ if li != 0:
178
+ res *= 2
179
+
180
+ if stack:
181
+ raise RuntimeError(f"Unused build-time skips: {stack}")
182
+
183
+ self.out_norm = JVPGroupNorm(gn_groups(ch), ch)
184
+ self.u_head = nn.Conv2d(ch, in_channels, 3, padding=1)
185
+ nn.init.zeros_(self.u_head.weight)
186
+ nn.init.zeros_(self.u_head.bias)
187
+
188
+ def forward(self, x, t, r, y=None, use_flash_attention=False):
189
+ # Reference notebook uses (x,r,t,y); repository API uses (x,t,r,y).
190
+ if y is None:
191
+ raise ValueError("This U-Net requires class labels")
192
+ c = self.cond_out(self.t_emb(t) + self.r_emb(r) + self.y_emb(y))
193
+ hs = []
194
+ x = self.in_conv(x)
195
+ hs.append(x)
196
+
197
+ for level in self.down_levels:
198
+ for block, attn in zip(level["blocks"], level["atts"]):
199
+ x = attn(block(x, c))
200
+ hs.append(x)
201
+ if not isinstance(level["down"], nn.Identity):
202
+ x = level["down"](x)
203
+ hs.append(x)
204
+
205
+ x = self.mid2(self.mid_attn(self.mid1(x, c)), c)
206
+
207
+ for level in self.up_levels:
208
+ for block, attn in zip(level["blocks"], level["atts"]):
209
+ x = attn(block(torch.cat([x, hs.pop()], dim=1), c))
210
+ x = level["up"](x)
211
+
212
+ if hs:
213
+ raise RuntimeError(f"Unconsumed runtime skips: {len(hs)}")
214
+ return self.u_head(F.silu(self.out_norm(x)))
multi_trace_imf.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Equal-grid Multi-Trace objective and 1..K sampling from Untitled0.ipynb."""
2
+ import torch
3
+ from trace_imf import TraceIMF
4
+
5
+
6
+ class MultiTraceIMF(TraceIMF):
7
+ def __init__(self, max_nfe=5, jvp_precision="bf16", channels_last=True, **kwargs):
8
+ super().__init__(**kwargs)
9
+ if max_nfe < 1 or jvp_precision not in ("fp32", "bf16"):
10
+ raise ValueError("Invalid max_nfe or JVP precision")
11
+ self.max_nfe = max_nfe
12
+ self.jvp_precision = jvp_precision
13
+ self.channels_last = channels_last
14
+
15
+ def draw_interval(self, device, generator=None, nfe=None):
16
+ # One K and j for the entire effective batch, including all microbatches.
17
+ k = int(torch.randint(1, self.max_nfe + 1, (), device=device, generator=generator)) if nfe is None else nfe
18
+ if not 1 <= k <= self.max_nfe:
19
+ raise ValueError("NFE outside the trained range")
20
+ j = int(torch.randint(k, (), device=device, generator=generator))
21
+ return k, j
22
+
23
+ def loss(self, model, x, labels=None, *, interval=None, nfe=None, generator=None,
24
+ t=None, r=None, noise=None, derivative_model=None):
25
+ if t is None:
26
+ k, j = interval or self.draw_interval(x.device, generator, nfe)
27
+ r = torch.full((len(x),), j / k, device=x.device)
28
+ t = r + torch.rand(len(x), device=x.device, generator=generator) / k
29
+ elif r is None:
30
+ raise ValueError("Explicit Multi-Trace t requires explicit r")
31
+ return super().loss(model, x, labels, derivative_model=derivative_model,
32
+ t=t, r=r, noise=noise, generator=generator)
33
+
34
+ @torch.no_grad()
35
+ def sample(self, model, n_samples=None, labels=None, *, device=None, noise=None, nfe=1):
36
+ if not 1 <= nfe <= self.max_nfe:
37
+ raise ValueError("NFE outside the trained range")
38
+ device = device or next(model.parameters()).device
39
+ if labels is None:
40
+ raise ValueError("Class-conditioned sampling requires labels")
41
+ labels = labels.to(device)
42
+ z = (torch.randn(len(labels), self.channels, self.image_size, self.image_size, device=device)
43
+ if noise is None else noise.to(device).clone())
44
+ if len(z) != len(labels):
45
+ raise ValueError("Noise and labels must have the same batch size")
46
+ if self.channels_last:
47
+ z = z.contiguous(memory_format=torch.channels_last)
48
+ was_training = model.training
49
+ model.eval()
50
+ try:
51
+ for index in range(nfe, 0, -1):
52
+ t = torch.full((len(z),), index / nfe, device=device)
53
+ r = torch.full_like(t, (index - 1) / nfe)
54
+ z = z - model(z, t, r, y=labels, use_flash_attention=False) / nfe
55
+ return (z.clamp(-1, 1) + 1) * 0.5
56
+ finally:
57
+ model.train(was_training)
objectives.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Objective selection shared by training and the standalone inference bundle."""
2
+ from trace_imf import TraceIMF
3
+ from multi_trace_imf import MultiTraceIMF
4
+
5
+
6
+ def build_objective(cfg):
7
+ common = dict(channels=cfg["model"]["in_channels"],
8
+ image_size=cfg["model"]["input_size"],
9
+ num_classes=cfg["model"]["num_classes"])
10
+ name = cfg.get("objective", "trace_imf")
11
+ if name == "multi_trace_imf":
12
+ return MultiTraceIMF(**common, **cfg["multi_trace_imf"])
13
+ if name == "trace_imf":
14
+ return TraceIMF(**common, **cfg["trace_imf"])
15
+ raise ValueError(f"Unknown objective: {name}")
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ torch>=2.2
2
+ numpy>=1.24
3
+ safetensors>=0.4
4
+ pillow>=9
5
+ huggingface_hub>=0.21
sample.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Sample the exported custom TraceDiT inference bundle without loading pickle."""
2
+ import argparse
3
+ import json
4
+ from pathlib import Path
5
+
6
+ import numpy as np
7
+ from PIL import Image
8
+ from safetensors.torch import load_file
9
+ import torch
10
+
11
+ from models import build_backbone
12
+ from objectives import build_objective
13
+
14
+
15
+ def main():
16
+ parser = argparse.ArgumentParser()
17
+ parser.add_argument("--model-dir", required=True)
18
+ parser.add_argument("--output", default="samples.png")
19
+ parser.add_argument("--n-per-class", type=int, default=4)
20
+ parser.add_argument("--seed", type=int, default=42)
21
+ parser.add_argument("--weights", default="model.safetensors")
22
+ parser.add_argument("--nfe", type=int, default=1)
23
+ args = parser.parse_args()
24
+ if args.n_per_class <= 0:
25
+ parser.error("n-per-class must be positive")
26
+ folder = Path(args.model_dir)
27
+ cfg = json.loads((folder / "config.json").read_text())
28
+ device = "cuda" if torch.cuda.is_available() else "cpu"
29
+ torch.manual_seed(args.seed)
30
+ model = build_backbone(cfg).to(device)
31
+ model.load_state_dict(load_file(str(folder / args.weights), device=device), strict=True)
32
+ objective = build_objective(cfg)
33
+ if args.nfe != 1 and not hasattr(objective, "max_nfe"):
34
+ parser.error("This model supports only one NFE")
35
+ if objective.num_classes is None:
36
+ labels, columns = None, 10
37
+ else:
38
+ columns = objective.num_classes
39
+ labels = torch.arange(columns, device=device).repeat(args.n_per_class)
40
+ images = objective.sample(model, n_samples=columns * args.n_per_class,
41
+ labels=labels, device=device,
42
+ **({"nfe": args.nfe} if hasattr(objective, "max_nfe") else {}))
43
+ pixels = (images.permute(0, 2, 3, 1).cpu().numpy() * 255).round().astype(np.uint8)
44
+ rows = args.n_per_class
45
+ if pixels.shape[-1] == 1:
46
+ pixels = pixels[..., 0]
47
+ grid = np.concatenate([np.concatenate(pixels[row*columns:(row+1)*columns], axis=1)
48
+ for row in range(rows)], axis=0)
49
+ output = Path(args.output)
50
+ output.parent.mkdir(parents=True, exist_ok=True)
51
+ Image.fromarray(grid).save(output)
52
+ print(f"{args.nfe}-NFE samples saved: {output}")
53
+
54
+
55
+ if __name__ == "__main__":
56
+ main()
sample_grid.png ADDED
sample_grid_nfe2.png ADDED
sample_grid_nfe3.png ADDED
sample_grid_nfe4.png ADDED
sample_grid_nfe5.png ADDED
samples.jsonl ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"step": 42000, "pixel_mean": 0.47372499108314514, "nfe": 1, "pixel_std": 0.23482201993465424, "between_samples_std": 0.2342541217803955}
2
+ {"step": 42000, "pixel_mean": 0.4737403690814972, "nfe": 2, "pixel_std": 0.23318670690059662, "between_samples_std": 0.23249799013137817}
3
+ {"step": 42000, "pixel_mean": 0.4733788073062897, "nfe": 3, "pixel_std": 0.23294048011302948, "between_samples_std": 0.23233386874198914}
4
+ {"step": 42000, "pixel_mean": 0.47353851795196533, "nfe": 4, "pixel_std": 0.23217451572418213, "between_samples_std": 0.23162195086479187}
5
+ {"step": 42000, "pixel_mean": 0.4734746813774109, "nfe": 5, "pixel_std": 0.2306039184331894, "between_samples_std": 0.23005102574825287}
6
+ {"step": 43000, "pixel_mean": 0.4738962948322296, "nfe": 1, "pixel_std": 0.23467251658439636, "between_samples_std": 0.23411357402801514}
7
+ {"step": 43000, "pixel_mean": 0.47399187088012695, "nfe": 2, "pixel_std": 0.23315978050231934, "between_samples_std": 0.23246732354164124}
8
+ {"step": 43000, "pixel_mean": 0.4736575782299042, "nfe": 3, "pixel_std": 0.23255649209022522, "between_samples_std": 0.23195421695709229}
9
+ {"step": 43000, "pixel_mean": 0.4738808572292328, "nfe": 4, "pixel_std": 0.23214948177337646, "between_samples_std": 0.23160535097122192}
10
+ {"step": 43000, "pixel_mean": 0.4738691449165344, "nfe": 5, "pixel_std": 0.23027542233467102, "between_samples_std": 0.22973471879959106}
11
+ {"step": 44000, "pixel_mean": 0.47436124086380005, "nfe": 1, "pixel_std": 0.23476190865039825, "between_samples_std": 0.23417595028877258}
12
+ {"step": 44000, "pixel_mean": 0.474582701921463, "nfe": 2, "pixel_std": 0.23312358558177948, "between_samples_std": 0.23241935670375824}
13
+ {"step": 44000, "pixel_mean": 0.47428470849990845, "nfe": 3, "pixel_std": 0.23243620991706848, "between_samples_std": 0.23181688785552979}
14
+ {"step": 44000, "pixel_mean": 0.4745030701160431, "nfe": 4, "pixel_std": 0.23207718133926392, "between_samples_std": 0.2315332293510437}
15
+ {"step": 44000, "pixel_mean": 0.4745500683784485, "nfe": 5, "pixel_std": 0.23035971820354462, "between_samples_std": 0.2298177182674408}
16
+ {"step": 45000, "pixel_mean": 0.47422075271606445, "nfe": 1, "pixel_std": 0.23496539890766144, "between_samples_std": 0.23434244096279144}
17
+ {"step": 45000, "pixel_mean": 0.4741981029510498, "nfe": 2, "pixel_std": 0.23349685966968536, "between_samples_std": 0.23275989294052124}
18
+ {"step": 45000, "pixel_mean": 0.47374066710472107, "nfe": 3, "pixel_std": 0.23272140324115753, "between_samples_std": 0.23208104074001312}
19
+ {"step": 45000, "pixel_mean": 0.4738740026950836, "nfe": 4, "pixel_std": 0.23238259553909302, "between_samples_std": 0.2318258285522461}
20
+ {"step": 45000, "pixel_mean": 0.4740034341812134, "nfe": 5, "pixel_std": 0.2307807356119156, "between_samples_std": 0.23024126887321472}
21
+ {"step": 46000, "pixel_mean": 0.4745643734931946, "nfe": 1, "pixel_std": 0.23507004976272583, "between_samples_std": 0.2344510555267334}
22
+ {"step": 46000, "pixel_mean": 0.4744739830493927, "nfe": 2, "pixel_std": 0.23381182551383972, "between_samples_std": 0.2330787479877472}
23
+ {"step": 46000, "pixel_mean": 0.47411832213401794, "nfe": 3, "pixel_std": 0.23263326287269592, "between_samples_std": 0.23199662566184998}
24
+ {"step": 46000, "pixel_mean": 0.474417120218277, "nfe": 4, "pixel_std": 0.2324787825345993, "between_samples_std": 0.23192620277404785}
25
+ {"step": 46000, "pixel_mean": 0.47444015741348267, "nfe": 5, "pixel_std": 0.2309519499540329, "between_samples_std": 0.23041489720344543}
26
+ {"step": 47000, "pixel_mean": 0.47470709681510925, "nfe": 1, "pixel_std": 0.23535038530826569, "between_samples_std": 0.23473000526428223}
27
+ {"step": 47000, "pixel_mean": 0.4745272994041443, "nfe": 2, "pixel_std": 0.2342585325241089, "between_samples_std": 0.23352518677711487}
28
+ {"step": 47000, "pixel_mean": 0.47419074177742004, "nfe": 3, "pixel_std": 0.23334956169128418, "between_samples_std": 0.2327093929052353}
29
+ {"step": 47000, "pixel_mean": 0.4744076132774353, "nfe": 4, "pixel_std": 0.23303648829460144, "between_samples_std": 0.23248785734176636}
30
+ {"step": 47000, "pixel_mean": 0.47451314330101013, "nfe": 5, "pixel_std": 0.23162786662578583, "between_samples_std": 0.2310994565486908}
31
+ {"step": 48000, "pixel_mean": 0.47464919090270996, "nfe": 1, "pixel_std": 0.2351643443107605, "between_samples_std": 0.2345452606678009}
32
+ {"step": 48000, "pixel_mean": 0.47439342737197876, "nfe": 2, "pixel_std": 0.23403969407081604, "between_samples_std": 0.2333148717880249}
33
+ {"step": 48000, "pixel_mean": 0.47428229451179504, "nfe": 3, "pixel_std": 0.23292940855026245, "between_samples_std": 0.2323130965232849}
34
+ {"step": 48000, "pixel_mean": 0.47453099489212036, "nfe": 4, "pixel_std": 0.2325868308544159, "between_samples_std": 0.23205390572547913}
35
+ {"step": 48000, "pixel_mean": 0.47459015250205994, "nfe": 5, "pixel_std": 0.23120051622390747, "between_samples_std": 0.23069819808006287}
36
+ {"step": 49000, "pixel_mean": 0.4743174612522125, "nfe": 1, "pixel_std": 0.23494189977645874, "between_samples_std": 0.23430010676383972}
37
+ {"step": 49000, "pixel_mean": 0.4741107225418091, "nfe": 2, "pixel_std": 0.23382453620433807, "between_samples_std": 0.23308944702148438}
38
+ {"step": 49000, "pixel_mean": 0.47396624088287354, "nfe": 3, "pixel_std": 0.23279331624507904, "between_samples_std": 0.2321631908416748}
39
+ {"step": 49000, "pixel_mean": 0.47409728169441223, "nfe": 4, "pixel_std": 0.2323838174343109, "between_samples_std": 0.2318393886089325}
40
+ {"step": 49000, "pixel_mean": 0.47436952590942383, "nfe": 5, "pixel_std": 0.23112046718597412, "between_samples_std": 0.23060618340969086}
41
+ {"step": 50000, "pixel_mean": 0.4741409122943878, "nfe": 1, "pixel_std": 0.23498037457466125, "between_samples_std": 0.23431378602981567}
42
+ {"step": 50000, "pixel_mean": 0.47384196519851685, "nfe": 2, "pixel_std": 0.23412783443927765, "between_samples_std": 0.2333933562040329}
43
+ {"step": 50000, "pixel_mean": 0.47364792227745056, "nfe": 3, "pixel_std": 0.2328539341688156, "between_samples_std": 0.23222188651561737}
44
+ {"step": 50000, "pixel_mean": 0.47384998202323914, "nfe": 4, "pixel_std": 0.23271359503269196, "between_samples_std": 0.2321617305278778}
45
+ {"step": 50000, "pixel_mean": 0.47402939200401306, "nfe": 5, "pixel_std": 0.23148764669895172, "between_samples_std": 0.23096564412117004}
source_manifest.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "repo_url": "https://github.com/namdeptraivcd/IMF.git",
3
+ "git_commit": "59d5164a2b20753b846568264ebb10c3e49beace",
4
+ "files": {
5
+ "train.py": "34f72a2bbba5341aeda9cd3fe021e18ed6bf1bbc73b823187a97ed83e03cc3aa",
6
+ "monitoring.py": "5315ee70585789a684162fbd4fa3a8f2479d5186d282d22a3fc314432b3100a9",
7
+ "hub.py": "ca23b68ef728ea2ae514918a09bb678d80df303fc97949593f2c6607cdc0fa03",
8
+ "sample.py": "90f1089547475b5ab1d8f5f8d160a33c639826eda95c6ca79ee2d3f527b24be1",
9
+ "models/dit.py": "843080c2702d596dd3b16e35b78501b168ca008d013d4394ee9c64c086361819",
10
+ "models/__init__.py": "1d9d5ec9cc26f0e76e570735a42e420314fdccc0a4aa113ddac642fd4d147c36",
11
+ "trace_imf.py": "43e2e8105541257376f648f3ee82a92cce8402530be59372f8d7ed0516501263",
12
+ "data.py": "a346a102fac83a40823501b68cf8055ac385ab3837cb6ef62b9212bdc7b9dffc",
13
+ "configs/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
14
+ "configs/cifar10_22m.py": "1599fb09bab2ac556f46f434f82d22d61aa22901140679b4bfef62aa65245588",
15
+ "requirements-notebook.txt": "858b7587f8c9b4778b2f13955ce8a00ff1f9a8f1cbfabb0ce94c2e97c55cc5fc",
16
+ "models/unet.py": "57baed6e4ef61ca23aa0ddf62ec0c30b85e6d27f2504416269bb6d1245ee22df",
17
+ "multi_trace_imf.py": "a807809500be68da9d33f13fd528d987e61471161ad869f97c7411bb225fe5b8",
18
+ "objectives.py": "691d152ee1f0970fa9c279c596d09070c5a5c6618ac465bb462fac0188796f7d",
19
+ "ema.py": "1bc020387ec0020724d0a5c066180100f08204102fd79e804c3624203ebc4579",
20
+ "evaluation.py": "6f2d19263ea1b8c13c9fdc4678062adae99ea0773e0f03c8001f81a598f03238",
21
+ "configs/multitrace_cifar10_22m.py": "e0a8fc408170b618d88d19ccf71993af5f469e59c36c31dd38d920b57ee727bb",
22
+ "configs/multitrace_cifar10_15m.py": "96863dc436dce0accb6a2722b4398aa1a8a6ebf4e96386511767fe9b3c2db69d"
23
+ }
24
+ }
tensorboard/segment_0041000_1791126419399065883/events.out.tfevents.1791126419.modal.498.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0419329574f8b6750d3cdfb4cd8da01f5d8d2c4ec603ae8cb6fed34a6bdb1527
3
+ size 4065148
third_party/MeanFlow.LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jiarui Hai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
third_party/README.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Nguồn code
2
+
3
+ `models/dit.py`, `data.py` và cấu trúc training được kế thừa/adapt từ
4
+ `../backbone_IMF`, nguồn [haidog-yaqub/MeanFlow](https://github.com/haidog-yaqub/MeanFlow),
5
+ commit `97cc5182abe9d69e5dcb350268f603fbe31a5897`.
6
+ MIT notice được giữ trong `MeanFlow.LICENSE`.
7
+
8
+ Model giữ attention, adaLN-zero, embedding và unpatchify của nguồn; thay hai head
9
+ bằng một head u, bỏ CFG embedding, cố định positional embedding, thay lớp timm
10
+ bằng PyTorch tương đương và RMSNorm với epsilon 1e-6 để hỗ trợ PyTorch 2.2.
11
+ Loss Trace-iMF được viết theo tài liệu idea của người dùng.
12
+
13
+ `models/unet.py` giữ U-Net topology/shared head và `multi_trace_imf.py` giữ
14
+ equal-grid interval schedule từ notebook `Untitled0.ipynb` do người dùng cung
15
+ cấp. Bản 22M widen base44→84 và cond160→356; thứ tự API được chuẩn hóa thành
16
+ `(z,t,r,y)`. GroupNorm nhận contiguous input để hỗ trợ forward AD trên PyTorch2.2.
17
+ EMA/accumulation/resume/monitoring là phần tích hợp của IMF; không thực thi
18
+ các cell Colab/unzip/Drive từ notebook tham chiếu.
trace_imf.py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Two-trace quadratic objective from idea.pdf, sections 10 and 14."""
2
+ import torch
3
+ import torch.nn.functional as F
4
+
5
+
6
+ class TraceIMF:
7
+ def __init__(self, channels=3, image_size=32, num_classes=10, lambda_diag=1.0):
8
+ if lambda_diag <= 0:
9
+ raise ValueError("lambda_diag must be positive to train both traces")
10
+ self.channels = channels
11
+ self.image_size = image_size
12
+ self.num_classes = num_classes
13
+ self.lambda_diag = lambda_diag
14
+
15
+ def loss(self, model, x, labels=None, *, derivative_model=None, t=None, noise=None,
16
+ r=None, generator=None):
17
+ """x is raw image data in [0,1]. Optional t/noise permit exact checks.
18
+
19
+ Use the unwrapped model for JVP under Accelerate/DDP. The single joint
20
+ grad-enabled call through model trains both edge and diagonal safely.
21
+ """
22
+ b = x.shape[0]
23
+ x = x.float() * 2 - 1
24
+ t = torch.rand(b, device=x.device, generator=generator) if t is None else t.to(x.device).float()
25
+ noise = torch.randn(x.shape, device=x.device, generator=generator) if noise is None else noise.to(x.device).float()
26
+ if t.shape != (b,) or noise.shape != x.shape:
27
+ raise ValueError("Expected t with shape (B,) and noise with the image shape")
28
+ if self.num_classes is not None and labels is None:
29
+ raise ValueError("Class-conditioned training requires labels")
30
+ if self.num_classes is None:
31
+ labels = None
32
+ t_image = t[:, None, None, None]
33
+ z = (1 - t_image) * x + t_image * noise
34
+ target = noise - x
35
+ r = torch.zeros_like(t) if r is None else r.to(x.device).float()
36
+ if r.shape != t.shape or (r < 0).any() or (t > 1).any() or (r > t).any():
37
+ raise ValueError("Require 0 <= r <= t <= 1, with r and t shaped (B,)")
38
+ if getattr(self, "channels_last", False):
39
+ z = z.contiguous(memory_format=torch.channels_last)
40
+
41
+ # Both branches use the SAME u head, evaluated at r=0 and r=t.
42
+ pair_labels = None if labels is None else torch.cat((labels, labels))
43
+ predictions = model(torch.cat((z, z)), torch.cat((t, t)),
44
+ torch.cat((r, t)), y=pair_labels,
45
+ use_flash_attention=True)
46
+ edge, diagonal = predictions.chunk(2)
47
+ jvp_model = model if derivative_model is None else derivative_model
48
+
49
+ # FP32 JVP: native attention supports forward AD; SDPA is used only in
50
+ # the grad-enabled forward. No parameter gradient through the JVP.
51
+ use_bf16 = getattr(self, "jvp_precision", "fp32") == "bf16" and x.device.type == "cuda"
52
+ with torch.no_grad(), torch.autocast(device_type=x.device.type, enabled=use_bf16,
53
+ dtype=torch.bfloat16):
54
+ def edge_fn(z_value, t_value, r_value):
55
+ # Accelerate may autocast the instance's forward even after
56
+ # unwrap_model. The class forward bypasses that AMP wrapper
57
+ # without mutating the grad-enabled training forward.
58
+ return type(jvp_model).forward(jvp_model, z_value, t_value, r_value,
59
+ y=labels, use_flash_attention=False)
60
+
61
+ _, derivative = torch.func.jvp(
62
+ edge_fn, (z, t, r),
63
+ (diagonal.detach().float(), torch.ones_like(t), torch.zeros_like(r)),
64
+ )
65
+
66
+ compound = edge.float() + (t - r)[:, None, None, None] * derivative.detach().float()
67
+ edge_loss = F.mse_loss(compound, target)
68
+ diag_loss = F.mse_loss(diagonal.float(), target)
69
+ loss = edge_loss + self.lambda_diag * diag_loss
70
+ return loss, {"edge_loss": edge_loss.detach(), "diag_loss": diag_loss.detach(),
71
+ "jvp_rms": derivative.detach().square().mean().sqrt()}
72
+
73
+ @torch.no_grad()
74
+ def sample(self, model, n_samples=None, labels=None, *, device=None, noise=None):
75
+ """Exactly one evaluation at (t,r)=(1,0), then map back to [0,1]."""
76
+ was_training = model.training
77
+ model.eval()
78
+ try:
79
+ if device is None:
80
+ device = next(model.parameters()).device
81
+ if labels is not None:
82
+ labels = labels.to(device)
83
+ n_samples = len(labels)
84
+ if self.num_classes is not None and labels is None:
85
+ raise ValueError("Class-conditioned sampling requires labels")
86
+ if self.num_classes is None:
87
+ labels = None
88
+ if noise is None:
89
+ if n_samples is None or n_samples <= 0:
90
+ raise ValueError("n_samples must be positive")
91
+ noise = torch.randn(n_samples, self.channels, self.image_size,
92
+ self.image_size, device=device)
93
+ else:
94
+ noise = noise.to(device)
95
+ t = torch.ones(noise.shape[0], device=device)
96
+ u = model(noise, t, torch.zeros_like(t), y=labels,
97
+ use_flash_attention=True)
98
+ return ((noise - u).clamp(-1, 1) + 1) * 0.5
99
+ finally:
100
+ model.train(was_training)
training_config.json ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "multitrace_unet_cifar10_15m",
3
+ "architecture": "ConditionalMultiTraceUNet",
4
+ "objective": "multi_trace_imf",
5
+ "seed": 42,
6
+ "dataset": "cifar10",
7
+ "data_root": "/mnt/imf-training/data/cifar10",
8
+ "image_size": 32,
9
+ "num_workers": 2,
10
+ "lr": 0.0001,
11
+ "min_lr_ratio": 0.1,
12
+ "betas": [
13
+ 0.9,
14
+ 0.99
15
+ ],
16
+ "weight_decay": 0.0,
17
+ "grad_clip": 1.0,
18
+ "mixed_precision": "bf16",
19
+ "channels_last": true,
20
+ "allow_tf32": true,
21
+ "fused_optimizer": true,
22
+ "preload_gpu": true,
23
+ "log_step": 50,
24
+ "sample_step": 1000,
25
+ "checkpoint_step": 1000,
26
+ "keep_last_checkpoints": 3,
27
+ "sample_nrow": 10,
28
+ "parameter_target": 15000000,
29
+ "parameter_tolerance": 0.01,
30
+ "model": {
31
+ "input_size": 32,
32
+ "in_channels": 3,
33
+ "num_classes": 10,
34
+ "base_channels": 69,
35
+ "channel_mult": [
36
+ 1,
37
+ 2,
38
+ 2,
39
+ 4
40
+ ],
41
+ "num_res_blocks": 1,
42
+ "cond_dim": 312,
43
+ "fourier_dim": 64,
44
+ "attn_resolutions": [
45
+ 8
46
+ ]
47
+ },
48
+ "multi_trace_imf": {
49
+ "lambda_diag": 1.0,
50
+ "max_nfe": 5,
51
+ "jvp_precision": "bf16",
52
+ "channels_last": true
53
+ },
54
+ "monitoring": {
55
+ "enabled": true,
56
+ "tensorboard": true,
57
+ "save_best": true,
58
+ "validate_raw": true,
59
+ "plot_every": 500,
60
+ "validation_every": 1000,
61
+ "validation_batches": 5,
62
+ "sample_n_per_class": 2
63
+ },
64
+ "evaluation": {
65
+ "num_generated": 10000,
66
+ "batch_size": 128,
67
+ "nfes": [
68
+ 1,
69
+ 2,
70
+ 3,
71
+ 4,
72
+ 5
73
+ ],
74
+ "seed": 2026
75
+ },
76
+ "batch_size": 1024,
77
+ "gradient_accumulation_steps": 1,
78
+ "n_steps": 50000,
79
+ "warmup_steps": 2500,
80
+ "ema_decay": 0.9998000100000001,
81
+ "source_manifest": {
82
+ "repo_url": "https://github.com/namdeptraivcd/IMF.git",
83
+ "git_commit": "59d5164a2b20753b846568264ebb10c3e49beace",
84
+ "files": {
85
+ "train.py": "34f72a2bbba5341aeda9cd3fe021e18ed6bf1bbc73b823187a97ed83e03cc3aa",
86
+ "monitoring.py": "5315ee70585789a684162fbd4fa3a8f2479d5186d282d22a3fc314432b3100a9",
87
+ "hub.py": "ca23b68ef728ea2ae514918a09bb678d80df303fc97949593f2c6607cdc0fa03",
88
+ "sample.py": "90f1089547475b5ab1d8f5f8d160a33c639826eda95c6ca79ee2d3f527b24be1",
89
+ "models/dit.py": "843080c2702d596dd3b16e35b78501b168ca008d013d4394ee9c64c086361819",
90
+ "models/__init__.py": "1d9d5ec9cc26f0e76e570735a42e420314fdccc0a4aa113ddac642fd4d147c36",
91
+ "trace_imf.py": "43e2e8105541257376f648f3ee82a92cce8402530be59372f8d7ed0516501263",
92
+ "data.py": "a346a102fac83a40823501b68cf8055ac385ab3837cb6ef62b9212bdc7b9dffc",
93
+ "configs/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
94
+ "configs/cifar10_22m.py": "1599fb09bab2ac556f46f434f82d22d61aa22901140679b4bfef62aa65245588",
95
+ "requirements-notebook.txt": "858b7587f8c9b4778b2f13955ce8a00ff1f9a8f1cbfabb0ce94c2e97c55cc5fc",
96
+ "models/unet.py": "57baed6e4ef61ca23aa0ddf62ec0c30b85e6d27f2504416269bb6d1245ee22df",
97
+ "multi_trace_imf.py": "a807809500be68da9d33f13fd528d987e61471161ad869f97c7411bb225fe5b8",
98
+ "objectives.py": "691d152ee1f0970fa9c279c596d09070c5a5c6618ac465bb462fac0188796f7d",
99
+ "ema.py": "1bc020387ec0020724d0a5c066180100f08204102fd79e804c3624203ebc4579",
100
+ "evaluation.py": "6f2d19263ea1b8c13c9fdc4678062adae99ea0773e0f03c8001f81a598f03238",
101
+ "configs/multitrace_cifar10_22m.py": "e0a8fc408170b618d88d19ccf71993af5f469e59c36c31dd38d920b57ee727bb",
102
+ "configs/multitrace_cifar10_15m.py": "96863dc436dce0accb6a2722b4398aa1a8a6ebf4e96386511767fe9b3c2db69d"
103
+ }
104
+ }
105
+ }
training_log.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
training_metrics.json ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "step": 50000,
3
+ "lr": 1.0000000098422651e-05,
4
+ "window_steps": 50,
5
+ "elapsed_seconds": 5178.840372322999,
6
+ "steps_per_second": 1.7378407815190096,
7
+ "eta_seconds": 0.0,
8
+ "images_seen": 51200000,
9
+ "images_per_second": 1779.5489602754658,
10
+ "effective_batch_size": 1024,
11
+ "loss": 0.3548988401889801,
12
+ "edge_loss": 0.18379321694374084,
13
+ "diag_loss": 0.17110557854175568,
14
+ "jvp_rms": 1.8925390243530273,
15
+ "grad_norm": 0.21770034730434418,
16
+ "grad_norm_postclip": 0.21770034730434418,
17
+ "clip_fraction": 0.0,
18
+ "ema_updates": 50000,
19
+ "ema_decay": 0.9998000100000001,
20
+ "loss_nfe_3": 0.35597619265317915,
21
+ "updates_nfe_3": 10,
22
+ "loss_nfe_4": 0.37776655620998806,
23
+ "updates_nfe_4": 9,
24
+ "loss_nfe_5": 0.3045877367258072,
25
+ "updates_nfe_5": 8,
26
+ "loss_nfe_2": 0.3413205325603485,
27
+ "updates_nfe_2": 15,
28
+ "loss_nfe_1": 0.403596218675375,
29
+ "updates_nfe_1": 8,
30
+ "gpu_allocated_gb": 0.8975429534912109,
31
+ "gpu_reserved_gb": 43.775390625,
32
+ "gpu_peak_allocated_gb": 37.954071044921875,
33
+ "gradient_groups": {
34
+ "t_emb": {
35
+ "weight_norm": 16.515023530024582,
36
+ "grad_norm": 0.11432138125518912,
37
+ "grad_rms": 0.00033289269578588913,
38
+ "grad_to_weight": 0.00692226572050297,
39
+ "update_to_weight": 5.734569434715802e-05,
40
+ "missing_grad_tensors": 0,
41
+ "zero_grad_tensors": 0
42
+ },
43
+ "r_emb": {
44
+ "weight_norm": 16.262888330958752,
45
+ "grad_norm": 0.039618767773493664,
46
+ "grad_rms": 0.00011536598196266779,
47
+ "grad_to_weight": 0.002436145841207901,
48
+ "update_to_weight": 4.733992422527738e-05,
49
+ "missing_grad_tensors": 0,
50
+ "zero_grad_tensors": 0
51
+ },
52
+ "y_emb": {
53
+ "weight_norm": 5.067645060453645,
54
+ "grad_norm": 0.0034476322407670404,
55
+ "grad_rms": 6.172251819577942e-05,
56
+ "grad_to_weight": 0.000680322358736469,
57
+ "update_to_weight": 2.5612938476024494e-05,
58
+ "missing_grad_tensors": 0,
59
+ "zero_grad_tensors": 0
60
+ },
61
+ "cond_out": {
62
+ "weight_norm": 12.87244278780043,
63
+ "grad_norm": 0.03697475371479452,
64
+ "grad_rms": 0.00011831936333622446,
65
+ "grad_to_weight": 0.002872396042019042,
66
+ "update_to_weight": 6.601609987986573e-05,
67
+ "missing_grad_tensors": 0,
68
+ "zero_grad_tensors": 0
69
+ },
70
+ "in_conv": {
71
+ "weight_norm": 5.039121547619157,
72
+ "grad_norm": 0.02010702286093248,
73
+ "grad_rms": 0.000457450609587797,
74
+ "grad_to_weight": 0.0039901841364458615,
75
+ "update_to_weight": 3.290046528251253e-05,
76
+ "missing_grad_tensors": 0,
77
+ "zero_grad_tensors": 0
78
+ },
79
+ "down_levels.0": {
80
+ "weight_norm": 16.64608276842342,
81
+ "grad_norm": 0.09815406752986451,
82
+ "grad_rms": 0.0002365165120239306,
83
+ "grad_to_weight": 0.0058965264618326095,
84
+ "update_to_weight": 8.954140929857495e-05,
85
+ "missing_grad_tensors": 0,
86
+ "zero_grad_tensors": 0
87
+ },
88
+ "down_levels.1": {
89
+ "weight_norm": 24.577499197373093,
90
+ "grad_norm": 0.01800084380436817,
91
+ "grad_rms": 2.4834869479276555e-05,
92
+ "grad_to_weight": 0.0007324115305552383,
93
+ "update_to_weight": 9.463347569559213e-05,
94
+ "missing_grad_tensors": 0,
95
+ "zero_grad_tensors": 0
96
+ },
97
+ "down_levels.2": {
98
+ "weight_norm": 30.83386603917639,
99
+ "grad_norm": 0.008038267314234277,
100
+ "grad_rms": 9.758269257084616e-06,
101
+ "grad_to_weight": 0.0002606960575109572,
102
+ "update_to_weight": 6.642526625302697e-05,
103
+ "missing_grad_tensors": 0,
104
+ "zero_grad_tensors": 0
105
+ },
106
+ "down_levels.3": {
107
+ "weight_norm": 34.63907268454675,
108
+ "grad_norm": 0.003863454481162671,
109
+ "grad_rms": 3.468231732491786e-06,
110
+ "grad_to_weight": 0.00011153458166581472,
111
+ "update_to_weight": 7.572530100937947e-05,
112
+ "missing_grad_tensors": 0,
113
+ "zero_grad_tensors": 0
114
+ },
115
+ "mid1": {
116
+ "weight_norm": 37.09438513040922,
117
+ "grad_norm": 0.0032076774317542586,
118
+ "grad_rms": 2.580133241292384e-06,
119
+ "grad_to_weight": 8.647339537984874e-05,
120
+ "update_to_weight": 7.81818486024589e-05,
121
+ "missing_grad_tensors": 0,
122
+ "zero_grad_tensors": 0
123
+ },
124
+ "mid_attn": {
125
+ "weight_norm": 24.673390202443425,
126
+ "grad_norm": 0.0011791270861310043,
127
+ "grad_rms": 2.1303187281934394e-06,
128
+ "grad_to_weight": 4.778942319869097e-05,
129
+ "update_to_weight": 5.262799180821532e-05,
130
+ "missing_grad_tensors": 0,
131
+ "zero_grad_tensors": 0
132
+ },
133
+ "mid2": {
134
+ "weight_norm": 37.37197710653749,
135
+ "grad_norm": 0.003229066174170447,
136
+ "grad_rms": 2.597337528965184e-06,
137
+ "grad_to_weight": 8.640340769141662e-05,
138
+ "update_to_weight": 7.984646921565486e-05,
139
+ "missing_grad_tensors": 0,
140
+ "zero_grad_tensors": 0
141
+ },
142
+ "up_levels.0": {
143
+ "weight_norm": 63.52169789540913,
144
+ "grad_norm": 0.008797741452653435,
145
+ "grad_rms": 3.905892380033334e-06,
146
+ "grad_to_weight": 0.0001384997842334008,
147
+ "update_to_weight": 9.197308783625432e-05,
148
+ "missing_grad_tensors": 0,
149
+ "zero_grad_tensors": 0
150
+ },
151
+ "up_levels.1": {
152
+ "weight_norm": 50.788316815976486,
153
+ "grad_norm": 0.022728171192384107,
154
+ "grad_rms": 1.695910240002863e-05,
155
+ "grad_to_weight": 0.00044750786435266354,
156
+ "update_to_weight": 8.085612339796532e-05,
157
+ "missing_grad_tensors": 0,
158
+ "zero_grad_tensors": 0
159
+ },
160
+ "up_levels.2": {
161
+ "weight_norm": 40.116334734120464,
162
+ "grad_norm": 0.038615167286647545,
163
+ "grad_rms": 3.316118164288409e-05,
164
+ "grad_to_weight": 0.0009625796459865482,
165
+ "update_to_weight": 9.42659917428506e-05,
166
+ "missing_grad_tensors": 0,
167
+ "zero_grad_tensors": 0
168
+ },
169
+ "up_levels.3": {
170
+ "weight_norm": 28.206099436294913,
171
+ "grad_norm": 0.10106223952213236,
172
+ "grad_rms": 0.00015754171001242578,
173
+ "grad_to_weight": 0.0035829923861109263,
174
+ "update_to_weight": 8.058384138680281e-05,
175
+ "missing_grad_tensors": 0,
176
+ "zero_grad_tensors": 0
177
+ },
178
+ "out_norm": {
179
+ "weight_norm": 8.418451806035767,
180
+ "grad_norm": 0.00825520231395145,
181
+ "grad_rms": 0.0007027294882485905,
182
+ "grad_to_weight": 0.0009806081336752117,
183
+ "update_to_weight": 5.2765190801682055e-06,
184
+ "missing_grad_tensors": 0,
185
+ "zero_grad_tensors": 0
186
+ },
187
+ "u_head": {
188
+ "weight_norm": 1.3251545617986,
189
+ "grad_norm": 0.10927559814558875,
190
+ "grad_rms": 0.002529690400215243,
191
+ "grad_to_weight": 0.08246253025554366,
192
+ "update_to_weight": 0.00010683296531524654,
193
+ "missing_grad_tensors": 0,
194
+ "zero_grad_tensors": 0
195
+ }
196
+ },
197
+ "gradient_snapshot_step": 50000
198
+ }
validation.jsonl ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {"step": 41000, "weights_source": "ema", "loss": 0.3725855791568756, "edge_loss": 0.19200483143329622, "diag_loss": 0.18058074414730071, "jvp_rms": 2.078083175420761, "examples": 5120, "loss_nfe_1": 0.3927511692047119, "edge_loss_nfe_1": 0.2175933986902237, "diag_loss_nfe_1": 0.17515776455402374, "jvp_rms_nfe_1": 2.4403680324554444, "loss_nfe_2": 0.369793975353241, "edge_loss_nfe_2": 0.18860338628292084, "diag_loss_nfe_2": 0.1811905950307846, "jvp_rms_nfe_2": 2.2941908717155455, "loss_nfe_3": 0.3564019322395325, "edge_loss_nfe_3": 0.17990776002407075, "diag_loss_nfe_3": 0.17649417072534562, "jvp_rms_nfe_3": 1.885271716117859, "loss_nfe_4": 0.3897887945175171, "edge_loss_nfe_4": 0.19601401388645173, "diag_loss_nfe_4": 0.1937747687101364, "jvp_rms_nfe_4": 2.270489048957825, "loss_nfe_5": 0.3541920244693756, "edge_loss_nfe_5": 0.17790559828281402, "diag_loss_nfe_5": 0.17628642171621323, "jvp_rms_nfe_5": 1.500096207857132, "raw_loss": 0.379677836894989, "raw_edge_loss": 0.19833322674036027, "raw_diag_loss": 0.1813446119427681, "raw_jvp_rms": 2.2722322368621826, "raw_loss_nfe_1": 0.4198586106300354, "raw_edge_loss_nfe_1": 0.24385497570037842, "raw_diag_loss_nfe_1": 0.17600363194942475, "raw_jvp_rms_nfe_1": 2.645507574081421, "raw_loss_nfe_2": 0.37339203953742983, "raw_edge_loss_nfe_2": 0.19148991107940674, "raw_diag_loss_nfe_2": 0.18190212845802306, "raw_jvp_rms_nfe_2": 2.5214332699775697, "raw_loss_nfe_3": 0.35822181701660155, "raw_edge_loss_nfe_3": 0.18091285228729248, "raw_diag_loss_nfe_3": 0.1773089662194252, "raw_jvp_rms_nfe_3": 2.062240254878998, "raw_loss_nfe_4": 0.3911686480045319, "raw_edge_loss_nfe_4": 0.19675154983997345, "raw_diag_loss_nfe_4": 0.1944171041250229, "raw_jvp_rms_nfe_4": 2.484368699789047, "raw_loss_nfe_5": 0.35574806928634645, "raw_edge_loss_nfe_5": 0.17865684479475022, "raw_diag_loss_nfe_5": 0.17709122896194457, "raw_jvp_rms_nfe_5": 1.6476113855838777}
2
+ {"step": 42000, "weights_source": "ema", "loss": 0.3723788583278656, "edge_loss": 0.19195123821496965, "diag_loss": 0.18042762011289598, "jvp_rms": 2.0993320310115813, "examples": 5120, "loss_nfe_1": 0.3929444789886475, "edge_loss_nfe_1": 0.21792266964912416, "diag_loss_nfe_1": 0.17502180635929107, "jvp_rms_nfe_1": 2.471006441116333, "loss_nfe_2": 0.36948872208595274, "edge_loss_nfe_2": 0.18845009803771973, "diag_loss_nfe_2": 0.18103862702846527, "jvp_rms_nfe_2": 2.3163293421268465, "loss_nfe_3": 0.35611130595207213, "edge_loss_nfe_3": 0.1797650545835495, "diag_loss_nfe_3": 0.17634625285863875, "jvp_rms_nfe_3": 1.9045085847377776, "loss_nfe_4": 0.3894401788711548, "edge_loss_nfe_4": 0.19585056602954865, "diag_loss_nfe_4": 0.19358961880207062, "jvp_rms_nfe_4": 2.2923266768455504, "loss_nfe_5": 0.3539096057415009, "edge_loss_nfe_5": 0.17776780277490617, "diag_loss_nfe_5": 0.1761417955160141, "jvp_rms_nfe_5": 1.5124891102313995, "raw_loss": 0.37814890921115873, "raw_edge_loss": 0.19729300439357758, "raw_diag_loss": 0.1808559051156044, "raw_jvp_rms": 2.621889500617981, "raw_loss_nfe_1": 0.4127004086971283, "raw_edge_loss_nfe_1": 0.23728247880935668, "raw_diag_loss_nfe_1": 0.17541792690753938, "raw_jvp_rms_nfe_1": 3.186359691619873, "raw_loss_nfe_2": 0.37278689742088317, "raw_edge_loss_nfe_2": 0.19128688871860505, "raw_diag_loss_nfe_2": 0.18150001168251037, "raw_jvp_rms_nfe_2": 2.9029066443443297, "raw_loss_nfe_3": 0.3582378625869751, "raw_edge_loss_nfe_3": 0.18145101070404052, "raw_diag_loss_nfe_3": 0.1767868474125862, "raw_jvp_rms_nfe_3": 2.349283879995346, "raw_loss_nfe_4": 0.3917541980743408, "raw_edge_loss_nfe_4": 0.19763608276844025, "raw_diag_loss_nfe_4": 0.1941181242465973, "raw_jvp_rms_nfe_4": 2.840165650844574, "raw_loss_nfe_5": 0.3552651792764664, "raw_edge_loss_nfe_5": 0.17880856096744538, "raw_diag_loss_nfe_5": 0.17645661532878876, "raw_jvp_rms_nfe_5": 1.830731636285782}
3
+ {"step": 43000, "weights_source": "ema", "loss": 0.37205516755580903, "edge_loss": 0.1917748808860779, "diag_loss": 0.18028028905391694, "jvp_rms": 2.125342252254486, "examples": 5120, "loss_nfe_1": 0.3925249338150024, "edge_loss_nfe_1": 0.21763605773448944, "diag_loss_nfe_1": 0.17488887906074524, "jvp_rms_nfe_1": 2.5001804351806642, "loss_nfe_2": 0.3691649556159973, "edge_loss_nfe_2": 0.1882774442434311, "diag_loss_nfe_2": 0.18088751137256623, "jvp_rms_nfe_2": 2.3510846734046935, "loss_nfe_3": 0.35585449934005736, "edge_loss_nfe_3": 0.17965261936187743, "diag_loss_nfe_3": 0.1762018769979477, "jvp_rms_nfe_3": 1.92358438372612, "loss_nfe_4": 0.3890950262546539, "edge_loss_nfe_4": 0.19568087458610534, "diag_loss_nfe_4": 0.1934141606092453, "jvp_rms_nfe_4": 2.3233995378017425, "loss_nfe_5": 0.35363642275333407, "edge_loss_nfe_5": 0.17762740850448608, "diag_loss_nfe_5": 0.1760090172290802, "jvp_rms_nfe_5": 1.5284622311592102, "raw_loss": 0.37374089658260345, "raw_edge_loss": 0.1935477900505066, "raw_diag_loss": 0.1801931056380272, "raw_jvp_rms": 2.299976586103439, "raw_loss_nfe_1": 0.39992823004722594, "raw_edge_loss_nfe_1": 0.2250307857990265, "raw_diag_loss_nfe_1": 0.17489744424819947, "raw_jvp_rms_nfe_1": 2.7114959239959715, "raw_loss_nfe_2": 0.36982461214065554, "raw_edge_loss_nfe_2": 0.18907322287559508, "raw_diag_loss_nfe_2": 0.18075139224529266, "raw_jvp_rms_nfe_2": 2.5491456270217894, "raw_loss_nfe_3": 0.3560143828392029, "raw_edge_loss_nfe_3": 0.17990127801895142, "raw_diag_loss_nfe_3": 0.17611309438943862, "raw_jvp_rms_nfe_3": 2.0785558223724365, "raw_loss_nfe_4": 0.3891355276107788, "raw_edge_loss_nfe_4": 0.19592745006084442, "raw_diag_loss_nfe_4": 0.19320808351039886, "raw_jvp_rms_nfe_4": 2.514833205938339, "raw_loss_nfe_5": 0.3538017302751541, "raw_edge_loss_nfe_5": 0.17780621349811554, "raw_diag_loss_nfe_5": 0.17599551379680634, "raw_jvp_rms_nfe_5": 1.6458523511886596}
4
+ {"step": 44000, "weights_source": "ema", "loss": 0.3718108052015304, "edge_loss": 0.19166429877281188, "diag_loss": 0.1801465055346489, "jvp_rms": 2.1521597826480865, "examples": 5120, "loss_nfe_1": 0.3922906398773193, "edge_loss_nfe_1": 0.2175253540277481, "diag_loss_nfe_1": 0.17476528584957124, "jvp_rms_nfe_1": 2.536211538314819, "loss_nfe_2": 0.3689300060272217, "edge_loss_nfe_2": 0.18817995488643646, "diag_loss_nfe_2": 0.18075005412101747, "jvp_rms_nfe_2": 2.3827747225761415, "loss_nfe_3": 0.35562258362770083, "edge_loss_nfe_3": 0.17955487966537476, "diag_loss_nfe_3": 0.17606770247220993, "jvp_rms_nfe_3": 1.947074192762375, "loss_nfe_4": 0.38880528807640075, "edge_loss_nfe_4": 0.19554311633110047, "diag_loss_nfe_4": 0.19326217472553253, "jvp_rms_nfe_4": 2.3517152607440948, "loss_nfe_5": 0.3534055083990097, "edge_loss_nfe_5": 0.17751818895339966, "diag_loss_nfe_5": 0.17588731050491332, "jvp_rms_nfe_5": 1.5430231988430023, "raw_loss": 0.37199350357055666, "raw_edge_loss": 0.19197442293167116, "raw_diag_loss": 0.18001908123493196, "raw_jvp_rms": 2.215284506082535, "raw_loss_nfe_1": 0.3944181323051453, "raw_edge_loss_nfe_1": 0.2197323888540268, "raw_diag_loss_nfe_1": 0.1746857464313507, "raw_jvp_rms_nfe_1": 2.620998001098633, "raw_loss_nfe_2": 0.3687027633190155, "raw_edge_loss_nfe_2": 0.18810227811336516, "raw_diag_loss_nfe_2": 0.18060048818588256, "raw_jvp_rms_nfe_2": 2.459484040737152, "raw_loss_nfe_3": 0.35545286536216736, "raw_edge_loss_nfe_3": 0.17949930727481841, "raw_diag_loss_nfe_3": 0.17595355361700057, "raw_jvp_rms_nfe_3": 2.002295124530792, "raw_loss_nfe_4": 0.38823755383491515, "raw_edge_loss_nfe_4": 0.19519887268543243, "raw_diag_loss_nfe_4": 0.1930386781692505, "raw_jvp_rms_nfe_4": 2.4217930257320406, "raw_loss_nfe_5": 0.35315620303153994, "raw_edge_loss_nfe_5": 0.1773392677307129, "raw_diag_loss_nfe_5": 0.17581693977117538, "raw_jvp_rms_nfe_5": 1.5718523383140564}
5
+ {"step": 45000, "weights_source": "ema", "loss": 0.37168434262275696, "edge_loss": 0.19165305346250533, "diag_loss": 0.18003128856420517, "jvp_rms": 2.1736205995082853, "examples": 5120, "loss_nfe_1": 0.3925355851650238, "edge_loss_nfe_1": 0.21787453591823577, "diag_loss_nfe_1": 0.17466104328632354, "jvp_rms_nfe_1": 2.5622494220733643, "loss_nfe_2": 0.3687441825866699, "edge_loss_nfe_2": 0.18811105489730834, "diag_loss_nfe_2": 0.18063313663005828, "jvp_rms_nfe_2": 2.406940096616745, "loss_nfe_3": 0.35541791915893556, "edge_loss_nfe_3": 0.1794615715742111, "diag_loss_nfe_3": 0.17595634311437608, "jvp_rms_nfe_3": 1.9702612817287446, "loss_nfe_4": 0.3885439932346344, "edge_loss_nfe_4": 0.19541764855384827, "diag_loss_nfe_4": 0.1931263417005539, "jvp_rms_nfe_4": 2.373984634876251, "loss_nfe_5": 0.35318003296852113, "edge_loss_nfe_5": 0.17740045636892318, "diag_loss_nfe_5": 0.17577957808971406, "jvp_rms_nfe_5": 1.5546675622463226, "raw_loss": 0.3740403318405151, "raw_edge_loss": 0.1942245441675186, "raw_diag_loss": 0.17981578558683395, "raw_jvp_rms": 2.3283275413513183, "raw_loss_nfe_1": 0.4041799962520599, "raw_edge_loss_nfe_1": 0.2296959787607193, "raw_diag_loss_nfe_1": 0.1744840145111084, "raw_jvp_rms_nfe_1": 2.760013055801392, "raw_loss_nfe_2": 0.36933073997497556, "raw_edge_loss_nfe_2": 0.18892420828342438, "raw_diag_loss_nfe_2": 0.18040653467178344, "raw_jvp_rms_nfe_2": 2.587478423118591, "raw_loss_nfe_3": 0.3554180383682251, "raw_edge_loss_nfe_3": 0.17966652810573577, "raw_diag_loss_nfe_3": 0.1757515013217926, "raw_jvp_rms_nfe_3": 2.1034037828445435, "raw_loss_nfe_4": 0.38829761147499087, "raw_edge_loss_nfe_4": 0.1954770267009735, "raw_diag_loss_nfe_4": 0.19282058477401734, "raw_jvp_rms_nfe_4": 2.5383615255355836, "raw_loss_nfe_5": 0.35297527313232424, "raw_edge_loss_nfe_5": 0.1773589789867401, "raw_diag_loss_nfe_5": 0.175616292655468, "raw_jvp_rms_nfe_5": 1.652380919456482}
6
+ {"step": 46000, "weights_source": "ema", "loss": 0.3715553200244904, "edge_loss": 0.19162928521633146, "diag_loss": 0.1799260401725769, "jvp_rms": 2.201610367298126, "examples": 5120, "loss_nfe_1": 0.3926394283771515, "edge_loss_nfe_1": 0.2180699735879898, "diag_loss_nfe_1": 0.17456946074962615, "jvp_rms_nfe_1": 2.6001721382141114, "loss_nfe_2": 0.3686067283153534, "edge_loss_nfe_2": 0.18808059692382811, "diag_loss_nfe_2": 0.18052614033222197, "jvp_rms_nfe_2": 2.439925366640091, "loss_nfe_3": 0.35523309707641604, "edge_loss_nfe_3": 0.1793862372636795, "diag_loss_nfe_3": 0.17584685534238814, "jvp_rms_nfe_3": 1.992531567811966, "loss_nfe_4": 0.38829939961433413, "edge_loss_nfe_4": 0.19529785215854645, "diag_loss_nfe_4": 0.19300155341625214, "jvp_rms_nfe_4": 2.4034175872802734, "loss_nfe_5": 0.35299794673919677, "edge_loss_nfe_5": 0.17731176614761351, "diag_loss_nfe_5": 0.17568619102239608, "jvp_rms_nfe_5": 1.5720051765441894, "raw_loss": 0.37294554710388184, "raw_edge_loss": 0.19305831611156463, "raw_diag_loss": 0.17988722890615463, "raw_jvp_rms": 2.5546124279499054, "raw_loss_nfe_1": 0.39817399382591245, "raw_edge_loss_nfe_1": 0.2236364871263504, "raw_diag_loss_nfe_1": 0.17453750371932983, "raw_jvp_rms_nfe_1": 3.0601311683654786, "raw_loss_nfe_2": 0.36934937834739684, "raw_edge_loss_nfe_2": 0.18887795507907867, "raw_diag_loss_nfe_2": 0.1804714173078537, "raw_jvp_rms_nfe_2": 2.8419912278652193, "raw_loss_nfe_3": 0.35562482476234436, "raw_edge_loss_nfe_3": 0.17977170050144195, "raw_diag_loss_nfe_3": 0.17585312575101852, "raw_jvp_rms_nfe_3": 2.303293800354004, "raw_loss_nfe_4": 0.3885082483291626, "raw_edge_loss_nfe_4": 0.19556552171707153, "raw_diag_loss_nfe_4": 0.1929427295923233, "raw_jvp_rms_nfe_4": 2.7833980321884155, "raw_loss_nfe_5": 0.3530712902545929, "raw_edge_loss_nfe_5": 0.1774399161338806, "raw_diag_loss_nfe_5": 0.1756313681602478, "raw_jvp_rms_nfe_5": 1.78424791097641}
7
+ {"step": 47000, "weights_source": "ema", "loss": 0.3713958901166916, "edge_loss": 0.1915695336461067, "diag_loss": 0.1798263558745384, "jvp_rms": 2.2319657707214353, "examples": 5120, "loss_nfe_1": 0.3926237761974335, "edge_loss_nfe_1": 0.2181445300579071, "diag_loss_nfe_1": 0.1744792491197586, "jvp_rms_nfe_1": 2.642152261734009, "loss_nfe_2": 0.36840869188308717, "edge_loss_nfe_2": 0.18798398077487946, "diag_loss_nfe_2": 0.18042470812797545, "jvp_rms_nfe_2": 2.475356990098953, "loss_nfe_3": 0.3550576686859131, "edge_loss_nfe_3": 0.17930547297000884, "diag_loss_nfe_3": 0.175752192735672, "jvp_rms_nfe_3": 2.0165530383586883, "loss_nfe_4": 0.3880728900432587, "edge_loss_nfe_4": 0.19519352316856384, "diag_loss_nfe_4": 0.19287936985492707, "jvp_rms_nfe_4": 2.435269385576248, "loss_nfe_5": 0.35281642377376554, "edge_loss_nfe_5": 0.17722016125917434, "diag_loss_nfe_5": 0.17559625953435898, "jvp_rms_nfe_5": 1.5904971778392791, "raw_loss": 0.3728845959901809, "raw_edge_loss": 0.19330160319805145, "raw_diag_loss": 0.17958299428224564, "raw_jvp_rms": 2.488507117033005, "raw_loss_nfe_1": 0.4004963099956512, "raw_edge_loss_nfe_1": 0.226207235455513, "raw_diag_loss_nfe_1": 0.1742890805006027, "raw_jvp_rms_nfe_1": 2.9745230674743652, "raw_loss_nfe_2": 0.36872340440750123, "raw_edge_loss_nfe_2": 0.18855189383029938, "raw_diag_loss_nfe_2": 0.18017151057720185, "raw_jvp_rms_nfe_2": 2.7699862122535706, "raw_loss_nfe_3": 0.3549445480108261, "raw_edge_loss_nfe_3": 0.17942589223384858, "raw_diag_loss_nfe_3": 0.17551865577697753, "raw_jvp_rms_nfe_3": 2.246046853065491, "raw_loss_nfe_4": 0.3877571880817413, "raw_edge_loss_nfe_4": 0.19519511461257935, "raw_diag_loss_nfe_4": 0.192562073469162, "raw_jvp_rms_nfe_4": 2.705729341506958, "raw_loss_nfe_5": 0.3525015294551849, "raw_edge_loss_nfe_5": 0.17712787985801698, "raw_diag_loss_nfe_5": 0.1753736510872841, "raw_jvp_rms_nfe_5": 1.7462501108646393}
8
+ {"step": 48000, "weights_source": "ema", "loss": 0.3712373948097229, "edge_loss": 0.19149310767650604, "diag_loss": 0.17974428683519364, "jvp_rms": 2.250151746273041, "examples": 5120, "loss_nfe_1": 0.39254979491233827, "edge_loss_nfe_1": 0.21814591586589813, "diag_loss_nfe_1": 0.17440388202667237, "jvp_rms_nfe_1": 2.665694570541382, "loss_nfe_2": 0.3681997716426849, "edge_loss_nfe_2": 0.18785875737667085, "diag_loss_nfe_2": 0.1803410142660141, "jvp_rms_nfe_2": 2.495949363708496, "loss_nfe_3": 0.3549005001783371, "edge_loss_nfe_3": 0.17922913730144502, "diag_loss_nfe_3": 0.17567135840654374, "jvp_rms_nfe_3": 2.0347792744636535, "loss_nfe_4": 0.3878713846206665, "edge_loss_nfe_4": 0.19508881270885467, "diag_loss_nfe_4": 0.19278257191181183, "jvp_rms_nfe_4": 2.4547479271888735, "loss_nfe_5": 0.35266552269458773, "edge_loss_nfe_5": 0.17714291512966157, "diag_loss_nfe_5": 0.17552260756492616, "jvp_rms_nfe_5": 1.5995875954627992, "raw_loss": 0.37239629626274107, "raw_edge_loss": 0.19247002869844437, "raw_diag_loss": 0.17992626249790195, "raw_jvp_rms": 2.1689469707012177, "raw_loss_nfe_1": 0.396082466840744, "raw_edge_loss_nfe_1": 0.2214716374874115, "raw_diag_loss_nfe_1": 0.17461082339286804, "raw_jvp_rms_nfe_1": 2.5685171604156496, "raw_loss_nfe_2": 0.36995372772216795, "raw_edge_loss_nfe_2": 0.18943111300468446, "raw_diag_loss_nfe_2": 0.1805226117372513, "raw_jvp_rms_nfe_2": 2.4097091972827913, "raw_loss_nfe_3": 0.35518380999565125, "raw_edge_loss_nfe_3": 0.17940330505371094, "raw_diag_loss_nfe_3": 0.17578050196170808, "raw_jvp_rms_nfe_3": 1.9646742224693299, "raw_loss_nfe_4": 0.3877831220626831, "raw_edge_loss_nfe_4": 0.19488065540790558, "raw_diag_loss_nfe_4": 0.19290245771408082, "raw_jvp_rms_nfe_4": 2.366553395986557, "raw_loss_nfe_5": 0.3529783546924591, "raw_edge_loss_nfe_5": 0.17716343253850936, "raw_diag_loss_nfe_5": 0.17581491768360138, "raw_jvp_rms_nfe_5": 1.5352808773517608}
9
+ {"step": 49000, "weights_source": "ema", "loss": 0.3710547721385956, "edge_loss": 0.19137788712978362, "diag_loss": 0.17967688530683518, "jvp_rms": 2.26550262093544, "examples": 5120, "loss_nfe_1": 0.39221864342689516, "edge_loss_nfe_1": 0.21786801517009735, "diag_loss_nfe_1": 0.17435062825679778, "jvp_rms_nfe_1": 2.686102199554443, "loss_nfe_2": 0.3680577754974365, "edge_loss_nfe_2": 0.1877869725227356, "diag_loss_nfe_2": 0.18027080297470094, "jvp_rms_nfe_2": 2.5132674276828766, "loss_nfe_3": 0.3547529995441437, "edge_loss_nfe_3": 0.17915709614753722, "diag_loss_nfe_3": 0.17559590488672255, "jvp_rms_nfe_3": 2.0510569334030153, "loss_nfe_4": 0.3877130031585693, "edge_loss_nfe_4": 0.19501143097877502, "diag_loss_nfe_4": 0.19270157516002656, "jvp_rms_nfe_4": 2.470135527849197, "loss_nfe_5": 0.3525314390659332, "edge_loss_nfe_5": 0.17706592082977296, "diag_loss_nfe_5": 0.17546551525592805, "jvp_rms_nfe_5": 1.606951016187668, "raw_loss": 0.3729947149753571, "raw_edge_loss": 0.19341899901628495, "raw_diag_loss": 0.17957571774721146, "raw_jvp_rms": 2.3479965436458587, "raw_loss_nfe_1": 0.4013635516166687, "raw_edge_loss_nfe_1": 0.22706393301486968, "raw_diag_loss_nfe_1": 0.17429961562156676, "raw_jvp_rms_nfe_1": 2.7829211711883546, "raw_loss_nfe_2": 0.3686074197292328, "raw_edge_loss_nfe_2": 0.18846496045589448, "raw_diag_loss_nfe_2": 0.18014245927333833, "raw_jvp_rms_nfe_2": 2.6206358075141907, "raw_loss_nfe_3": 0.35482444763183596, "raw_edge_loss_nfe_3": 0.17929541170597077, "raw_diag_loss_nfe_3": 0.17552904039621353, "raw_jvp_rms_nfe_3": 2.1178201019763945, "raw_loss_nfe_4": 0.3876810848712921, "raw_edge_loss_nfe_4": 0.19514916241168975, "raw_diag_loss_nfe_4": 0.19253192245960235, "raw_jvp_rms_nfe_4": 2.551815760135651, "raw_loss_nfe_5": 0.35249707102775574, "raw_edge_loss_nfe_5": 0.17712152749300003, "raw_diag_loss_nfe_5": 0.1753755509853363, "raw_jvp_rms_nfe_5": 1.6667898774147034}
10
+ {"step": 50000, "weights_source": "ema", "loss": 0.3709731566905975, "edge_loss": 0.19136443853378296, "diag_loss": 0.1796087145805359, "jvp_rms": 2.2817168676853177, "examples": 5120, "loss_nfe_1": 0.39239816665649413, "edge_loss_nfe_1": 0.21810964345932007, "diag_loss_nfe_1": 0.1742885172367096, "jvp_rms_nfe_1": 2.700194501876831, "loss_nfe_2": 0.3679115891456604, "edge_loss_nfe_2": 0.18770996630191802, "diag_loss_nfe_2": 0.18020162284374236, "jvp_rms_nfe_2": 2.536956226825714, "loss_nfe_3": 0.35463637113571167, "edge_loss_nfe_3": 0.1791027843952179, "diag_loss_nfe_3": 0.17553358674049377, "jvp_rms_nfe_3": 2.0643750607967375, "loss_nfe_4": 0.38753209710121156, "edge_loss_nfe_4": 0.19491184055805205, "diag_loss_nfe_4": 0.19262024462223054, "jvp_rms_nfe_4": 2.4871247947216033, "loss_nfe_5": 0.3523875594139099, "edge_loss_nfe_5": 0.17698795795440675, "diag_loss_nfe_5": 0.17539960145950317, "jvp_rms_nfe_5": 1.6199337542057037, "raw_loss": 0.37272677540779114, "raw_edge_loss": 0.19294691383838652, "raw_diag_loss": 0.17977986514568328, "raw_jvp_rms": 2.4338310968875883, "raw_loss_nfe_1": 0.39853897094726565, "raw_edge_loss_nfe_1": 0.2240687519311905, "raw_diag_loss_nfe_1": 0.1744702249765396, "raw_jvp_rms_nfe_1": 2.9251581192016602, "raw_loss_nfe_2": 0.3692192077636719, "raw_edge_loss_nfe_2": 0.18882804214954377, "raw_diag_loss_nfe_2": 0.18039117157459258, "raw_jvp_rms_nfe_2": 2.7281934142112734, "raw_loss_nfe_3": 0.35528815984725953, "raw_edge_loss_nfe_3": 0.1796249717473984, "raw_diag_loss_nfe_3": 0.17566319108009337, "raw_jvp_rms_nfe_3": 2.1835286557674407, "raw_loss_nfe_4": 0.3877676367759705, "raw_edge_loss_nfe_4": 0.19502896666526795, "raw_diag_loss_nfe_4": 0.1927386701107025, "raw_jvp_rms_nfe_4": 2.6403229236602783, "raw_loss_nfe_5": 0.3528199017047882, "raw_edge_loss_nfe_5": 0.1771838366985321, "raw_diag_loss_nfe_5": 0.17563606798648834, "raw_jvp_rms_nfe_5": 1.69195237159729}