data-archetype commited on
Commit
263b26f
·
verified ·
1 Parent(s): 0957ad9

dflow_2b 0.22

Browse files
MANUAL.md CHANGED
@@ -56,6 +56,46 @@ pip install -e dflow_2b
56
  `diffusers` is needed only for the optional
57
  [diffusers wrapper](#diffusers-wrapper).
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  ### Compilation
60
 
61
  The denoiser, the text encoder and the autoencoder are compiled with
@@ -1071,7 +1111,7 @@ VAEEncode nodes.
1071
  | `source` | `bundled` | `bundled` reads the weights in the node folder; `local_dir` another folder; `hub` a Hugging Face repository |
1072
  | `local_dir` | empty | Release folder, for the `local_dir` source |
1073
  | `repository` | `data-archetype/dflow_2b` | Repository id, for the `hub` source |
1074
- | `revision` | empty | Hub revision; empty for `main` |
1075
  | `compile_model` | on | Compile the model with `torch.compile` |
1076
  | `cache_dir` | empty | Hugging Face cache directory; empty for the default |
1077
 
 
56
  `diffusers` is needed only for the optional
57
  [diffusers wrapper](#diffusers-wrapper).
58
 
59
+ ### Updating and older versions
60
+
61
+ Each release is tagged on the Hub with its version, such as `v0.21`;
62
+ [RELEASES.md](RELEASES.md) lists them.
63
+
64
+ To update, run the download again into the same folder and reinstall the
65
+ requirements. Only the files that changed are downloaded; files a newer release
66
+ no longer has stay in the folder. Then restart ComfyUI:
67
+
68
+ ```bash
69
+ cd ComfyUI/custom_nodes
70
+ hf download data-archetype/dflow_2b --local-dir dflow_2b
71
+ pip install -r dflow_2b/requirements.txt
72
+ ```
73
+
74
+ To try the weights of an older release with the installed nodes, set the DFlow
75
+ Loader's `source` to `hub` and its `revision` to the tag, such as `v0.21`. The
76
+ weights download into the Hugging Face cache. In Python, pass the tag as
77
+ `revision`:
78
+
79
+ ```python
80
+ pipe = DFlowPipeline.from_pretrained("data-archetype/dflow_2b", revision="v0.21")
81
+ ```
82
+
83
+ A saved ComfyUI workflow keeps the loader's source and revision, and images from
84
+ the Python pipeline name the release of their weights in the `model` field of
85
+ their PNG metadata. To reproduce an older release's images exactly, or to start
86
+ from a clean folder, install the release whole, replacing the folder:
87
+
88
+ ```bash
89
+ cd ComfyUI/custom_nodes
90
+ rm -rf dflow_2b
91
+ hf download data-archetype/dflow_2b --revision v0.21 --local-dir dflow_2b
92
+ pip install -r dflow_2b/requirements.txt
93
+ ```
94
+
95
+ Keep a single copy in `custom_nodes`: ComfyUI loads every folder there, and two
96
+ copies register the same nodes. For the Python package, run the same `hf
97
+ download` command where the folder is; the editable install uses the new files.
98
+
99
  ### Compilation
100
 
101
  The denoiser, the text encoder and the autoencoder are compiled with
 
1111
  | `source` | `bundled` | `bundled` reads the weights in the node folder; `local_dir` another folder; `hub` a Hugging Face repository |
1112
  | `local_dir` | empty | Release folder, for the `local_dir` source |
1113
  | `repository` | `data-archetype/dflow_2b` | Repository id, for the `hub` source |
1114
+ | `revision` | empty | Hub revision, such as a release tag (`v0.21`); empty for `main` |
1115
  | `compile_model` | on | Compile the model with `torch.compile` |
1116
  | `cache_dir` | empty | Hugging Face cache directory; empty for the default |
1117
 
README.md CHANGED
@@ -17,7 +17,7 @@ base_model:
17
  # dflow_2b
18
 
19
  > [!WARNING]
20
- > **Preview, version 0.215.** The model is still training, so checkpoints and
21
  > behaviour will change between releases. Generations are still uneven, expect
22
  > some seed hunting.
23
 
@@ -81,6 +81,9 @@ hf download data-archetype/dflow_2b --local-dir dflow_2b
81
  pip install -r dflow_2b/requirements.txt
82
  ```
83
 
 
 
 
84
  Load `dflow_2b/comfyui/workflows/dflow_default.json`, or drag any image from the
85
  [gallery](GALLERY.md) onto the canvas to get the workflow that made it. Start
86
  ComfyUI with `--preview-method auto` for live previews.
@@ -171,6 +174,6 @@ Third-party material is listed in [`ATTRIBUTION.md`](ATTRIBUTION.md).
171
  author = {{Data Archetype}},
172
  year = {2026},
173
  url = {https://huggingface.co/data-archetype/dflow_2b},
174
- note = {Preview release, version 0.215}
175
  }
176
  ```
 
17
  # dflow_2b
18
 
19
  > [!WARNING]
20
+ > **Preview, version 0.22.** The model is still training, so checkpoints and
21
  > behaviour will change between releases. Generations are still uneven, expect
22
  > some seed hunting.
23
 
 
81
  pip install -r dflow_2b/requirements.txt
82
  ```
83
 
84
+ To update later, run the same `hf download` command again. The manual explains
85
+ how to [install an older release](MANUAL.md#updating-and-older-versions).
86
+
87
  Load `dflow_2b/comfyui/workflows/dflow_default.json`, or drag any image from the
88
  [gallery](GALLERY.md) onto the canvas to get the workflow that made it. Start
89
  ComfyUI with `--preview-method auto` for live previews.
 
174
  author = {{Data Archetype}},
175
  year = {2026},
176
  url = {https://huggingface.co/data-archetype/dflow_2b},
177
+ note = {Preview release, version 0.22}
178
  }
179
  ```
RELEASES.md CHANGED
@@ -3,6 +3,18 @@
3
  [Model card](README.md) · [Manual](MANUAL.md) ·
4
  [Technical report](TECHNICAL_REPORT.md) · [Example gallery](GALLERY.md)
5
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  ## 0.215
7
 
8
  Same weights as 0.21. MOSS-Image layout prompts and editable drafts now work
 
3
  [Model card](README.md) · [Manual](MANUAL.md) ·
4
  [Technical report](TECHNICAL_REPORT.md) · [Example gallery](GALLERY.md)
5
 
6
+ Each release is tagged on the Hub with its version (`v0.22`, `v0.215`, `v0.21`,
7
+ `v0.2`). The manual explains how to
8
+ [update or install an older release](MANUAL.md#updating-and-older-versions).
9
+
10
+ ## 0.22
11
+
12
+ Checkpoint update: the average, with equal weights, of the EMAs at training
13
+ steps 593,000 and 594,000.
14
+
15
+ The weights of every earlier release load with this version: set the DFlow
16
+ Loader's `source` to `hub` and its `revision` to a release tag, such as `v0.21`.
17
+
18
  ## 0.215
19
 
20
  Same weights as 0.21. MOSS-Image layout prompts and editable drafts now work
TECHNICAL_REPORT.md CHANGED
@@ -573,7 +573,7 @@ objective.
573
  | Batch size | 128, with gradient accumulation |
574
  | Precision | bfloat16 autocast |
575
  | EMA | Updated every 10 steps; half-life 4,000 steps, 2,000 from step 400,000 |
576
- | Hardware | One GPU |
577
 
578
  At 512 px a batch is accumulated over 4 micro-batches. At 1024 px it is
579
  accumulated over 16, or over 24 when the batch contains very long captions.
@@ -596,7 +596,8 @@ images of one shape.
596
  Structured layout captions were introduced in the 1024 px stage and make up
597
  about 10% of its recent samples.
598
 
599
- The released weights are the EMA at step 583,000.
 
600
 
601
  ## Limitations
602
 
 
573
  | Batch size | 128, with gradient accumulation |
574
  | Precision | bfloat16 autocast |
575
  | EMA | Updated every 10 steps; half-life 4,000 steps, 2,000 from step 400,000 |
576
+ | Hardware | One GH200 |
577
 
578
  At 512 px a batch is accumulated over 4 micro-batches. At 1024 px it is
579
  accumulated over 16, or over 24 when the batch contains very long captions.
 
596
  Structured layout captions were introduced in the 1024 px stage and make up
597
  about 10% of its recent samples.
598
 
599
+ The released weights are the average, with equal weights, of the EMAs at steps
600
+ 593,000 and 594,000.
601
 
602
  ## Limitations
603
 
comfyui/nodes.py CHANGED
@@ -279,7 +279,11 @@ class DFlowLoader:
279
  ),
280
  "revision": (
281
  "STRING",
282
- {"default": "", "tooltip": "Hub revision; empty for main."},
 
 
 
 
283
  ),
284
  "compile_model": _bool(True, "torch.compile the model (faster)."),
285
  "cache_dir": (
 
279
  ),
280
  "revision": (
281
  "STRING",
282
+ {
283
+ "default": "",
284
+ "tooltip": "Hub revision, such as a release tag (v0.21); "
285
+ "empty for main.",
286
+ },
287
  ),
288
  "compile_model": _bool(True, "torch.compile the model (faster)."),
289
  "cache_dir": (
dflow/loading.py CHANGED
@@ -4,8 +4,9 @@ A release directory holds ``model.safetensors`` (every weight, public names,
4
  see ``precision``), ``config.json`` (architecture constants) and
5
  ``release.json`` (version and counts). Loading checks, before any weight
6
  reaches a module: the config against this package's architecture, the
7
- version, the tensor and parameter counts, every name (none missing, none
8
- extra), every shape and every storage dtype. The denoiser then loads with
 
9
  ``strict=True``.
10
 
11
  Public names: ``denoiser.<module path>`` for the denoiser (``DFlowModel``'s
@@ -32,7 +33,7 @@ from .precision import (
32
  denoiser_storage_dtype,
33
  text_adapter_storage_dtypes,
34
  )
35
- from .version import MODEL_VERSION
36
 
37
  MODEL_FILENAME = "model.safetensors"
38
  CONFIG_FILENAME = "config.json"
@@ -89,12 +90,13 @@ def validate_public_tensors(tensors: dict[str, Tensor], config: DFlowConfig) ->
89
  )
90
 
91
 
92
- def _validate_release_metadata(path: Path, tensors: dict[str, Tensor]) -> None:
93
- """Check ``release.json``'s version and counts against the weight file.
94
 
95
  Raises:
96
  FileNotFoundError: If ``release.json`` is missing.
97
- ValueError: If the version or a count differs.
 
98
  """
99
 
100
  if not path.is_file():
@@ -110,10 +112,37 @@ def _validate_release_metadata(path: Path, tensors: dict[str, Tensor]) -> None:
110
  raise ValueError(
111
  f"{path} must hold version, tensor_count and parameter_count"
112
  )
113
- if version != MODEL_VERSION:
114
  raise ValueError(
115
- f"{path} is release {version}; this package loads {MODEL_VERSION}"
 
116
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  found_parameters = sum(tensor.numel() for tensor in tensors.values())
118
  if (tensor_count, parameter_count) != (len(tensors), found_parameters):
119
  raise ValueError(
 
4
  see ``precision``), ``config.json`` (architecture constants) and
5
  ``release.json`` (version and counts). Loading checks, before any weight
6
  reaches a module: the config against this package's architecture, the
7
+ version (one of ``LOADABLE_WEIGHT_VERSIONS``), the tensor and parameter
8
+ counts, every name (none missing, none extra), every shape and every storage
9
+ dtype. The denoiser then loads with
10
  ``strict=True``.
11
 
12
  Public names: ``denoiser.<module path>`` for the denoiser (``DFlowModel``'s
 
33
  denoiser_storage_dtype,
34
  text_adapter_storage_dtypes,
35
  )
36
+ from .version import LOADABLE_WEIGHT_VERSIONS, MODEL_VERSION
37
 
38
  MODEL_FILENAME = "model.safetensors"
39
  CONFIG_FILENAME = "config.json"
 
90
  )
91
 
92
 
93
+ def _read_release_metadata(path: Path) -> tuple[str, int, int]:
94
+ """``release.json``'s version, tensor count and parameter count.
95
 
96
  Raises:
97
  FileNotFoundError: If ``release.json`` is missing.
98
+ ValueError: If a field is missing, or the version's weights are not
99
+ loadable by this package.
100
  """
101
 
102
  if not path.is_file():
 
112
  raise ValueError(
113
  f"{path} must hold version, tensor_count and parameter_count"
114
  )
115
+ if version not in LOADABLE_WEIGHT_VERSIONS:
116
  raise ValueError(
117
+ f"{path} is release {version}; this package ({MODEL_VERSION}) loads "
118
+ f"the weights of releases {', '.join(LOADABLE_WEIGHT_VERSIONS)}"
119
  )
120
+ return version, tensor_count, parameter_count
121
+
122
+
123
+ def read_release_version(directory: Path) -> str:
124
+ """The release version of a release directory's weights.
125
+
126
+ Raises:
127
+ FileNotFoundError: If ``release.json`` is missing.
128
+ ValueError: If it is malformed or the version is not loadable.
129
+ """
130
+
131
+ version, _tensors, _parameters = _read_release_metadata(
132
+ directory / RELEASE_FILENAME
133
+ )
134
+ return version
135
+
136
+
137
+ def _validate_release_metadata(path: Path, tensors: dict[str, Tensor]) -> None:
138
+ """Check ``release.json``'s version and counts against the weight file.
139
+
140
+ Raises:
141
+ FileNotFoundError: If ``release.json`` is missing.
142
+ ValueError: If the version is not loadable or a count differs.
143
+ """
144
+
145
+ _version, tensor_count, parameter_count = _read_release_metadata(path)
146
  found_parameters = sum(tensor.numel() for tensor in tensors.values())
147
  if (tensor_count, parameter_count) != (len(tensors), found_parameters):
148
  raise ValueError(
dflow/pipeline.py CHANGED
@@ -20,11 +20,16 @@ from .inference import (
20
  ImageToImage,
21
  LatentCallback,
22
  )
23
- from .loading import CONFIG_FILENAME, load_dflow_denoiser, load_text_adapter_tensors
 
 
 
 
 
24
  from .preview import preview_images
25
  from .text_conditioning import DFlowTextEncoder, TextAdapter
26
  from .vae import DFlowVae
27
- from .version import MODEL_VERSION, __version__
28
 
29
  REPOSITORY = "data-archetype/dflow_2b"
30
  TEXT_ENCODER_DIRNAME = "text_encoder"
@@ -47,20 +52,21 @@ def resolve_release_directory(
47
 
48
  A ``Path`` or an existing directory is used as it is; any other string
49
  with a ``/`` is a Hub repository id whose weights and text encoder are
50
- downloaded.
51
 
52
  Raises:
53
  FileNotFoundError: If a ``Path`` names no directory, or a string is
54
  neither a directory nor a Hub id.
 
55
  """
56
 
57
  if isinstance(path_or_repository, Path):
58
  if not path_or_repository.is_dir():
59
  raise FileNotFoundError(f"No release directory at {path_or_repository}.")
60
- return path_or_repository
61
  local = Path(path_or_repository).expanduser()
62
  if local.is_dir():
63
- return local
64
  if "/" not in path_or_repository:
65
  raise FileNotFoundError(
66
  f"No release folder {path_or_repository!r} here; pass its path or the "
@@ -76,6 +82,22 @@ def resolve_release_directory(
76
  )
77
 
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  @dataclass(frozen=True)
80
  class DFlowComponents:
81
  """The loaded parts of the model.
@@ -84,11 +106,13 @@ class DFlowComponents:
84
  engine: Denoiser and text encoder.
85
  vae: The dinac3_96 autoencoder.
86
  compiled: Whether the blocks were compiled.
 
87
  """
88
 
89
  engine: DFlowEngine
90
  vae: DFlowVae
91
  compiled: bool
 
92
 
93
  @classmethod
94
  def from_pretrained(
@@ -140,6 +164,7 @@ class DFlowComponents:
140
  engine=DFlowEngine(model, text_encoder, policy=policy),
141
  vae=vae,
142
  compiled=compile,
 
143
  )
144
 
145
 
@@ -249,7 +274,10 @@ class DFlowPipeline:
249
  images = preview_images(rgb)
250
  for index, image in enumerate(images):
251
  image.info[PNG_METADATA_KEY] = generation_metadata(
252
- prompts[index], chosen, batch_index=index
 
 
 
253
  )
254
  return DFlowOutput(images=images, tensors=None, settings=chosen)
255
  case _ as unreachable:
@@ -270,12 +298,17 @@ class DFlowPipeline:
270
 
271
 
272
  def generation_metadata(
273
- prompt: str, settings: GenerationSettings, *, batch_index: int
 
 
 
 
274
  ) -> str:
275
- """JSON text describing one generated image."""
 
276
 
277
  payload = {
278
- "model": f"dflow_2b {MODEL_VERSION}",
279
  "package": __version__,
280
  "prompt": prompt,
281
  "batch_index": batch_index,
 
20
  ImageToImage,
21
  LatentCallback,
22
  )
23
+ from .loading import (
24
+ CONFIG_FILENAME,
25
+ load_dflow_denoiser,
26
+ load_text_adapter_tensors,
27
+ read_release_version,
28
+ )
29
  from .preview import preview_images
30
  from .text_conditioning import DFlowTextEncoder, TextAdapter
31
  from .vae import DFlowVae
32
+ from .version import __version__
33
 
34
  REPOSITORY = "data-archetype/dflow_2b"
35
  TEXT_ENCODER_DIRNAME = "text_encoder"
 
52
 
53
  A ``Path`` or an existing directory is used as it is; any other string
54
  with a ``/`` is a Hub repository id whose weights and text encoder are
55
+ downloaded at ``revision``.
56
 
57
  Raises:
58
  FileNotFoundError: If a ``Path`` names no directory, or a string is
59
  neither a directory nor a Hub id.
60
+ ValueError: If ``revision`` is given with a local directory.
61
  """
62
 
63
  if isinstance(path_or_repository, Path):
64
  if not path_or_repository.is_dir():
65
  raise FileNotFoundError(f"No release directory at {path_or_repository}.")
66
+ return _local_release(path_or_repository, revision)
67
  local = Path(path_or_repository).expanduser()
68
  if local.is_dir():
69
+ return _local_release(local, revision)
70
  if "/" not in path_or_repository:
71
  raise FileNotFoundError(
72
  f"No release folder {path_or_repository!r} here; pass its path or the "
 
82
  )
83
 
84
 
85
+ def _local_release(directory: Path, revision: str | None) -> Path:
86
+ """Return a local release directory, which has no Hub revision.
87
+
88
+ Raises:
89
+ ValueError: If ``revision`` is given.
90
+ """
91
+
92
+ if revision is not None:
93
+ raise ValueError(
94
+ f"Revision {revision!r} selects a Hub release, but {directory} is a "
95
+ "local folder. Load the repository id data-archetype/dflow_2b (the "
96
+ "DFlow Loader's hub source) to use a revision."
97
+ )
98
+ return directory
99
+
100
+
101
  @dataclass(frozen=True)
102
  class DFlowComponents:
103
  """The loaded parts of the model.
 
106
  engine: Denoiser and text encoder.
107
  vae: The dinac3_96 autoencoder.
108
  compiled: Whether the blocks were compiled.
109
+ weights_version: The release the weights come from (``release.json``).
110
  """
111
 
112
  engine: DFlowEngine
113
  vae: DFlowVae
114
  compiled: bool
115
+ weights_version: str
116
 
117
  @classmethod
118
  def from_pretrained(
 
164
  engine=DFlowEngine(model, text_encoder, policy=policy),
165
  vae=vae,
166
  compiled=compile,
167
+ weights_version=read_release_version(directory),
168
  )
169
 
170
 
 
274
  images = preview_images(rgb)
275
  for index, image in enumerate(images):
276
  image.info[PNG_METADATA_KEY] = generation_metadata(
277
+ prompts[index],
278
+ chosen,
279
+ batch_index=index,
280
+ weights_version=self.components.weights_version,
281
  )
282
  return DFlowOutput(images=images, tensors=None, settings=chosen)
283
  case _ as unreachable:
 
298
 
299
 
300
  def generation_metadata(
301
+ prompt: str,
302
+ settings: GenerationSettings,
303
+ *,
304
+ batch_index: int,
305
+ weights_version: str,
306
  ) -> str:
307
+ """JSON text describing one generated image; ``model`` names the release
308
+ of the weights, ``package`` the code's version."""
309
 
310
  payload = {
311
+ "model": f"dflow_2b {weights_version}",
312
  "package": __version__,
313
  "prompt": prompt,
314
  "batch_index": batch_index,
dflow/version.py CHANGED
@@ -1,4 +1,7 @@
1
  """Package and model version."""
2
 
3
- __version__ = "0.215.0"
4
- MODEL_VERSION = "0.215"
 
 
 
 
1
  """Package and model version."""
2
 
3
+ __version__ = "0.22.0"
4
+ MODEL_VERSION = "0.22"
5
+ # Releases whose weights this package loads: they share one architecture and
6
+ # storage layout (each release's config.json is still checked against it).
7
+ LOADABLE_WEIGHT_VERSIONS = ("0.2", "0.21", "0.215", "0.22")
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:bf0537d8f89ba48c03a3d270d9ff0d1b347b74c32508e8de0795b94308ae800e
3
  size 4268864440
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6ec305741c98bd33639b75041cd3c5eef031c6969ab90554f1e7e13277f43f5
3
  size 4268864440
release.json CHANGED
@@ -5,5 +5,5 @@
5
  "tensor_count": 468,
6
  "text_encoder_repository": "google/t5gemma-2-270m-270m",
7
  "vae_repository": "data-archetype/dinac3_96",
8
- "version": "0.215"
9
  }
 
5
  "tensor_count": 468,
6
  "text_encoder_repository": "google/t5gemma-2-270m-270m",
7
  "vae_repository": "data-archetype/dinac3_96",
8
+ "version": "0.22"
9
  }
text_encoder/model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b311240dbb5d694fb17e028a1d67a6cdf91d8290d549fac3a01ba39e79dc95dc
3
  size 469329848
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ac6e442a6e35df2fc2bf3dae6eb4bd8cdd6995e23742df85cd6688469f5aa70
3
  size 469329848