jyliuAI commited on
Commit
6b56858
·
verified ·
1 Parent(s): 069761e

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. adapters/__init__.py +1 -0
  2. adapters/_distilled_runtime.py +586 -0
  3. adapters/base.py +3 -0
  4. adapters/candi.py +3 -0
  5. adapters/di4c.py +3 -0
  6. adapters/duo.py +3 -0
  7. adapters/flm.py +3 -0
  8. adapters/langflow.py +3 -0
  9. adapters/mdlm.py +3 -0
  10. adapters/rdlm.py +3 -0
  11. adapters/sample_di4c.py +153 -0
  12. adapters/sample_langflow.py +82 -0
  13. adapters/sample_sdtt.py +146 -0
  14. adapters/sdtt.py +3 -0
  15. adapters/train_di4c.py +179 -0
  16. adapters/train_duo_dcd.py +58 -0
  17. artifacts/data.yaml +33 -0
  18. checkpoints/official/flm/lm1b/model.safetensors +3 -0
  19. checkpoints/official/mdlm/owt/model.safetensors +3 -0
  20. data/conditional/lm1b-c64/prompts.jsonl +0 -0
  21. data/conditional/owt-c64/prompts.jsonl +0 -0
  22. data/elf/assets.json +171 -0
  23. data/elf/owt-prefix.jsonl +0 -0
  24. data/elf/owt-prefix.manifest.json +8 -0
  25. data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519/config.json +31 -0
  26. data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519/merges.txt +0 -0
  27. data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519/tokenizer.json +0 -0
  28. data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519/tokenizer_config.json +1 -0
  29. data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519/vocab.json +0 -0
  30. data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e/config.json +31 -0
  31. data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e/merges.txt +0 -0
  32. data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e/tokenizer.json +0 -0
  33. data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e/tokenizer_config.json +1 -0
  34. data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e/vocab.json +0 -0
  35. data/elf/snapshots/owt/146f84133c1389bfd4ef47f14ec7a955da22faa7/config.yml +42 -0
  36. data/elf/snapshots/t5/df1b051c49625cf57a3d0d8d3863ed4d13564fe4/config.json +51 -0
  37. data/elf/snapshots/t5/df1b051c49625cf57a3d0d8d3863ed4d13564fe4/tokenizer.json +0 -0
  38. data/elf/snapshots/t5/df1b051c49625cf57a3d0d8d3863ed4d13564fe4/tokenizer_config.json +111 -0
  39. data/elf/snapshots/wmt14-official-validation/bcc92bda4b07c329354843724c9d9ea740f30685/dataset_info.json +101 -0
  40. data/elf/snapshots/wmt14-official-validation/bcc92bda4b07c329354843724c9d9ea740f30685/state.json +13 -0
  41. data/elf/snapshots/wmt14/93ce98315a2dec985cdefb8d8e62ab618e896ec4/config.yml +45 -0
  42. data/elf/snapshots/xsum-official-validation/b0b4f5de92434d308eceeb9e38fd3f8d7d2b6a9e/dataset_info.json +88 -0
  43. data/elf/snapshots/xsum-official-validation/b0b4f5de92434d308eceeb9e38fd3f8d7d2b6a9e/state.json +13 -0
  44. data/elf/snapshots/xsum/aca4abd1c7ff5f841f0e2a3ec8a18b0a927927f1/config.yml +45 -0
  45. data/elf/wmt14-official-validation.jsonl +0 -0
  46. data/elf/wmt14-official-validation.manifest.json +17 -0
  47. data/elf/wmt14-test.jsonl +0 -0
  48. data/elf/wmt14-test.manifest.json +17 -0
  49. data/elf/wmt14-validation.jsonl +0 -0
  50. data/elf/wmt14-validation.manifest.json +17 -0
adapters/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """Compatibility imports for the Task 7 adapter paths."""
adapters/_distilled_runtime.py ADDED
@@ -0,0 +1,586 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Server-only runtime shared by the SDTT and Di4C sampling entrypoints."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from contextlib import contextmanager
6
+ import hashlib
7
+ import json
8
+ import os
9
+ from pathlib import Path
10
+ import random
11
+ import re
12
+ import sys
13
+ import tempfile
14
+ from collections.abc import Mapping
15
+
16
+ import yaml
17
+
18
+ from dlb.adapters.conditional_runtime import load_conditioning_batch, token_project_fn
19
+
20
+
21
+ class TokenizerBinding:
22
+ __slots__ = ("tokenizer_id", "revision", "snapshot")
23
+
24
+ def __init__(self, tokenizer_id: str, revision: str, snapshot: Path) -> None:
25
+ self.tokenizer_id = tokenizer_id
26
+ self.revision = revision
27
+ self.snapshot = snapshot
28
+
29
+
30
+ def require_file(path: Path, label: str) -> Path:
31
+ path = path.absolute()
32
+ if path.is_symlink() or not path.is_file() or path.stat().st_size <= 0:
33
+ raise ValueError(f"{label} is missing or unsafe: {path}")
34
+ return path
35
+
36
+
37
+ def require_directory(path: Path, label: str) -> Path:
38
+ path = path.absolute()
39
+ if path.is_symlink() or not path.is_dir():
40
+ raise ValueError(f"{label} is missing or unsafe: {path}")
41
+ return path
42
+
43
+
44
+ def sha256_file(path: Path) -> str:
45
+ digest = hashlib.sha256()
46
+ with require_file(path, "hashed file").open("rb") as handle:
47
+ for chunk in iter(lambda: handle.read(1024 * 1024), b""):
48
+ digest.update(chunk)
49
+ return digest.hexdigest()
50
+
51
+
52
+ def verify_sha256(path: Path, expected: str, label: str) -> Path:
53
+ path = require_file(path, label)
54
+ if (
55
+ len(expected) != 64
56
+ or any(character not in "0123456789abcdef" for character in expected)
57
+ or sha256_file(path) != expected
58
+ ):
59
+ raise ValueError(f"{label} SHA-256 differs from canonical provenance")
60
+ return path
61
+
62
+
63
+ def parse_bool(value: str) -> bool:
64
+ if value == "true":
65
+ return True
66
+ if value == "false":
67
+ return False
68
+ raise ValueError("boolean values must be 'true' or 'false'")
69
+
70
+
71
+ @contextmanager
72
+ def offline_huggingface(enabled: bool):
73
+ names = ("HF_HUB_OFFLINE", "TRANSFORMERS_OFFLINE")
74
+ previous = {name: os.environ.get(name) for name in names}
75
+ if enabled:
76
+ os.environ.update({name: "1" for name in names})
77
+ try:
78
+ yield
79
+ finally:
80
+ for name, value in previous.items():
81
+ if value is None:
82
+ os.environ.pop(name, None)
83
+ else:
84
+ os.environ[name] = value
85
+
86
+
87
+ def install_upstream(upstream_root: Path) -> None:
88
+ source = require_directory(upstream_root / "src", "upstream Python source")
89
+ source_text = str(source)
90
+ if source_text not in sys.path:
91
+ sys.path.insert(0, source_text)
92
+
93
+
94
+ def seed_everything(seed: int) -> None:
95
+ random.seed(seed)
96
+ try:
97
+ import numpy
98
+
99
+ numpy.random.seed(seed % (2**32))
100
+ except ImportError:
101
+ pass
102
+ import torch
103
+
104
+ torch.manual_seed(seed)
105
+ if torch.cuda.is_available():
106
+ torch.cuda.manual_seed_all(seed)
107
+
108
+
109
+ def load_tokenizer(snapshot: Path):
110
+ from transformers import AutoTokenizer
111
+
112
+ return AutoTokenizer.from_pretrained(
113
+ str(require_directory(snapshot, "locked tokenizer snapshot")),
114
+ local_files_only=True,
115
+ trust_remote_code=False,
116
+ )
117
+
118
+
119
+ def load_config(path: Path, expected_sha256: str):
120
+ from omegaconf import OmegaConf
121
+
122
+ return OmegaConf.load(verify_sha256(path, expected_sha256, "sampling config"))
123
+
124
+
125
+ def checkpoint_state(
126
+ path: Path, expected_sha256: str
127
+ ) -> tuple[dict[str, object], object | None]:
128
+ path = verify_sha256(path, expected_sha256, "student checkpoint")
129
+ if path.suffix == ".safetensors":
130
+ from safetensors.torch import load_file
131
+
132
+ return dict(load_file(str(path))), None
133
+ import torch
134
+
135
+ # Lightning 2.2 checkpoints contain OmegaConf DictConfig objects. Full pickle
136
+ # loading is deliberately restricted to bytes authenticated above by the
137
+ # canonical runner/checkpoint manifest provenance.
138
+ payload = torch.load(str(path), map_location="cpu", weights_only=False)
139
+ if not isinstance(payload, dict):
140
+ raise ValueError("student checkpoint is not a mapping")
141
+ state = payload.get("state_dict", payload)
142
+ if not isinstance(state, dict):
143
+ raise ValueError("student checkpoint state_dict is invalid")
144
+ config = None
145
+ hyperparameters = payload.get("hyper_parameters")
146
+ if isinstance(hyperparameters, dict):
147
+ config = hyperparameters.get("config")
148
+ return dict(state), config
149
+
150
+
151
+ _MISSING = object()
152
+ _STANDARD_REFERENCE = re.compile(r"^\$\{([A-Za-z_][A-Za-z0-9_.]*)\}$")
153
+
154
+
155
+ def _select_config_value(
156
+ config: object, path: str, references: frozenset[str] = frozenset()
157
+ ) -> object:
158
+ """Resolve one selected scalar without walking unrelated Hydra config nodes."""
159
+
160
+ try:
161
+ from omegaconf import OmegaConf
162
+
163
+ if OmegaConf.is_config(config):
164
+ try:
165
+ return OmegaConf.select(
166
+ config,
167
+ path,
168
+ default=_MISSING,
169
+ throw_on_resolution_failure=True,
170
+ )
171
+ except Exception as error:
172
+ raise ValueError(
173
+ f"sampling config field {path} cannot be resolved"
174
+ ) from error
175
+ except ImportError:
176
+ pass
177
+ value = config
178
+ for component in path.split("."):
179
+ try:
180
+ value = (
181
+ value[component]
182
+ if isinstance(value, Mapping)
183
+ else getattr(value, component)
184
+ )
185
+ except (AttributeError, KeyError, TypeError):
186
+ return _MISSING
187
+ if isinstance(value, str):
188
+ reference = _STANDARD_REFERENCE.fullmatch(value)
189
+ if reference is not None:
190
+ target = reference.group(1)
191
+ if target in references or target == path:
192
+ raise ValueError(f"sampling config has a cyclic reference at {path}")
193
+ return _select_config_value(config, target, references | {path})
194
+ return value
195
+
196
+
197
+ def _nested(config: object, path: str) -> object:
198
+ value = _select_config_value(config, path)
199
+ if value is _MISSING:
200
+ raise ValueError(f"sampling config is missing required field {path}")
201
+ return value
202
+
203
+
204
+ def _optional_nested(config: object, path: str) -> object:
205
+ return _select_config_value(config, path)
206
+
207
+
208
+ _CHECKPOINT_CONFIG_FIELDS = (
209
+ "T",
210
+ "time_conditioning",
211
+ "model.type",
212
+ "model.hidden_size",
213
+ "model.cond_dim",
214
+ "model.length",
215
+ "model.n_blocks",
216
+ "model.n_heads",
217
+ "model.scale_by_sigma",
218
+ "model.dropout",
219
+ "model.tie_word_embeddings",
220
+ "noise.type",
221
+ "noise.sigma_min",
222
+ "noise.sigma_max",
223
+ "training.ema",
224
+ "training.antithetic_sampling",
225
+ "training.importance_sampling",
226
+ "training.sampling_eps",
227
+ "training.change_of_variables",
228
+ "tokenizer.name",
229
+ "parameterization.name",
230
+ "parameterization.log_loss_buckets",
231
+ "parameterization.start_from_hf",
232
+ "parameterization.distill_mode",
233
+ "parameterization.num_distill_steps",
234
+ "parameterization.min_num_sampling_steps",
235
+ "parameterization.grow_dt_every",
236
+ "parameterization.orig_num_sampling_steps",
237
+ "parameterization.sampling_mode",
238
+ "parameterization.loss_precision",
239
+ "parameterization.reset_optimizer_on_growth",
240
+ "parameterization.use_ema_on_growth",
241
+ )
242
+
243
+ _OPTIONAL_CHECKPOINT_CONFIG_FIELDS = ("model.causal", "is_di4c")
244
+
245
+
246
+ def validate_embedded_config(
247
+ authoritative: object,
248
+ embedded: object | None,
249
+ *,
250
+ allow_missing_embedded_config: bool = False,
251
+ ) -> None:
252
+ if embedded is None:
253
+ if allow_missing_embedded_config:
254
+ return
255
+ raise ValueError("Lightning checkpoint does not embed its training config")
256
+ for path in (*_CHECKPOINT_CONFIG_FIELDS, *_OPTIONAL_CHECKPOINT_CONFIG_FIELDS):
257
+ expected = _optional_nested(authoritative, path)
258
+ if expected is _MISSING:
259
+ continue
260
+ observed = _optional_nested(embedded, path)
261
+ if observed is _MISSING:
262
+ raise ValueError(f"embedded checkpoint config is missing required field {path}")
263
+ if observed != expected:
264
+ raise ValueError(
265
+ f"embedded checkpoint config differs at {path}: "
266
+ f"expected {expected!r}, found {observed!r}"
267
+ )
268
+
269
+
270
+ def validate_sampling_config(
271
+ config: object,
272
+ *,
273
+ binding: TokenizerBinding,
274
+ sequence_length: int,
275
+ require_di4c: bool,
276
+ ) -> None:
277
+ for path in _CHECKPOINT_CONFIG_FIELDS:
278
+ _nested(config, path)
279
+ tokenizer_name = _nested(config, "tokenizer.name")
280
+ if tokenizer_name != binding.tokenizer_id and Path(str(tokenizer_name)).resolve() != binding.snapshot.resolve():
281
+ raise ValueError("sampling config tokenizer differs from canonical data contract")
282
+ if _nested(config, "model.length") != sequence_length:
283
+ raise ValueError("sampling config sequence length differs from canonical dataset")
284
+ if _nested(config, "data_preprocess.seq_len") != sequence_length:
285
+ raise ValueError("sampling config preprocessing length differs from canonical dataset")
286
+ if _nested(config, "parameterization.sampling_mode") != "ancestral":
287
+ raise ValueError("sampling config does not use ancestral sampling")
288
+ di4c_identity = _optional_nested(config, "is_di4c")
289
+ if require_di4c:
290
+ if di4c_identity is not True:
291
+ raise ValueError("sampling config Di4C identity is inconsistent")
292
+ if _nested(config, "parameterization.start_from_hf") is not False:
293
+ raise ValueError("Di4C sampling config must instantiate the local student")
294
+ elif di4c_identity not in {_MISSING, False}:
295
+ raise ValueError("sampling config Di4C identity is inconsistent")
296
+
297
+
298
+ def load_tokenizer_binding(
299
+ data_config_path: Path,
300
+ downloads_manifest_path: Path,
301
+ dataset_id: str,
302
+ requested_snapshot: Path,
303
+ ) -> TokenizerBinding:
304
+ data_config_path = require_file(data_config_path, "data config")
305
+ downloads_manifest_path = require_file(
306
+ downloads_manifest_path, "download manifest"
307
+ )
308
+ try:
309
+ configuration = yaml.safe_load(data_config_path.read_text(encoding="utf-8"))
310
+ downloads = json.loads(downloads_manifest_path.read_text(encoding="utf-8"))
311
+ tokenizer_id = configuration["datasets"][dataset_id]["tokenizer"]
312
+ revision = configuration["models"][tokenizer_id]
313
+ record = downloads["models"][tokenizer_id]
314
+ except (OSError, UnicodeDecodeError, json.JSONDecodeError, KeyError, TypeError) as error:
315
+ raise ValueError("locked tokenizer metadata is invalid") from error
316
+ if downloads.get("schema_version") != 1:
317
+ raise ValueError("download manifest schema is not supported")
318
+ if (
319
+ not isinstance(tokenizer_id, str)
320
+ or not isinstance(revision, str)
321
+ or len(revision) != 40
322
+ ):
323
+ raise ValueError("data config tokenizer binding is invalid")
324
+ if record.get("repo_id") != tokenizer_id or record.get("revision") != revision:
325
+ raise ValueError("download manifest tokenizer binding differs from data config")
326
+ recorded = record.get("snapshot_path")
327
+ if not isinstance(recorded, str) or not recorded:
328
+ raise ValueError("download manifest tokenizer snapshot is missing")
329
+ snapshot = Path(recorded)
330
+ if not snapshot.is_absolute():
331
+ snapshot = data_config_path.parents[1] / snapshot
332
+ requested_snapshot = requested_snapshot.absolute()
333
+ if requested_snapshot != snapshot:
334
+ raise ValueError("requested tokenizer snapshot differs from download manifest")
335
+ parts = snapshot.parts
336
+ try:
337
+ recorded_revision = parts[parts.index("snapshots") + 1]
338
+ except (ValueError, IndexError) as error:
339
+ raise ValueError("download manifest tokenizer snapshot path is invalid") from error
340
+ if recorded_revision != revision:
341
+ raise ValueError("download manifest tokenizer snapshot revision differs from data config")
342
+ require_directory(snapshot, "locked tokenizer snapshot")
343
+ return TokenizerBinding(tokenizer_id, revision, snapshot)
344
+
345
+
346
+ def instantiate_without_training_teacher(model_type, config, tokenizer):
347
+ """Instantiate the released student architecture without loading a network teacher."""
348
+
349
+ original = model_type.prepare_teacher_and_student
350
+
351
+ def sampling_only(self):
352
+ self.teacher = []
353
+
354
+ model_type.prepare_teacher_and_student = sampling_only
355
+ try:
356
+ return model_type(config, tokenizer, verbose=False)
357
+ finally:
358
+ model_type.prepare_teacher_and_student = original
359
+
360
+
361
+ def normalize_state_dict(state: dict[str, object]) -> dict[str, object]:
362
+ return {key.replace("_orig_mod.", ""): value for key, value in state.items()}
363
+
364
+
365
+ def write_capture_atomic(
366
+ output: Path,
367
+ *,
368
+ model,
369
+ tokenizer,
370
+ sample_count: int,
371
+ batch_size: int,
372
+ num_steps: int,
373
+ seq_len: int,
374
+ sampler: str,
375
+ generation_mode: str = "unconditional",
376
+ conditioning_manifest: Path | None = None,
377
+ conditioning_manifest_sha256: str | None = None,
378
+ prompt_count: int | None = None,
379
+ diversity_prompt_count: int | None = None,
380
+ completions_per_diversity_prompt: int | None = None,
381
+ ) -> None:
382
+ """Sample exact batches, immediately move IDs to CPU, and atomically publish JSON."""
383
+
384
+ if min(sample_count, batch_size, num_steps, seq_len) <= 0:
385
+ raise ValueError("sampling counts and lengths must be positive")
386
+ if sampler != "ancestral":
387
+ raise ValueError("distilled language baselines require ancestral sampling")
388
+ if generation_mode not in {"unconditional", "conditional_prefix"}:
389
+ raise ValueError(f"unsupported generation mode: {generation_mode!r}")
390
+ output = output.absolute()
391
+ if not output.is_absolute() or output.is_symlink():
392
+ raise ValueError(f"output path is unsafe: {output}")
393
+ output.parent.mkdir(parents=True, exist_ok=True)
394
+ descriptor, temporary_name = tempfile.mkstemp(
395
+ prefix=f".{output.name}.", suffix=".partial", dir=output.parent
396
+ )
397
+ temporary = Path(temporary_name)
398
+ written = 0
399
+ try:
400
+ with os.fdopen(descriptor, "w", encoding="utf-8") as handle:
401
+ handle.write('{"schema":"dlb-upstream-token-capture-v1","samples":[')
402
+ if generation_mode == "conditional_prefix":
403
+ if (
404
+ conditioning_manifest is None
405
+ or conditioning_manifest_sha256 is None
406
+ or prompt_count is None
407
+ or diversity_prompt_count is None
408
+ or completions_per_diversity_prompt is None
409
+ ):
410
+ raise ValueError("conditional distilled sampling requires a prompt contract")
411
+ batches: list[tuple[int, int, int]] = []
412
+ for start in range(0, prompt_count, batch_size):
413
+ batches.append((0, start, min(batch_size, prompt_count - start)))
414
+ for completion_id in range(1, completions_per_diversity_prompt):
415
+ for start in range(0, diversity_prompt_count, batch_size):
416
+ batches.append(
417
+ (
418
+ completion_id,
419
+ start,
420
+ min(batch_size, diversity_prompt_count - start),
421
+ )
422
+ )
423
+ else:
424
+ batches = [(-1, written, min(batch_size, sample_count - written)) for written in range(0, sample_count, batch_size)]
425
+ for completion_id, prompt_start, current in batches:
426
+ current = min(batch_size, sample_count - written)
427
+ batch = None
428
+ project_fn = lambda value: value
429
+ if generation_mode == "conditional_prefix":
430
+ batch = load_conditioning_batch(
431
+ conditioning_manifest,
432
+ conditioning_manifest_sha256,
433
+ completion_id=completion_id,
434
+ prompt_start=prompt_start,
435
+ batch_size=current,
436
+ device=str(model.device),
437
+ vocab_size=len(tokenizer),
438
+ )
439
+ project_fn = token_project_fn(batch.prefix_token_ids)
440
+ result = project_fn(
441
+ model.sample(
442
+ n_samples=current,
443
+ num_steps=num_steps,
444
+ seq_len=seq_len,
445
+ sampler=sampler,
446
+ verbose=False,
447
+ project_fn=project_fn,
448
+ )
449
+ )
450
+ rows = result.detach().cpu().tolist()
451
+ if not isinstance(rows, list) or len(rows) != current:
452
+ raise ValueError("upstream sampler returned the wrong batch size")
453
+ texts = list(tokenizer.batch_decode(rows))
454
+ if len(texts) != current:
455
+ raise ValueError("tokenizer returned the wrong decoded batch size")
456
+ for batch_index, (row, text) in enumerate(zip(rows, texts, strict=True)):
457
+ if not isinstance(row, list) or len(row) != seq_len:
458
+ raise ValueError("upstream sampler returned a noncanonical sequence")
459
+ if not isinstance(text, str) or not text.strip():
460
+ raise ValueError("upstream tokenizer returned empty text")
461
+ payload = {"sample_id": written, "text": text, "token_ids": row}
462
+ if batch is not None:
463
+ prefix = batch.prefix_token_ids[batch_index].detach().cpu().tolist()
464
+ reference = batch.reference_token_ids[batch_index].detach().cpu().tolist()
465
+ if row[: len(prefix)] != prefix:
466
+ raise ValueError("conditional sampler returned a prefix mismatch")
467
+ payload.update(
468
+ {
469
+ "prompt_id": batch.prompt_ids[batch_index],
470
+ "completion_id": completion_id,
471
+ "source_index": batch.source_indices[batch_index],
472
+ "prefix_token_ids": prefix,
473
+ "reference_token_ids": reference,
474
+ "full_token_ids": row,
475
+ "prefix_text": tokenizer.decode(prefix),
476
+ "continuation_text": tokenizer.decode(row[len(prefix) :]),
477
+ "reference_text": tokenizer.decode(reference),
478
+ "full_text": text,
479
+ "prefix_exact_match": True,
480
+ }
481
+ )
482
+ if written:
483
+ handle.write(",")
484
+ json.dump(
485
+ payload,
486
+ handle,
487
+ ensure_ascii=False,
488
+ separators=(",", ":"),
489
+ )
490
+ written += 1
491
+ del result, rows, texts
492
+ handle.write("]}")
493
+ handle.flush()
494
+ os.fsync(handle.fileno())
495
+ if written != sample_count:
496
+ raise ValueError(f"expected {sample_count} samples, wrote {written}")
497
+ os.replace(temporary, output)
498
+ except BaseException:
499
+ temporary.unlink(missing_ok=True)
500
+ raise
501
+
502
+
503
+ def benchmark_model(
504
+ *,
505
+ model,
506
+ output: Path,
507
+ metadata_path: Path,
508
+ precision: str,
509
+ num_steps: int,
510
+ seq_len: int,
511
+ sampler: str,
512
+ generation_mode: str = "unconditional",
513
+ conditioning_manifest: Path | None = None,
514
+ conditioning_manifest_sha256: str | None = None,
515
+ prompt_count: int | None = None,
516
+ diversity_prompt_count: int | None = None,
517
+ completions_per_diversity_prompt: int | None = None,
518
+ ):
519
+ """Time the already-materialized student's real one-sample tensor callback."""
520
+
521
+ if min(num_steps, seq_len) <= 0 or sampler != "ancestral":
522
+ raise ValueError("distilled benchmark sampling arguments are invalid")
523
+ from dlb.timing import benchmark_and_publish
524
+
525
+ project_fn = lambda value: value
526
+ if generation_mode == "conditional_prefix":
527
+ if conditioning_manifest is None or conditioning_manifest_sha256 is None:
528
+ raise ValueError("conditional benchmark requires a prompt manifest")
529
+ del prompt_count, diversity_prompt_count, completions_per_diversity_prompt
530
+ batch = load_conditioning_batch(
531
+ conditioning_manifest,
532
+ conditioning_manifest_sha256,
533
+ completion_id=0,
534
+ prompt_start=0,
535
+ batch_size=1,
536
+ device=str(model.device),
537
+ vocab_size=len(model.tokenizer),
538
+ )
539
+ project_fn = token_project_fn(batch.prefix_token_ids)
540
+ return benchmark_and_publish(
541
+ lambda: project_fn(model.sample(
542
+ n_samples=1,
543
+ num_steps=num_steps,
544
+ seq_len=seq_len,
545
+ sampler=sampler,
546
+ verbose=False,
547
+ project_fn=project_fn,
548
+ )),
549
+ model=model,
550
+ output=output,
551
+ metadata_path=metadata_path,
552
+ precision=precision,
553
+ )
554
+
555
+
556
+ def configure_for_sampling(config, *, tokenizer_snapshot: Path, seq_len: int) -> None:
557
+ config.tokenizer.name = str(tokenizer_snapshot)
558
+ config.model.length = seq_len
559
+ config.data_preprocess.seq_len = seq_len
560
+ config.mode = "sample"
561
+ config.compile = False
562
+
563
+
564
+ def materialize_model(
565
+ *,
566
+ model_type,
567
+ config,
568
+ tokenizer,
569
+ state: dict[str, object],
570
+ strict: bool,
571
+ ):
572
+ model = instantiate_without_training_teacher(model_type, config, tokenizer)
573
+ result = model.load_state_dict(normalize_state_dict(state), strict=strict)
574
+ if not strict:
575
+ missing = [key for key in result.missing_keys if not key.startswith("teacher.")]
576
+ unexpected = [key for key in result.unexpected_keys if not key.startswith("teacher.")]
577
+ if missing or unexpected:
578
+ raise ValueError(
579
+ "student checkpoint does not match the configured architecture: "
580
+ f"missing={missing[:8]}, unexpected={unexpected[:8]}"
581
+ )
582
+ model.eval()
583
+ if not __import__("torch").cuda.is_available():
584
+ raise RuntimeError("distilled sampling requires a CUDA server")
585
+ model.cuda()
586
+ return model
adapters/base.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from dlb.adapters.base import AdapterError, BaseTeacherAdapter, CheckpointSelection
2
+
3
+ __all__ = ["AdapterError", "BaseTeacherAdapter", "CheckpointSelection"]
adapters/candi.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from dlb.adapters.candi import CANDIAdapter, adapter
2
+
3
+ __all__ = ["CANDIAdapter", "adapter"]
adapters/di4c.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from dlb.adapters.di4c import Di4CAdapter, adapter
2
+
3
+ __all__ = ["Di4CAdapter", "adapter"]
adapters/duo.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from dlb.adapters.duo import DuoAdapter, adapter
2
+
3
+ __all__ = ["DuoAdapter", "adapter"]
adapters/flm.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from dlb.adapters.flm import FLMAdapter, adapter
2
+
3
+ __all__ = ["FLMAdapter", "adapter"]
adapters/langflow.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from dlb.adapters.langflow import LangFlowAdapter, adapter
2
+
3
+ __all__ = ["LangFlowAdapter", "adapter"]
adapters/mdlm.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from dlb.adapters.mdlm import MDLMAdapter, adapter
2
+
3
+ __all__ = ["MDLMAdapter", "adapter"]
adapters/rdlm.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from dlb.adapters.rdlm import RDLMAdapter, adapter
2
+
3
+ __all__ = ["RDLMAdapter", "adapter"]
adapters/sample_di4c.py ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Sample a pinned Di4C language student from local server assets only."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ from pathlib import Path
8
+
9
+ from _distilled_runtime import (
10
+ benchmark_model,
11
+ checkpoint_state,
12
+ configure_for_sampling,
13
+ install_upstream,
14
+ load_config,
15
+ load_tokenizer,
16
+ load_tokenizer_binding,
17
+ materialize_model,
18
+ offline_huggingface,
19
+ parse_bool,
20
+ require_directory,
21
+ require_file,
22
+ seed_everything,
23
+ validate_embedded_config,
24
+ validate_sampling_config,
25
+ write_capture_atomic,
26
+ )
27
+
28
+
29
+ def main(argv: list[str] | None = None) -> int:
30
+ parser = argparse.ArgumentParser(description=__doc__)
31
+ parser.add_argument("--upstream-root", type=Path, required=True)
32
+ parser.add_argument("--checkpoint", type=Path, required=True)
33
+ parser.add_argument("--config", type=Path, required=True)
34
+ parser.add_argument("--checkpoint-sha256", required=True)
35
+ parser.add_argument("--config-sha256", required=True)
36
+ parser.add_argument("--data-config", type=Path, required=True)
37
+ parser.add_argument("--downloads-manifest", type=Path, required=True)
38
+ parser.add_argument("--tokenizer-snapshot", type=Path, required=True)
39
+ parser.add_argument("--output", type=Path, required=True)
40
+ parser.add_argument("--sample-count", type=int, required=True)
41
+ parser.add_argument("--batch-size", type=int, required=True)
42
+ parser.add_argument("--num-steps", type=int, required=True)
43
+ parser.add_argument("--seq-len", type=int, required=True)
44
+ parser.add_argument("--seed", type=int, required=True)
45
+ parser.add_argument("--sampler", choices=("ancestral",), required=True)
46
+ parser.add_argument(
47
+ "--teacher-family", choices=("masked_mdlm", "uniform_duo"), required=True
48
+ )
49
+ parser.add_argument("--dataset", choices=("lm1b", "owt"), required=True)
50
+ parser.add_argument("--generation-mode", choices=("unconditional", "conditional_prefix"), default="unconditional")
51
+ parser.add_argument("--conditioning-manifest", type=Path)
52
+ parser.add_argument("--conditioning-manifest-sha256")
53
+ parser.add_argument("--conditioning-config-sha256")
54
+ parser.add_argument("--prefix-length", type=int)
55
+ parser.add_argument("--evaluation-continuation-length", type=int)
56
+ parser.add_argument("--prompt-count", type=int)
57
+ parser.add_argument("--diversity-prompt-count", type=int)
58
+ parser.add_argument("--completions-per-diversity-prompt", type=int)
59
+ parser.add_argument("--completion-schedule")
60
+ parser.add_argument("--offline", type=parse_bool, required=True)
61
+ parser.add_argument(
62
+ "--allow-missing-embedded-config", type=parse_bool, default=False
63
+ )
64
+ parser.add_argument("--benchmark-output", type=Path)
65
+ parser.add_argument("--benchmark-metadata", type=Path)
66
+ parser.add_argument("--benchmark-precision", choices=("author",))
67
+ args = parser.parse_args(argv)
68
+ benchmark_values = (args.benchmark_output, args.benchmark_metadata, args.benchmark_precision)
69
+ if any(value is not None for value in benchmark_values) and not all(
70
+ value is not None for value in benchmark_values
71
+ ):
72
+ parser.error("benchmark arguments must be provided together")
73
+
74
+ upstream = require_directory(args.upstream_root, "pinned Di4C language source")
75
+ require_file(upstream / "src/sdtt/main.py", "pinned Di4C entrypoint")
76
+ install_upstream(upstream)
77
+ checkpoint = require_file(args.checkpoint, "Di4C student checkpoint")
78
+ config_path = require_file(args.config, "Di4C sampling config")
79
+ binding = load_tokenizer_binding(
80
+ args.data_config,
81
+ args.downloads_manifest,
82
+ args.dataset,
83
+ args.tokenizer_snapshot,
84
+ )
85
+ with offline_huggingface(args.offline):
86
+ from sdtt.core.distill.multi_round_sdtt import MultiRoundSDTT
87
+
88
+ config = load_config(config_path, args.config_sha256)
89
+ state, embedded_config = checkpoint_state(
90
+ checkpoint, args.checkpoint_sha256
91
+ )
92
+ validate_sampling_config(
93
+ config,
94
+ binding=binding,
95
+ sequence_length=args.seq_len,
96
+ require_di4c=True,
97
+ )
98
+ validate_embedded_config(
99
+ config,
100
+ embedded_config,
101
+ allow_missing_embedded_config=args.allow_missing_embedded_config,
102
+ )
103
+ configure_for_sampling(
104
+ config, tokenizer_snapshot=binding.snapshot, seq_len=args.seq_len
105
+ )
106
+ config.parameterization.checkpoint_path = str(checkpoint)
107
+ tokenizer = load_tokenizer(binding.snapshot)
108
+ seed_everything(args.seed)
109
+ model = materialize_model(
110
+ model_type=MultiRoundSDTT,
111
+ config=config,
112
+ tokenizer=tokenizer,
113
+ state=state,
114
+ strict=False,
115
+ )
116
+ if args.benchmark_output is not None:
117
+ benchmark_model(
118
+ model=model,
119
+ output=args.benchmark_output,
120
+ metadata_path=args.benchmark_metadata,
121
+ precision=args.benchmark_precision,
122
+ num_steps=args.num_steps,
123
+ seq_len=args.seq_len,
124
+ sampler=args.sampler,
125
+ generation_mode=args.generation_mode,
126
+ conditioning_manifest=args.conditioning_manifest,
127
+ conditioning_manifest_sha256=args.conditioning_manifest_sha256,
128
+ prompt_count=args.prompt_count,
129
+ diversity_prompt_count=args.diversity_prompt_count,
130
+ completions_per_diversity_prompt=args.completions_per_diversity_prompt,
131
+ )
132
+ else:
133
+ write_capture_atomic(
134
+ args.output,
135
+ model=model,
136
+ tokenizer=tokenizer,
137
+ sample_count=args.sample_count,
138
+ batch_size=args.batch_size,
139
+ num_steps=args.num_steps,
140
+ seq_len=args.seq_len,
141
+ sampler=args.sampler,
142
+ generation_mode=args.generation_mode,
143
+ conditioning_manifest=args.conditioning_manifest,
144
+ conditioning_manifest_sha256=args.conditioning_manifest_sha256,
145
+ prompt_count=args.prompt_count,
146
+ diversity_prompt_count=args.diversity_prompt_count,
147
+ completions_per_diversity_prompt=args.completions_per_diversity_prompt,
148
+ )
149
+ return 0
150
+
151
+
152
+ if __name__ == "__main__":
153
+ raise SystemExit(main())
adapters/sample_langflow.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Dataset-configurable LangFlow sampler used by the DLB capture wrapper."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ from pathlib import Path
8
+ import sys
9
+
10
+ import torch
11
+ from safetensors.torch import load_file
12
+ from transformers import AutoTokenizer
13
+
14
+
15
+ ROOT = Path(__file__).resolve().parents[1]
16
+ UPSTREAM_ROOT = ROOT / "upstreams" / "langflow"
17
+ if str(UPSTREAM_ROOT) not in sys.path:
18
+ sys.path.insert(0, str(UPSTREAM_ROOT))
19
+
20
+ from langflow import LangFlow, LangFlowConfig # noqa: E402
21
+
22
+
23
+ def parse_args() -> argparse.Namespace:
24
+ parser = argparse.ArgumentParser(description="Generate samples with pinned LangFlow")
25
+ parser.add_argument("--checkpoint", required=True)
26
+ parser.add_argument("--num_samples", type=int, default=5)
27
+ parser.add_argument("--batch_size", type=int, default=1)
28
+ parser.add_argument("--num_steps", type=int, default=128)
29
+ parser.add_argument("--seq_length", type=int, default=None)
30
+ parser.add_argument("--seed", type=int, default=42)
31
+ parser.add_argument("--output")
32
+ parser.add_argument("--tokenizer", required=True)
33
+ return parser.parse_args()
34
+
35
+
36
+ def main() -> None:
37
+ args = parse_args()
38
+ checkpoint = Path(args.checkpoint)
39
+ config_dir = checkpoint.parent
40
+
41
+ torch.manual_seed(args.seed)
42
+ if torch.cuda.is_available():
43
+ torch.cuda.manual_seed_all(args.seed)
44
+
45
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
46
+ config = LangFlowConfig.from_pretrained(str(config_dir))
47
+ model = LangFlow(config)
48
+ state_dict = load_file(str(checkpoint), device=str(device))
49
+ model.load_state_dict(state_dict)
50
+ model = model.to(device)
51
+ model.eval()
52
+
53
+ tokenizer = AutoTokenizer.from_pretrained(args.tokenizer)
54
+
55
+ all_samples = []
56
+ remaining = args.num_samples
57
+ with torch.no_grad():
58
+ while remaining > 0:
59
+ batch = min(args.batch_size, remaining)
60
+ samples = model.generate_samples(
61
+ num_samples=batch,
62
+ seq_length=args.seq_length,
63
+ num_steps=args.num_steps,
64
+ device=device,
65
+ )
66
+ all_samples.append(samples)
67
+ remaining -= batch
68
+
69
+ generated = torch.cat(all_samples, dim=0)
70
+ texts = tokenizer.batch_decode(generated, skip_special_tokens=True)
71
+ for index, text in enumerate(texts):
72
+ print(f"\n--- Sample {index + 1} ---")
73
+ print(text[:500] + ("..." if len(text) > 500 else ""))
74
+
75
+ if args.output is not None:
76
+ with open(args.output, "w", encoding="utf-8") as output_file:
77
+ for index, text in enumerate(texts):
78
+ output_file.write(f"--- Sample {index + 1} ---\n{text}\n\n")
79
+
80
+
81
+ if __name__ == "__main__":
82
+ main()
adapters/sample_sdtt.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Sample the pinned SDTT KLD round-7 student from local server assets only."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ from pathlib import Path
8
+
9
+ from _distilled_runtime import (
10
+ benchmark_model,
11
+ configure_for_sampling,
12
+ install_upstream,
13
+ load_config,
14
+ load_tokenizer,
15
+ load_tokenizer_binding,
16
+ materialize_model,
17
+ offline_huggingface,
18
+ parse_bool,
19
+ require_directory,
20
+ require_file,
21
+ seed_everything,
22
+ checkpoint_state,
23
+ validate_embedded_config,
24
+ validate_sampling_config,
25
+ write_capture_atomic,
26
+ )
27
+
28
+
29
+ def main(argv: list[str] | None = None) -> int:
30
+ parser = argparse.ArgumentParser(description=__doc__)
31
+ parser.add_argument("--upstream-root", type=Path, required=True)
32
+ parser.add_argument("--checkpoint", type=Path, required=True)
33
+ parser.add_argument("--config", type=Path, required=True)
34
+ parser.add_argument("--checkpoint-sha256", required=True)
35
+ parser.add_argument("--config-sha256", required=True)
36
+ parser.add_argument("--data-config", type=Path, required=True)
37
+ parser.add_argument("--downloads-manifest", type=Path, required=True)
38
+ parser.add_argument("--dataset", choices=("lm1b", "owt"), required=True)
39
+ parser.add_argument("--tokenizer-snapshot", type=Path, required=True)
40
+ parser.add_argument("--output", type=Path, required=True)
41
+ parser.add_argument("--sample-count", type=int, required=True)
42
+ parser.add_argument("--batch-size", type=int, required=True)
43
+ parser.add_argument("--num-steps", type=int, required=True)
44
+ parser.add_argument("--seq-len", type=int, required=True)
45
+ parser.add_argument("--seed", type=int, required=True)
46
+ parser.add_argument("--sampler", choices=("ancestral",), required=True)
47
+ parser.add_argument("--loss", choices=("kld",), required=True)
48
+ parser.add_argument("--round", type=int, choices=(7,), required=True)
49
+ parser.add_argument("--teacher-family", choices=("masked_mdlm",), required=True)
50
+ parser.add_argument("--generation-mode", choices=("unconditional", "conditional_prefix"), default="unconditional")
51
+ parser.add_argument("--conditioning-manifest", type=Path)
52
+ parser.add_argument("--conditioning-manifest-sha256")
53
+ parser.add_argument("--conditioning-config-sha256")
54
+ parser.add_argument("--prefix-length", type=int)
55
+ parser.add_argument("--evaluation-continuation-length", type=int)
56
+ parser.add_argument("--prompt-count", type=int)
57
+ parser.add_argument("--diversity-prompt-count", type=int)
58
+ parser.add_argument("--completions-per-diversity-prompt", type=int)
59
+ parser.add_argument("--completion-schedule")
60
+ parser.add_argument("--offline", type=parse_bool, required=True)
61
+ parser.add_argument("--benchmark-output", type=Path)
62
+ parser.add_argument("--benchmark-metadata", type=Path)
63
+ parser.add_argument("--benchmark-precision", choices=("author",))
64
+ args = parser.parse_args(argv)
65
+ benchmark_values = (args.benchmark_output, args.benchmark_metadata, args.benchmark_precision)
66
+ if any(value is not None for value in benchmark_values) and not all(
67
+ value is not None for value in benchmark_values
68
+ ):
69
+ parser.error("benchmark arguments must be provided together")
70
+
71
+ upstream = require_directory(args.upstream_root, "pinned SDTT source")
72
+ require_file(upstream / "src/sdtt/main.py", "pinned SDTT entrypoint")
73
+ install_upstream(upstream)
74
+ checkpoint = require_file(args.checkpoint, "SDTT student checkpoint")
75
+ config_path = require_file(args.config, "SDTT student config")
76
+ binding = load_tokenizer_binding(
77
+ args.data_config,
78
+ args.downloads_manifest,
79
+ args.dataset,
80
+ args.tokenizer_snapshot,
81
+ )
82
+ with offline_huggingface(args.offline):
83
+ from sdtt.core.distill.multi_round_sdtt import MultiRoundSDTT
84
+
85
+ config = load_config(config_path, args.config_sha256)
86
+ state, embedded_config = checkpoint_state(
87
+ checkpoint, args.checkpoint_sha256
88
+ )
89
+ validate_sampling_config(
90
+ config,
91
+ binding=binding,
92
+ sequence_length=args.seq_len,
93
+ require_di4c=False,
94
+ )
95
+ if embedded_config is not None:
96
+ validate_embedded_config(config, embedded_config)
97
+ configure_for_sampling(
98
+ config, tokenizer_snapshot=binding.snapshot, seq_len=args.seq_len
99
+ )
100
+ tokenizer = load_tokenizer(binding.snapshot)
101
+ seed_everything(args.seed)
102
+ model = materialize_model(
103
+ model_type=MultiRoundSDTT,
104
+ config=config,
105
+ tokenizer=tokenizer,
106
+ state=state,
107
+ strict=True,
108
+ )
109
+ if args.benchmark_output is not None:
110
+ benchmark_model(
111
+ model=model,
112
+ output=args.benchmark_output,
113
+ metadata_path=args.benchmark_metadata,
114
+ precision=args.benchmark_precision,
115
+ num_steps=args.num_steps,
116
+ seq_len=args.seq_len,
117
+ sampler=args.sampler,
118
+ generation_mode=args.generation_mode,
119
+ conditioning_manifest=args.conditioning_manifest,
120
+ conditioning_manifest_sha256=args.conditioning_manifest_sha256,
121
+ prompt_count=args.prompt_count,
122
+ diversity_prompt_count=args.diversity_prompt_count,
123
+ completions_per_diversity_prompt=args.completions_per_diversity_prompt,
124
+ )
125
+ else:
126
+ write_capture_atomic(
127
+ args.output,
128
+ model=model,
129
+ tokenizer=tokenizer,
130
+ sample_count=args.sample_count,
131
+ batch_size=args.batch_size,
132
+ num_steps=args.num_steps,
133
+ seq_len=args.seq_len,
134
+ sampler=args.sampler,
135
+ generation_mode=args.generation_mode,
136
+ conditioning_manifest=args.conditioning_manifest,
137
+ conditioning_manifest_sha256=args.conditioning_manifest_sha256,
138
+ prompt_count=args.prompt_count,
139
+ diversity_prompt_count=args.diversity_prompt_count,
140
+ completions_per_diversity_prompt=args.completions_per_diversity_prompt,
141
+ )
142
+ return 0
143
+
144
+
145
+ if __name__ == "__main__":
146
+ raise SystemExit(main())
adapters/sdtt.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from dlb.adapters.sdtt import SDTTAdapter, adapter
2
+
3
+ __all__ = ["SDTTAdapter", "adapter"]
adapters/train_di4c.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Run Di4C language distillation with project-controlled student initialization."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ import sys
7
+ from typing import Any
8
+
9
+
10
+ _INIT_MODES = frozenset({"hf_small", "teacher", "scratch"})
11
+ _EVAL_GLOBALS = {
12
+ "__builtins__": {},
13
+ "__import__": __import__,
14
+ "abs": abs,
15
+ "float": float,
16
+ "int": int,
17
+ "len": len,
18
+ "max": max,
19
+ "min": min,
20
+ "round": round,
21
+ "str": str,
22
+ "sum": sum,
23
+ }
24
+
25
+
26
+ def _install_upstream_path() -> Path:
27
+ source = Path.cwd()
28
+ sdtt_src = source / "sdtt" / "src"
29
+ sdtt_package_root = sdtt_src / "sdtt"
30
+ if not (sdtt_package_root / "main.py").is_file():
31
+ raise RuntimeError(f"Di4C SDTT source is missing: {sdtt_src}")
32
+ for path in (source, sdtt_src, sdtt_package_root):
33
+ text = str(path)
34
+ if text not in sys.path:
35
+ sys.path.insert(0, text)
36
+ return source
37
+
38
+
39
+ def _student_init_mode(config: Any) -> str:
40
+ mode = config.get("dlb_student_init", "hf_small")
41
+ if mode not in _INIT_MODES:
42
+ raise ValueError(
43
+ f"unsupported dlb_student_init={mode!r}; expected one of {sorted(_INIT_MODES)}"
44
+ )
45
+ return str(mode)
46
+
47
+
48
+ def _eval_expression(expression: Any) -> Any:
49
+ return eval(str(expression), _EVAL_GLOBALS, {})
50
+
51
+
52
+ def _device_count() -> int:
53
+ try:
54
+ import torch
55
+ except ImportError:
56
+ return 0
57
+ return int(torch.cuda.device_count())
58
+
59
+
60
+ def _register_omegaconf_resolvers() -> None:
61
+ from omegaconf import OmegaConf
62
+
63
+ resolvers = {
64
+ "cwd": lambda: str(Path.cwd()),
65
+ "device_count": _device_count,
66
+ "div_up": lambda numerator, denominator: (
67
+ int(numerator) + int(denominator) - 1
68
+ )
69
+ // int(denominator),
70
+ "eval": _eval_expression,
71
+ }
72
+ for name, resolver in resolvers.items():
73
+ try:
74
+ OmegaConf.register_new_resolver(name, resolver, replace=True)
75
+ except TypeError:
76
+ OmegaConf.clear_resolver(name)
77
+ OmegaConf.register_new_resolver(name, resolver)
78
+
79
+
80
+ def _teacher_initialized_student(config: Any):
81
+ from sdtt.loading_utils import get_diffusion
82
+ from transformers import AutoTokenizer
83
+
84
+ tokenizer = AutoTokenizer.from_pretrained(config.tokenizer.name)
85
+ return get_diffusion(config, tokenizer)
86
+
87
+
88
+ def _hf_small_initialized_student(loss: str, round: int, config: Any):
89
+ if round not in range(1, 8):
90
+ raise ValueError(
91
+ f"Round value is too large: should be 1 <= round <= 7. Actual value: `{round}`"
92
+ )
93
+ if loss not in ("kld", "mse", "tvd"):
94
+ raise ValueError(f"Valid losses sizes: kld, mse, tvd. Actual value: `{loss}`")
95
+
96
+ from sdtt.core.distill.multi_round_sdtt import MultiRoundSDTT
97
+
98
+ revision = f"baselines_{loss}_step_{round * 10_000}"
99
+ # Upstream load_small_student uses student_as_teacher=True, which overwrites
100
+ # the configured teacher checkpoint with the HF small student backbone.
101
+ return MultiRoundSDTT.from_pretrained(
102
+ "jdeschena/sdtt",
103
+ revision,
104
+ config=config,
105
+ student_as_teacher=False,
106
+ )
107
+
108
+
109
+ def _scratch_initialized_student(config: Any):
110
+ from sdtt.models.loading_utils import get_backbone
111
+
112
+ model = _teacher_initialized_student(config)
113
+ model.backbone = get_backbone(config, model.vocab_size)
114
+ if hasattr(model.backbone, "is_di4c"):
115
+ model.backbone.is_di4c = True
116
+ model.init_ema()
117
+ return model
118
+
119
+
120
+ def _patch_student_loader() -> None:
121
+ import sdtt
122
+
123
+ original = sdtt.load_small_student
124
+ if getattr(original, "_dlb_student_init_patch", False):
125
+ return
126
+
127
+ def load_small_student(
128
+ loss: str = "kld",
129
+ round: int = 1,
130
+ config: Any | None = None,
131
+ **kwargs: Any,
132
+ ):
133
+ if config is None:
134
+ try:
135
+ return original(loss=loss, round=round, config=config, **kwargs)
136
+ except TypeError:
137
+ if kwargs:
138
+ return original(loss=loss, round=round, config=config)
139
+ raise
140
+
141
+ mode = _student_init_mode(config)
142
+ if mode == "hf_small":
143
+ kwargs.pop("student_as_teacher", None)
144
+ if kwargs:
145
+ raise TypeError(
146
+ f"unexpected load_small_student keyword(s): {sorted(kwargs)}"
147
+ )
148
+ return _hf_small_initialized_student(loss=loss, round=round, config=config)
149
+ if mode == "teacher":
150
+ return _teacher_initialized_student(config)
151
+ if mode == "scratch":
152
+ return _scratch_initialized_student(config)
153
+ raise AssertionError(f"unreachable Di4C student init mode: {mode}")
154
+
155
+ load_small_student._dlb_student_init_patch = True # type: ignore[attr-defined]
156
+ sdtt.load_small_student = load_small_student
157
+
158
+
159
+ def main() -> int:
160
+ _install_upstream_path()
161
+ _register_omegaconf_resolvers()
162
+ import hydra
163
+
164
+ _patch_student_loader()
165
+ import sdtt.main as upstream_main
166
+
167
+ @hydra.main(
168
+ version_base=None,
169
+ config_path="../upstreams/di4c/sdtt/src/sdtt/configs",
170
+ config_name="config",
171
+ )
172
+ def run(config: Any) -> None:
173
+ upstream_main.main.__wrapped__(config)
174
+
175
+ return int(run() or 0)
176
+
177
+
178
+ if __name__ == "__main__":
179
+ raise SystemExit(main())
adapters/train_duo_dcd.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Run Duo+DCD with a narrow compatibility patch for the pinned Duo source."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ import sys
7
+ from typing import Any
8
+
9
+
10
+ def _patch_distillation_nll() -> None:
11
+ import algo
12
+
13
+ original = algo.Distillation.nll
14
+ if getattr(original, "_dlb_accepts_labels", False):
15
+ return
16
+
17
+ def nll(
18
+ self: Any,
19
+ x0: Any,
20
+ labels_or_output_tokens: Any = None,
21
+ output_tokens: Any = None,
22
+ current_accumulation_step: Any = None,
23
+ train_mode: Any = None,
24
+ ) -> Any:
25
+ if output_tokens is None:
26
+ output_tokens = labels_or_output_tokens
27
+ return original(
28
+ self,
29
+ x0,
30
+ output_tokens,
31
+ current_accumulation_step,
32
+ train_mode,
33
+ )
34
+
35
+ nll._dlb_accepts_labels = True # type: ignore[attr-defined]
36
+ algo.Distillation.nll = nll
37
+
38
+
39
+ def main() -> int:
40
+ import hydra
41
+
42
+ sys.path.insert(0, str(Path.cwd()))
43
+ _patch_distillation_nll()
44
+ import main as upstream_main
45
+
46
+ @hydra.main(
47
+ version_base=None,
48
+ config_path="../upstreams/duo/configs",
49
+ config_name="config",
50
+ )
51
+ def run(config: Any) -> None:
52
+ upstream_main.main.__wrapped__(config)
53
+
54
+ return int(run() or 0)
55
+
56
+
57
+ if __name__ == "__main__":
58
+ raise SystemExit(main())
artifacts/data.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ schema_version: 1
2
+ resolved_at: "2026-07-29"
3
+ datasets:
4
+ lm1b:
5
+ repo_id: billion-word-benchmark/lm1b
6
+ revision: 35161838ea9e05371a25a8db037f94fcae4c2064
7
+ parquet_revision: 8d52bfd3cc2819fc1166dbb8144c328e2690de3e
8
+ config: plain_text
9
+ splits:
10
+ train: train
11
+ validation: test
12
+ sequence_length: 128
13
+ tokenizer: bert-base-uncased
14
+ owt:
15
+ repo_id: Skylion007/openwebtext
16
+ revision: 79d93d786212f7344586290adb811d4ae6a1762c
17
+ config: plain_text
18
+ documents: 8013769
19
+ splits:
20
+ train: "train[:-100000]"
21
+ validation: "train[-100000:]"
22
+ sequence_length: 1024
23
+ tokenizer: gpt2
24
+ models:
25
+ bert-base-uncased: 86b5e0934494bd15c9632b12f734a8a67f723594
26
+ gpt2: 607a30d783dfa663caf39e06633721c8d4cfcd7e
27
+ gpt2-large: 32b71b12589c2f8d625668d2335a01cac3249519
28
+ lm1b_archive:
29
+ url: http://www.statmt.org/lm-benchmark/1-billion-word-language-modeling-benchmark-r13output.tar.gz
30
+ size_bytes: 1792209805
31
+ sha256: 01ba60381110baf7f189dfd2b8374de371e8c9a340835793f190bdae9e90a34e
32
+ train_documents: 30301028
33
+ test_documents: 306688
checkpoints/official/flm/lm1b/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef02806ef90ab9aca274371c3b644193f0af1757504acdd11ac1c3f89359f55c
3
+ size 557184584
checkpoints/official/mdlm/owt/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:47149e73f7552f39ea9776dbe74d925d25237bcf2ed2e2ec03cdff9d51c82aa4
3
+ size 678522728
data/conditional/lm1b-c64/prompts.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/conditional/owt-c64/prompts.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/assets.json ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "assets": {
3
+ "owt": {
4
+ "repo_id": "embedded-language-flows/ELF-B-owt-torch",
5
+ "revision": "146f84133c1389bfd4ef47f14ec7a955da22faa7",
6
+ "repo_type": "model",
7
+ "patterns": [
8
+ "checkpoint_95085",
9
+ "config.yml"
10
+ ],
11
+ "checkpoint": "checkpoint_95085",
12
+ "path": "data/elf/snapshots/owt/146f84133c1389bfd4ef47f14ec7a955da22faa7",
13
+ "sha256": {
14
+ "checkpoint_95085": "52c21bfb7f920e785e0e780645c411c94e4541af4cee8f85b6f555f826d4c283",
15
+ "config.yml": "cce48467f0a54b99d9512e2d0bc670f9cddcc211436c98a0076591f0be9ebfa8"
16
+ }
17
+ },
18
+ "wmt14": {
19
+ "repo_id": "embedded-language-flows/ELF-B-de-en-torch",
20
+ "revision": "93ce98315a2dec985cdefb8d8e62ab618e896ec4",
21
+ "repo_type": "model",
22
+ "patterns": [
23
+ "checkpoint_880600",
24
+ "config.yml"
25
+ ],
26
+ "checkpoint": "checkpoint_880600",
27
+ "path": "data/elf/snapshots/wmt14/93ce98315a2dec985cdefb8d8e62ab618e896ec4",
28
+ "sha256": {
29
+ "checkpoint_880600": "46d77302b9f28b293227a2d29fd0f20b50be289ce9aa63a32f515f3290bbe7cc",
30
+ "config.yml": "1ac04147a1d80c4f8cd7fd304d11fc3897c490b1dfd132c9d472d6f781dd9657"
31
+ }
32
+ },
33
+ "xsum": {
34
+ "repo_id": "embedded-language-flows/ELF-B-xsum-torch",
35
+ "revision": "aca4abd1c7ff5f841f0e2a3ec8a18b0a927927f1",
36
+ "repo_type": "model",
37
+ "patterns": [
38
+ "checkpoint_39800",
39
+ "config.yml"
40
+ ],
41
+ "checkpoint": "checkpoint_39800",
42
+ "path": "data/elf/snapshots/xsum/aca4abd1c7ff5f841f0e2a3ec8a18b0a927927f1",
43
+ "sha256": {
44
+ "checkpoint_39800": "fb2cb9a2aba0328d0de30d53800c0976a019303b9a31f16051981982ed8795ae",
45
+ "config.yml": "70a3850da7244a5aa6ca61698233945f56ea2c44f5b0c73f3c7fd42375f8cdf3"
46
+ }
47
+ },
48
+ "t5": {
49
+ "repo_id": "google-t5/t5-small",
50
+ "revision": "df1b051c49625cf57a3d0d8d3863ed4d13564fe4",
51
+ "repo_type": "model",
52
+ "patterns": [
53
+ "config.json",
54
+ "model.safetensors",
55
+ "spiece.model",
56
+ "tokenizer.json",
57
+ "tokenizer_config.json"
58
+ ],
59
+ "path": "data/elf/snapshots/t5/df1b051c49625cf57a3d0d8d3863ed4d13564fe4",
60
+ "sha256": {
61
+ "config.json": "530e25060e3a8d5f7b0fcf53bfea9f3601165161f3b1914676e98d97cf07bcf1",
62
+ "model.safetensors": "bd944e5f1b3ad9b70dd9d00010a517059e19265671076b8b0a4a58d9491842bc",
63
+ "spiece.model": "d60acb128cf7b7f2536e8f38a5b18a05535c9e14c7a355904270e15b0945ea86",
64
+ "tokenizer.json": "d2acde0d8d71dd30a711834b07781b9c89feaac33fd332f60507699282740066",
65
+ "tokenizer_config.json": "d1e7146101aa96282057f374aa9c3b260fba2109e5990edb1775d6efc70ffa3c"
66
+ }
67
+ },
68
+ "gpt2": {
69
+ "repo_id": "gpt2",
70
+ "revision": "607a30d783dfa663caf39e06633721c8d4cfcd7e",
71
+ "repo_type": "model",
72
+ "patterns": [
73
+ "config.json",
74
+ "tokenizer.json",
75
+ "tokenizer_config.json",
76
+ "vocab.json",
77
+ "merges.txt"
78
+ ],
79
+ "path": "data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e",
80
+ "sha256": {
81
+ "config.json": "0daed7749b4f02b8f76240d5444551d7b08712dab4d0adb8239c56ba823bb7b4",
82
+ "merges.txt": "1ce1664773c50f3e0cc8842619a93edc4624525b728b188a9e0be33b7726adc5",
83
+ "tokenizer.json": "8414cab924d8b9b33013f0d221c5862f365ee9be39c5c2bfae8a5a9e970478a6",
84
+ "tokenizer_config.json": "5e04eb606e3a1583530a42e36c2a6b6615c86f34fe77e44d9ddeb43ff940931f",
85
+ "vocab.json": "196139668be63f3b5d6574427317ae82f612a97c5d1cdaf36ed2256dbf636783"
86
+ }
87
+ },
88
+ "gpt2-large": {
89
+ "repo_id": "gpt2-large",
90
+ "revision": "32b71b12589c2f8d625668d2335a01cac3249519",
91
+ "repo_type": "model",
92
+ "patterns": [
93
+ "config.json",
94
+ "model.safetensors",
95
+ "tokenizer.json",
96
+ "tokenizer_config.json",
97
+ "vocab.json",
98
+ "merges.txt"
99
+ ],
100
+ "path": "data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519",
101
+ "sha256": {
102
+ "config.json": "7fccdcfd6622055342a734c663ee0b61ff4fd697f42467595df0bf4448c8c170",
103
+ "merges.txt": "1ce1664773c50f3e0cc8842619a93edc4624525b728b188a9e0be33b7726adc5",
104
+ "model.safetensors": "5f47f3e12f91cd33b662ce7e433b6150ad5512b5884a2cee961b50e9c3bbebce",
105
+ "tokenizer.json": "8414cab924d8b9b33013f0d221c5862f365ee9be39c5c2bfae8a5a9e970478a6",
106
+ "tokenizer_config.json": "5e04eb606e3a1583530a42e36c2a6b6615c86f34fe77e44d9ddeb43ff940931f",
107
+ "vocab.json": "196139668be63f3b5d6574427317ae82f612a97c5d1cdaf36ed2256dbf636783"
108
+ }
109
+ },
110
+ "wmt14-official-validation": {
111
+ "repo_id": "embedded-language-flows/wmt14_de-en_validation_t5",
112
+ "revision": "bcc92bda4b07c329354843724c9d9ea740f30685",
113
+ "repo_type": "dataset",
114
+ "patterns": [
115
+ "*.arrow",
116
+ "*.json"
117
+ ],
118
+ "path": "data/elf/snapshots/wmt14-official-validation/bcc92bda4b07c329354843724c9d9ea740f30685",
119
+ "sha256": {
120
+ "data-00000-of-00001.arrow": "fbd26e8d20fb89d70283450ecda1635fb832f9cb42b713b1ac9c491f464cbd1e",
121
+ "dataset_info.json": "bf037f9baf98ca5b4fae81e09c0328c449fd28a35235d35500c452d84d8cd377",
122
+ "state.json": "106bdc18361a8b2b9d2a2a71b1c4139d316a15d824af84aa36140a87ec23e55d"
123
+ }
124
+ },
125
+ "xsum-official-validation": {
126
+ "repo_id": "embedded-language-flows/xsum_validation_t5",
127
+ "revision": "b0b4f5de92434d308eceeb9e38fd3f8d7d2b6a9e",
128
+ "repo_type": "dataset",
129
+ "patterns": [
130
+ "*.arrow",
131
+ "*.json"
132
+ ],
133
+ "path": "data/elf/snapshots/xsum-official-validation/b0b4f5de92434d308eceeb9e38fd3f8d7d2b6a9e",
134
+ "sha256": {
135
+ "data-00000-of-00001.arrow": "375d55bc9d0872ff172e0f5cff4e8bd1757fb61efd8a1c0d94c05713bdd901d8",
136
+ "dataset_info.json": "56049acaa63e7257169adeffc460b9d339d349bced668af515cb8cbca0da6b76",
137
+ "state.json": "1c7b7b52a9e5959b450e41c9ef79069a493386c8990a236207cd507c91631b62"
138
+ }
139
+ },
140
+ "wmt14-raw": {
141
+ "repo_id": "wmt/wmt14",
142
+ "revision": "b199e406369ec1b7634206d3ded5ba45de2fe696",
143
+ "repo_type": "dataset",
144
+ "patterns": [
145
+ "de-en/validation-*.parquet",
146
+ "de-en/test-*.parquet"
147
+ ],
148
+ "path": "data/elf/snapshots/wmt14-raw/b199e406369ec1b7634206d3ded5ba45de2fe696",
149
+ "sha256": {
150
+ "de-en/test-00000-of-00001.parquet": "a3baab716f14f8abfa63e54995e31f035bb78b20c7943de72f3e1110b7ff35bb",
151
+ "de-en/validation-00000-of-00001.parquet": "c4a2a0e3b3e472f97f4eceb6d06724571f5390ac705768a02c1a9ad5c3d675ea"
152
+ }
153
+ },
154
+ "xsum-raw": {
155
+ "repo_id": "EdinburghNLP/xsum",
156
+ "revision": "7d4d486c2f8ef850b1a11aead99b894ff3dd7da9",
157
+ "repo_type": "dataset",
158
+ "patterns": [
159
+ "data/validation-*.parquet",
160
+ "data/test-*.parquet"
161
+ ],
162
+ "path": "data/elf/snapshots/xsum-raw/7d4d486c2f8ef850b1a11aead99b894ff3dd7da9",
163
+ "sha256": {
164
+ "data/test-00000-of-00001.parquet": "224e9dbc6fed987759c1954603b43cb280b8d475d78893779130aa707d967ed7",
165
+ "data/validation-00000-of-00001.parquet": "b7fc808c2dd3d1340349481aeef489e6eb8c22ff5739d8bce6d0f99e5ef8044d"
166
+ }
167
+ }
168
+ },
169
+ "source_commit": "b29d8833609e9ab7f67cd9da39435ac5cea04837",
170
+ "lock_sha256": "b801cd97165cfd78a9f41d6dcbaa4bbf51c60df794237e8a981f8b1520b896a5"
171
+ }
data/elf/owt-prefix.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/owt-prefix.manifest.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "elf-input-v1",
3
+ "count": 1024,
4
+ "sha256": "3df4bc0c58454494944c86e374388f83ef3a4c2168a6c06f6b70a217cc8e3958",
5
+ "task": "owt-prefix",
6
+ "protocol": "c64_text_t5_v1",
7
+ "source_sha256": "68907c7d4eb5104dbaea6d136a951635a11eb46c0f3e8f417d5f406e1ca834fc"
8
+ }
data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519/config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu_new",
3
+ "architectures": [
4
+ "GPT2LMHeadModel"
5
+ ],
6
+ "attn_pdrop": 0.1,
7
+ "bos_token_id": 50256,
8
+ "embd_pdrop": 0.1,
9
+ "eos_token_id": 50256,
10
+ "initializer_range": 0.02,
11
+ "layer_norm_epsilon": 1e-05,
12
+ "model_type": "gpt2",
13
+ "n_ctx": 1024,
14
+ "n_embd": 1280,
15
+ "n_head": 20,
16
+ "n_layer": 36,
17
+ "n_positions": 1024,
18
+ "resid_pdrop": 0.1,
19
+ "summary_activation": null,
20
+ "summary_first_dropout": 0.1,
21
+ "summary_proj_to_labels": true,
22
+ "summary_type": "cls_index",
23
+ "summary_use_proj": true,
24
+ "task_specific_params": {
25
+ "text-generation": {
26
+ "do_sample": true,
27
+ "max_length": 50
28
+ }
29
+ },
30
+ "vocab_size": 50257
31
+ }
data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519/tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"model_max_length": 1024}
data/elf/snapshots/gpt2-large/32b71b12589c2f8d625668d2335a01cac3249519/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e/config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu_new",
3
+ "architectures": [
4
+ "GPT2LMHeadModel"
5
+ ],
6
+ "attn_pdrop": 0.1,
7
+ "bos_token_id": 50256,
8
+ "embd_pdrop": 0.1,
9
+ "eos_token_id": 50256,
10
+ "initializer_range": 0.02,
11
+ "layer_norm_epsilon": 1e-05,
12
+ "model_type": "gpt2",
13
+ "n_ctx": 1024,
14
+ "n_embd": 768,
15
+ "n_head": 12,
16
+ "n_layer": 12,
17
+ "n_positions": 1024,
18
+ "resid_pdrop": 0.1,
19
+ "summary_activation": null,
20
+ "summary_first_dropout": 0.1,
21
+ "summary_proj_to_labels": true,
22
+ "summary_type": "cls_index",
23
+ "summary_use_proj": true,
24
+ "task_specific_params": {
25
+ "text-generation": {
26
+ "do_sample": true,
27
+ "max_length": 50
28
+ }
29
+ },
30
+ "vocab_size": 50257
31
+ }
data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e/tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"model_max_length": 1024}
data/elf/snapshots/gpt2/607a30d783dfa663caf39e06633721c8d4cfcd7e/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/snapshots/owt/146f84133c1389bfd4ef47f14ec7a955da22faa7/config.yml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ data_path: embedded-language-flows/openwebtext-t5
2
+ max_length: 1024
3
+ encoder_model_name: t5-small
4
+ latent_mean: 0.0
5
+ latent_std: 0.2
6
+ model: ELF-B
7
+ bottleneck_dim: 128
8
+ num_time_tokens: 4
9
+ num_self_cond_cfg_tokens: 4
10
+ num_model_mode_tokens: 4
11
+ denoiser_p_mean: -1.5
12
+ denoiser_p_std: 0.8
13
+ denoiser_noise_scale: 2.0
14
+ t_eps: 0.05
15
+ time_schedule: logit_normal
16
+ decoder_prob: 0.2
17
+ decoder_noise_scale: 5.0
18
+ decoder_p_mean: 0.8
19
+ decoder_p_std: 0.8
20
+ self_cond_prob: 0.5
21
+ epochs: 5
22
+ global_batch_size: 512
23
+ blr: 0.001
24
+ weight_decay: 0.0
25
+ warmup_epochs: 0.5
26
+ warmup_steps: -1
27
+ optimizer: muon
28
+ ema_decay1: 0.9999
29
+ sampling_configs_path: src/configs/sampling_configs/uncond_sampling_configs.yml
30
+ num_samples: 1000
31
+ log_freq: 100
32
+ save_freq: 1
33
+ save_last_freq: 1
34
+ eval_freq: 1
35
+ output_dir: outputs/elf_b-owt_torch
36
+ resume: null
37
+ use_wandb: true
38
+ wandb_project: elf
39
+ wandb_entity: null
40
+ wandb_run_name: elf_b-owt
41
+ seed: 42
42
+ hf_repo_id: null
data/elf/snapshots/t5/df1b051c49625cf57a3d0d8d3863ed4d13564fe4/config.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "T5ForConditionalGeneration"
4
+ ],
5
+ "d_ff": 2048,
6
+ "d_kv": 64,
7
+ "d_model": 512,
8
+ "decoder_start_token_id": 0,
9
+ "dropout_rate": 0.1,
10
+ "eos_token_id": 1,
11
+ "initializer_factor": 1.0,
12
+ "is_encoder_decoder": true,
13
+ "layer_norm_epsilon": 1e-06,
14
+ "model_type": "t5",
15
+ "n_positions": 512,
16
+ "num_heads": 8,
17
+ "num_layers": 6,
18
+ "output_past": true,
19
+ "pad_token_id": 0,
20
+ "relative_attention_num_buckets": 32,
21
+ "task_specific_params": {
22
+ "summarization": {
23
+ "early_stopping": true,
24
+ "length_penalty": 2.0,
25
+ "max_length": 200,
26
+ "min_length": 30,
27
+ "no_repeat_ngram_size": 3,
28
+ "num_beams": 4,
29
+ "prefix": "summarize: "
30
+ },
31
+ "translation_en_to_de": {
32
+ "early_stopping": true,
33
+ "max_length": 300,
34
+ "num_beams": 4,
35
+ "prefix": "translate English to German: "
36
+ },
37
+ "translation_en_to_fr": {
38
+ "early_stopping": true,
39
+ "max_length": 300,
40
+ "num_beams": 4,
41
+ "prefix": "translate English to French: "
42
+ },
43
+ "translation_en_to_ro": {
44
+ "early_stopping": true,
45
+ "max_length": 300,
46
+ "num_beams": 4,
47
+ "prefix": "translate English to Romanian: "
48
+ }
49
+ },
50
+ "vocab_size": 32128
51
+ }
data/elf/snapshots/t5/df1b051c49625cf57a3d0d8d3863ed4d13564fe4/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/snapshots/t5/df1b051c49625cf57a3d0d8d3863ed4d13564fe4/tokenizer_config.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<extra_id_0>",
4
+ "<extra_id_1>",
5
+ "<extra_id_2>",
6
+ "<extra_id_3>",
7
+ "<extra_id_4>",
8
+ "<extra_id_5>",
9
+ "<extra_id_6>",
10
+ "<extra_id_7>",
11
+ "<extra_id_8>",
12
+ "<extra_id_9>",
13
+ "<extra_id_10>",
14
+ "<extra_id_11>",
15
+ "<extra_id_12>",
16
+ "<extra_id_13>",
17
+ "<extra_id_14>",
18
+ "<extra_id_15>",
19
+ "<extra_id_16>",
20
+ "<extra_id_17>",
21
+ "<extra_id_18>",
22
+ "<extra_id_19>",
23
+ "<extra_id_20>",
24
+ "<extra_id_21>",
25
+ "<extra_id_22>",
26
+ "<extra_id_23>",
27
+ "<extra_id_24>",
28
+ "<extra_id_25>",
29
+ "<extra_id_26>",
30
+ "<extra_id_27>",
31
+ "<extra_id_28>",
32
+ "<extra_id_29>",
33
+ "<extra_id_30>",
34
+ "<extra_id_31>",
35
+ "<extra_id_32>",
36
+ "<extra_id_33>",
37
+ "<extra_id_34>",
38
+ "<extra_id_35>",
39
+ "<extra_id_36>",
40
+ "<extra_id_37>",
41
+ "<extra_id_38>",
42
+ "<extra_id_39>",
43
+ "<extra_id_40>",
44
+ "<extra_id_41>",
45
+ "<extra_id_42>",
46
+ "<extra_id_43>",
47
+ "<extra_id_44>",
48
+ "<extra_id_45>",
49
+ "<extra_id_46>",
50
+ "<extra_id_47>",
51
+ "<extra_id_48>",
52
+ "<extra_id_49>",
53
+ "<extra_id_50>",
54
+ "<extra_id_51>",
55
+ "<extra_id_52>",
56
+ "<extra_id_53>",
57
+ "<extra_id_54>",
58
+ "<extra_id_55>",
59
+ "<extra_id_56>",
60
+ "<extra_id_57>",
61
+ "<extra_id_58>",
62
+ "<extra_id_59>",
63
+ "<extra_id_60>",
64
+ "<extra_id_61>",
65
+ "<extra_id_62>",
66
+ "<extra_id_63>",
67
+ "<extra_id_64>",
68
+ "<extra_id_65>",
69
+ "<extra_id_66>",
70
+ "<extra_id_67>",
71
+ "<extra_id_68>",
72
+ "<extra_id_69>",
73
+ "<extra_id_70>",
74
+ "<extra_id_71>",
75
+ "<extra_id_72>",
76
+ "<extra_id_73>",
77
+ "<extra_id_74>",
78
+ "<extra_id_75>",
79
+ "<extra_id_76>",
80
+ "<extra_id_77>",
81
+ "<extra_id_78>",
82
+ "<extra_id_79>",
83
+ "<extra_id_80>",
84
+ "<extra_id_81>",
85
+ "<extra_id_82>",
86
+ "<extra_id_83>",
87
+ "<extra_id_84>",
88
+ "<extra_id_85>",
89
+ "<extra_id_86>",
90
+ "<extra_id_87>",
91
+ "<extra_id_88>",
92
+ "<extra_id_89>",
93
+ "<extra_id_90>",
94
+ "<extra_id_91>",
95
+ "<extra_id_92>",
96
+ "<extra_id_93>",
97
+ "<extra_id_94>",
98
+ "<extra_id_95>",
99
+ "<extra_id_96>",
100
+ "<extra_id_97>",
101
+ "<extra_id_98>",
102
+ "<extra_id_99>"
103
+ ],
104
+ "clean_up_tokenization_spaces": true,
105
+ "eos_token": "</s>",
106
+ "extra_ids": 100,
107
+ "model_max_length": 512,
108
+ "pad_token": "<pad>",
109
+ "tokenizer_class": "T5Tokenizer",
110
+ "unk_token": "<unk>"
111
+ }
data/elf/snapshots/wmt14-official-validation/bcc92bda4b07c329354843724c9d9ea740f30685/dataset_info.json ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "parquet",
3
+ "citation": "",
4
+ "config_name": "de-en",
5
+ "dataset_name": "wmt14",
6
+ "dataset_size": 1359920533,
7
+ "description": "",
8
+ "download_checksums": {
9
+ "hf://datasets/wmt/wmt14@b199e406369ec1b7634206d3ded5ba45de2fe696/de-en/train-00000-of-00003.parquet": {
10
+ "num_bytes": 279527247,
11
+ "checksum": null
12
+ },
13
+ "hf://datasets/wmt/wmt14@b199e406369ec1b7634206d3ded5ba45de2fe696/de-en/train-00001-of-00003.parquet": {
14
+ "num_bytes": 264970514,
15
+ "checksum": null
16
+ },
17
+ "hf://datasets/wmt/wmt14@b199e406369ec1b7634206d3ded5ba45de2fe696/de-en/train-00002-of-00003.parquet": {
18
+ "num_bytes": 272987200,
19
+ "checksum": null
20
+ },
21
+ "hf://datasets/wmt/wmt14@b199e406369ec1b7634206d3ded5ba45de2fe696/de-en/validation-00000-of-00001.parquet": {
22
+ "num_bytes": 473798,
23
+ "checksum": null
24
+ },
25
+ "hf://datasets/wmt/wmt14@b199e406369ec1b7634206d3ded5ba45de2fe696/de-en/test-00000-of-00001.parquet": {
26
+ "num_bytes": 508753,
27
+ "checksum": null
28
+ }
29
+ },
30
+ "download_size": 818467512,
31
+ "features": {
32
+ "input": {
33
+ "dtype": "string",
34
+ "_type": "Value"
35
+ },
36
+ "target": {
37
+ "dtype": "string",
38
+ "_type": "Value"
39
+ },
40
+ "index": {
41
+ "dtype": "int64",
42
+ "_type": "Value"
43
+ },
44
+ "condition_input_ids": {
45
+ "feature": {
46
+ "dtype": "int64",
47
+ "_type": "Value"
48
+ },
49
+ "_type": "List"
50
+ },
51
+ "condition_sequence_length": {
52
+ "dtype": "int64",
53
+ "_type": "Value"
54
+ },
55
+ "input_ids": {
56
+ "feature": {
57
+ "dtype": "int32",
58
+ "_type": "Value"
59
+ },
60
+ "_type": "List"
61
+ },
62
+ "sequence_length": {
63
+ "dtype": "int64",
64
+ "_type": "Value"
65
+ }
66
+ },
67
+ "homepage": "",
68
+ "license": "",
69
+ "size_in_bytes": 2178388045,
70
+ "splits": {
71
+ "train": {
72
+ "name": "train",
73
+ "num_bytes": 1358406800,
74
+ "num_examples": 4508785,
75
+ "shard_lengths": [
76
+ 1521929,
77
+ 1721928,
78
+ 1264928
79
+ ],
80
+ "dataset_name": "wmt14"
81
+ },
82
+ "validation": {
83
+ "name": "validation",
84
+ "num_bytes": 736407,
85
+ "num_examples": 3000,
86
+ "dataset_name": "wmt14"
87
+ },
88
+ "test": {
89
+ "name": "test",
90
+ "num_bytes": 777326,
91
+ "num_examples": 3003,
92
+ "dataset_name": "wmt14"
93
+ }
94
+ },
95
+ "version": {
96
+ "version_str": "0.0.0",
97
+ "major": 0,
98
+ "minor": 0,
99
+ "patch": 0
100
+ }
101
+ }
data/elf/snapshots/wmt14-official-validation/bcc92bda4b07c329354843724c9d9ea740f30685/state.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00001.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "5f50308c846b2747",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_output_all_columns": false,
12
+ "_split": null
13
+ }
data/elf/snapshots/wmt14/93ce98315a2dec985cdefb8d8e62ab618e896ec4/config.yml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ data_path: embedded-language-flows/wmt14_de-en_train_t5
2
+ eval_data_path: embedded-language-flows/wmt14_de-en_validation_t5
3
+ max_length: 128
4
+ max_input_length: 64
5
+ pad_token: eos
6
+ encoder_model_name: t5-small
7
+ latent_mean: 0.0
8
+ latent_std: 0.2
9
+ model: ELF-B
10
+ bottleneck_dim: 128
11
+ num_time_tokens: 4
12
+ num_self_cond_cfg_tokens: 4
13
+ num_model_mode_tokens: 4
14
+ denoiser_p_mean: -1.5
15
+ denoiser_p_std: 0.8
16
+ denoiser_noise_scale: 2.0
17
+ t_eps: 0.05
18
+ time_schedule: logit_normal
19
+ decoder_prob: 0.2
20
+ decoder_noise_scale: 5.0
21
+ decoder_p_mean: 0.8
22
+ decoder_p_std: 0.8
23
+ label_drop_prob: 0.1
24
+ self_cond_prob: 0.5
25
+ epochs: 100
26
+ global_batch_size: 512
27
+ blr: 0.001
28
+ weight_decay: 0.0
29
+ warmup_steps: 5000
30
+ optimzier: muon
31
+ ema_decay1: 0.9999
32
+ sampling_configs_path: src/configs/sampling_configs/cond_sampling_configs.yml
33
+ num_samples: 5000
34
+ log_freq: 100
35
+ save_freq: 10
36
+ save_last_freq: 1000
37
+ eval_freq: 10
38
+ output_dir: outputs/elf_b-de-en_from_torch
39
+ resume: null
40
+ use_wandb: true
41
+ wandb_project: elf
42
+ wandb_entity: null
43
+ wandb_run_name: elf_b-wmt-de-en
44
+ seed: 42
45
+ hf_repo_id: null
data/elf/snapshots/xsum-official-validation/b0b4f5de92434d308eceeb9e38fd3f8d7d2b6a9e/dataset_info.json ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "parquet",
3
+ "citation": "",
4
+ "config_name": "default",
5
+ "dataset_name": "xsum",
6
+ "dataset_size": 532255381,
7
+ "description": "",
8
+ "download_checksums": {
9
+ "hf://datasets/EdinburghNLP/xsum@7d4d486c2f8ef850b1a11aead99b894ff3dd7da9/data/train-00000-of-00001.parquet": {
10
+ "num_bytes": 299612457,
11
+ "checksum": null
12
+ },
13
+ "hf://datasets/EdinburghNLP/xsum@7d4d486c2f8ef850b1a11aead99b894ff3dd7da9/data/validation-00000-of-00001.parquet": {
14
+ "num_bytes": 16447668,
15
+ "checksum": null
16
+ },
17
+ "hf://datasets/EdinburghNLP/xsum@7d4d486c2f8ef850b1a11aead99b894ff3dd7da9/data/test-00000-of-00001.parquet": {
18
+ "num_bytes": 16731226,
19
+ "checksum": null
20
+ }
21
+ },
22
+ "download_size": 332791351,
23
+ "features": {
24
+ "input": {
25
+ "dtype": "string",
26
+ "_type": "Value"
27
+ },
28
+ "target": {
29
+ "dtype": "string",
30
+ "_type": "Value"
31
+ },
32
+ "index": {
33
+ "dtype": "int64",
34
+ "_type": "Value"
35
+ },
36
+ "condition_input_ids": {
37
+ "feature": {
38
+ "dtype": "int64",
39
+ "_type": "Value"
40
+ },
41
+ "_type": "List"
42
+ },
43
+ "condition_sequence_length": {
44
+ "dtype": "int64",
45
+ "_type": "Value"
46
+ },
47
+ "input_ids": {
48
+ "feature": {
49
+ "dtype": "int32",
50
+ "_type": "Value"
51
+ },
52
+ "_type": "List"
53
+ },
54
+ "sequence_length": {
55
+ "dtype": "int64",
56
+ "_type": "Value"
57
+ }
58
+ },
59
+ "homepage": "",
60
+ "license": "",
61
+ "size_in_bytes": 865046732,
62
+ "splits": {
63
+ "train": {
64
+ "name": "train",
65
+ "num_bytes": 479206363,
66
+ "num_examples": 204045,
67
+ "dataset_name": "xsum"
68
+ },
69
+ "validation": {
70
+ "name": "validation",
71
+ "num_bytes": 26292877,
72
+ "num_examples": 11332,
73
+ "dataset_name": "xsum"
74
+ },
75
+ "test": {
76
+ "name": "test",
77
+ "num_bytes": 26756141,
78
+ "num_examples": 11334,
79
+ "dataset_name": "xsum"
80
+ }
81
+ },
82
+ "version": {
83
+ "version_str": "0.0.0",
84
+ "major": 0,
85
+ "minor": 0,
86
+ "patch": 0
87
+ }
88
+ }
data/elf/snapshots/xsum-official-validation/b0b4f5de92434d308eceeb9e38fd3f8d7d2b6a9e/state.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00001.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "f934ca16a682895c",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_output_all_columns": false,
12
+ "_split": null
13
+ }
data/elf/snapshots/xsum/aca4abd1c7ff5f841f0e2a3ec8a18b0a927927f1/config.yml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ data_path: embedded-language-flows/xsum_train_t5
2
+ eval_data_path: embedded-language-flows/xsum_validation_t5
3
+ max_length: 1088
4
+ max_input_length: 1024
5
+ pad_token: eos
6
+ encoder_model_name: t5-small
7
+ latent_mean: 0.0
8
+ latent_std: 0.2
9
+ model: ELF-B
10
+ bottleneck_dim: 128
11
+ num_time_tokens: 4
12
+ num_self_cond_cfg_tokens: 4
13
+ num_model_mode_tokens: 4
14
+ denoiser_p_mean: -1.5
15
+ denoiser_p_std: 0.8
16
+ denoiser_noise_scale: 2.0
17
+ t_eps: 0.05
18
+ time_schedule: logit_normal
19
+ decoder_prob: 0.2
20
+ decoder_noise_scale: 5.0
21
+ decoder_p_mean: 0.8
22
+ decoder_p_std: 0.8
23
+ label_drop_prob: 0.1
24
+ self_cond_prob: 0.5
25
+ epochs: 100
26
+ global_batch_size: 512
27
+ blr: 0.001
28
+ weight_decay: 0.0
29
+ warmup_steps: 5000
30
+ optimizer: muon
31
+ ema_decay1: 0.9999
32
+ sampling_configs_path: src/configs/sampling_configs/cond_sampling_configs.yml
33
+ num_samples: 5000
34
+ log_freq: 100
35
+ save_freq: 10
36
+ save_last_freq: 1000
37
+ eval_freq: 10
38
+ output_dir: outputs/elf_b-xsum_torch
39
+ resume: null
40
+ use_wandb: true
41
+ wandb_project: elf
42
+ wandb_entity: null
43
+ wandb_run_name: elf_b-xsum
44
+ seed: 42
45
+ hf_repo_id: null
data/elf/wmt14-official-validation.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/wmt14-official-validation.manifest.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "elf-input-v1",
3
+ "count": 3000,
4
+ "sha256": "1f40387571aa2d3543199a414a7539fcb6a2b6eae18e2d3d3d5765c7480f8e30",
5
+ "task": "wmt14",
6
+ "split": "official-validation",
7
+ "asset": {
8
+ "repo_id": "embedded-language-flows/wmt14_de-en_validation_t5",
9
+ "revision": "bcc92bda4b07c329354843724c9d9ea740f30685",
10
+ "repo_type": "dataset",
11
+ "patterns": [
12
+ "*.arrow",
13
+ "*.json"
14
+ ]
15
+ },
16
+ "reader": "pyarrow_ipc_v1"
17
+ }
data/elf/wmt14-test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/wmt14-test.manifest.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "elf-input-v1",
3
+ "count": 3003,
4
+ "sha256": "df5bb91d2d3ab7a2f85cb278c0d70fbf419c58aee8b2435ea488359941a9dc5a",
5
+ "task": "wmt14",
6
+ "split": "test",
7
+ "asset": {
8
+ "repo_id": "wmt/wmt14",
9
+ "revision": "b199e406369ec1b7634206d3ded5ba45de2fe696",
10
+ "repo_type": "dataset",
11
+ "patterns": [
12
+ "de-en/validation-*.parquet",
13
+ "de-en/test-*.parquet"
14
+ ]
15
+ },
16
+ "reader": "pyarrow_parquet_v1"
17
+ }
data/elf/wmt14-validation.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/elf/wmt14-validation.manifest.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "elf-input-v1",
3
+ "count": 3000,
4
+ "sha256": "ec0b7b23c62af5c941d2d6d6eda75588d0e1d99e13a68e580ac0f37583687680",
5
+ "task": "wmt14",
6
+ "split": "validation",
7
+ "asset": {
8
+ "repo_id": "wmt/wmt14",
9
+ "revision": "b199e406369ec1b7634206d3ded5ba45de2fe696",
10
+ "repo_type": "dataset",
11
+ "patterns": [
12
+ "de-en/validation-*.parquet",
13
+ "de-en/test-*.parquet"
14
+ ]
15
+ },
16
+ "reader": "pyarrow_parquet_v1"
17
+ }