yujiepan commited on
Commit
f84967c
·
verified ·
1 Parent(s): 7ff060e

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -12,23 +12,23 @@ Structural comparison with `OpenMOSS-Team/MOSS-Image-Base`:
12
  |---|---:|---:|
13
  | Pipeline | custom MOSS Image | same |
14
  | Text vocabulary / precision | 248,320 / BF16 | same |
15
- | Qwen3.5 text layers and cadence | 32; 3 linear + 1 full | same |
16
  | Text width / attention head dimension | 4,096 / 256 | 32 / 32 |
17
- | Text vision tower | 27 layers | same depth; width 32 |
18
- | DiT blocks | 42 | same |
19
  | DiT width / heads / FFN | 3,072 / 24 / 8,192 | 64 / 2 / 128 |
20
  | DiT latent channels | 128 | same |
21
  | Flux2 VAE blocks / layers per block | 4 / 2 | same; widths reduced |
22
  | Checkpoint precision | BF16 text/DiT; FP32 VAE/RoPE | same |
23
 
24
  The source's custom scheduler, DiT, tokenizer and pipeline code are copied from
25
- the pinned revision. The transformer keeps all 42 blocks, and the VAE stays
26
- FP32 because that is the source checkpoint representation and decoding path.
27
 
28
  | File path | Size |
29
  |------|------|
30
- | text_encoder/model.safetensors | 17.5MB |
31
- | transformer/diffusion_pytorch_model.safetensors | 3.8MB |
32
  | vae/diffusion_pytorch_model.safetensors | 5.8MB |
33
 
34
 
@@ -55,6 +55,7 @@ image = pipe(
55
  width=32,
56
  num_inference_steps=1,
57
  guidance_scale=1.0,
 
58
  generator=torch.Generator("cpu").manual_seed(42),
59
  ).images[0]
60
  print(image.size)
@@ -128,8 +129,8 @@ text.update(
128
  linear_value_head_dim=32,
129
  linear_num_key_heads=1,
130
  linear_num_value_heads=1,
131
- num_hidden_layers=32,
132
- layer_types=["linear_attention", "linear_attention", "linear_attention", "full_attention"] * 8,
133
  )
134
  text["rope_parameters"]["mrope_section"] = [1, 1, 2]
135
  raw_text["vision_config"].update(
@@ -137,7 +138,7 @@ raw_text["vision_config"].update(
137
  intermediate_size=64,
138
  num_heads=1,
139
  out_hidden_size=32,
140
- depth=27,
141
  )
142
  text_folder = folder / "text_encoder"
143
  text_folder.mkdir(exist_ok=True)
@@ -153,7 +154,7 @@ transformer = source.MOSSImageTransformer(
153
  dim=64,
154
  ffn_dim=128,
155
  num_heads=2,
156
- num_layers=42,
157
  text_dim=32,
158
  freq_dim=32,
159
  latent_channels=128,
@@ -177,7 +178,10 @@ vae.save_pretrained(folder / "vae", safe_serialization=True)
177
  scheduler = source.MOSSImageScheduler()
178
  scheduler.save_pretrained(folder / "scheduler")
179
 
180
- # Preserve all executable source code plus tokenizer assets byte-for-byte.
 
 
 
181
  assets = {
182
  "model_index.json", "pipeline_moss_image.py", "scheduler/pipeline_moss_image.py",
183
  "scheduler/scheduler_config.json", "tokenizer/chat_template.jinja",
@@ -188,6 +192,18 @@ for filename in sorted(set(list_repo_files(source_model_id, revision=source_revi
188
  destination = folder / filename
189
  destination.parent.mkdir(parents=True, exist_ok=True)
190
  copyfile(hf_hub_download(source_model_id, filename, revision=source_revision), destination)
 
 
 
 
 
 
 
 
 
 
 
 
191
 
192
  pipe = source.MOSSImagePipeline(transformer, scheduler, text_encoder, None, vae)
193
  ```
 
12
  |---|---:|---:|
13
  | Pipeline | custom MOSS Image | same |
14
  | Text vocabulary / precision | 248,320 / BF16 | same |
15
+ | Qwen3.5 text layers and cadence | 32; 3 linear + 1 full | 8; two cycles |
16
  | Text width / attention head dimension | 4,096 / 256 | 32 / 32 |
17
+ | Text vision tower | 27 layers | 2 layers; width 32 |
18
+ | DiT blocks | 42 | 4 |
19
  | DiT width / heads / FFN | 3,072 / 24 / 8,192 | 64 / 2 / 128 |
20
  | DiT latent channels | 128 | same |
21
  | Flux2 VAE blocks / layers per block | 4 / 2 | same; widths reduced |
22
  | Checkpoint precision | BF16 text/DiT; FP32 VAE/RoPE | same |
23
 
24
  The source's custom scheduler, DiT, tokenizer and pipeline code are copied from
25
+ the pinned revision. The transformer keeps four repeated blocks, and the VAE
26
+ stays FP32 because that is the source checkpoint representation and decoding path.
27
 
28
  | File path | Size |
29
  |------|------|
30
+ | text_encoder/model.safetensors | 16.4MB |
31
+ | transformer/diffusion_pytorch_model.safetensors | 0.6MB |
32
  | vae/diffusion_pytorch_model.safetensors | 5.8MB |
33
 
34
 
 
55
  width=32,
56
  num_inference_steps=1,
57
  guidance_scale=1.0,
58
+ uncond_skip_layers=(2,),
59
  generator=torch.Generator("cpu").manual_seed(42),
60
  ).images[0]
61
  print(image.size)
 
129
  linear_value_head_dim=32,
130
  linear_num_key_heads=1,
131
  linear_num_value_heads=1,
132
+ num_hidden_layers=8,
133
+ layer_types=["linear_attention", "linear_attention", "linear_attention", "full_attention"] * 2,
134
  )
135
  text["rope_parameters"]["mrope_section"] = [1, 1, 2]
136
  raw_text["vision_config"].update(
 
138
  intermediate_size=64,
139
  num_heads=1,
140
  out_hidden_size=32,
141
+ depth=2,
142
  )
143
  text_folder = folder / "text_encoder"
144
  text_folder.mkdir(exist_ok=True)
 
154
  dim=64,
155
  ffn_dim=128,
156
  num_heads=2,
157
+ num_layers=4,
158
  text_dim=32,
159
  freq_dim=32,
160
  latent_channels=128,
 
178
  scheduler = source.MOSSImageScheduler()
179
  scheduler.save_pretrained(folder / "scheduler")
180
 
181
+ # Preserve the executable source and tokenizer assets. The source pipeline
182
+ # defaults its negative-branch skip to block 22 of a 42-block DiT. Map that
183
+ # central source block to block 2 of the retained four-block topology so a
184
+ # normal public ``pipe(prompt)`` call remains valid after depth reduction.
185
  assets = {
186
  "model_index.json", "pipeline_moss_image.py", "scheduler/pipeline_moss_image.py",
187
  "scheduler/scheduler_config.json", "tokenizer/chat_template.jinja",
 
192
  destination = folder / filename
193
  destination.parent.mkdir(parents=True, exist_ok=True)
194
  copyfile(hf_hub_download(source_model_id, filename, revision=source_revision), destination)
195
+ for pipeline_path in (
196
+ folder / "pipeline_moss_image.py",
197
+ folder / "scheduler" / "pipeline_moss_image.py",
198
+ folder / "transformer" / "pipeline_moss_image.py",
199
+ ):
200
+ source_code = pipeline_path.read_text(encoding="utf-8")
201
+ source_code = source_code.replace(
202
+ "uncond_skip_layers=(22,)", "uncond_skip_layers=(2,)"
203
+ ).replace(
204
+ "defaults to (22,)", "defaults to (2,)"
205
+ )
206
+ pipeline_path.write_text(source_code, encoding="utf-8")
207
 
208
  pipe = source.MOSSImagePipeline(transformer, scheduler, text_encoder, None, vae)
209
  ```
pipeline_moss_image.py CHANGED
@@ -341,11 +341,11 @@ class MOSSImagePipeline(DiffusionPipeline):
341
  generator=None, latents=None, prompt_embeds=None, prompt_attention_mask=None,
342
  negative_prompt_embeds=None, negative_prompt_attention_mask=None,
343
  max_sequence_length=4096, output_type='pil', return_dict=True,
344
- uncond_skip_layers=(22,), slg_layers=None, slg_scale=0.0,
345
  slg_start=0.0, slg_stop=1.0):
346
  """Generate images with optional full-block skipping (zero-based indices).
347
 
348
- uncond_skip_layers defaults to (22,) and replaces CFG's negative-prompt
349
  prediction with a skipped-block prediction, retaining two forwards per
350
  step. Pass None or an empty sequence to disable skipping. slg_layers
351
  adds a skipped positive-prompt forward and the fp32 correction
 
341
  generator=None, latents=None, prompt_embeds=None, prompt_attention_mask=None,
342
  negative_prompt_embeds=None, negative_prompt_attention_mask=None,
343
  max_sequence_length=4096, output_type='pil', return_dict=True,
344
+ uncond_skip_layers=(2,), slg_layers=None, slg_scale=0.0,
345
  slg_start=0.0, slg_stop=1.0):
346
  """Generate images with optional full-block skipping (zero-based indices).
347
 
348
+ uncond_skip_layers defaults to (2,) and replaces CFG's negative-prompt
349
  prediction with a skipped-block prediction, retaining two forwards per
350
  step. Pass None or an empty sequence to disable skipping. slg_layers
351
  adds a skipped positive-prompt forward and the fp32 correction
scheduler/pipeline_moss_image.py CHANGED
@@ -341,11 +341,11 @@ class MOSSImagePipeline(DiffusionPipeline):
341
  generator=None, latents=None, prompt_embeds=None, prompt_attention_mask=None,
342
  negative_prompt_embeds=None, negative_prompt_attention_mask=None,
343
  max_sequence_length=4096, output_type='pil', return_dict=True,
344
- uncond_skip_layers=(22,), slg_layers=None, slg_scale=0.0,
345
  slg_start=0.0, slg_stop=1.0):
346
  """Generate images with optional full-block skipping (zero-based indices).
347
 
348
- uncond_skip_layers defaults to (22,) and replaces CFG's negative-prompt
349
  prediction with a skipped-block prediction, retaining two forwards per
350
  step. Pass None or an empty sequence to disable skipping. slg_layers
351
  adds a skipped positive-prompt forward and the fp32 correction
 
341
  generator=None, latents=None, prompt_embeds=None, prompt_attention_mask=None,
342
  negative_prompt_embeds=None, negative_prompt_attention_mask=None,
343
  max_sequence_length=4096, output_type='pil', return_dict=True,
344
+ uncond_skip_layers=(2,), slg_layers=None, slg_scale=0.0,
345
  slg_start=0.0, slg_stop=1.0):
346
  """Generate images with optional full-block skipping (zero-based indices).
347
 
348
+ uncond_skip_layers defaults to (2,) and replaces CFG's negative-prompt
349
  prediction with a skipped-block prediction, retaining two forwards per
350
  step. Pass None or an empty sequence to disable skipping. slg_layers
351
  adds a skipped positive-prompt forward and the fp32 correction
text_encoder/config.json CHANGED
@@ -19,30 +19,6 @@
19
  "initializer_range": 0.02,
20
  "intermediate_size": 64,
21
  "layer_types": [
22
- "linear_attention",
23
- "linear_attention",
24
- "linear_attention",
25
- "full_attention",
26
- "linear_attention",
27
- "linear_attention",
28
- "linear_attention",
29
- "full_attention",
30
- "linear_attention",
31
- "linear_attention",
32
- "linear_attention",
33
- "full_attention",
34
- "linear_attention",
35
- "linear_attention",
36
- "linear_attention",
37
- "full_attention",
38
- "linear_attention",
39
- "linear_attention",
40
- "linear_attention",
41
- "full_attention",
42
- "linear_attention",
43
- "linear_attention",
44
- "linear_attention",
45
- "full_attention",
46
  "linear_attention",
47
  "linear_attention",
48
  "linear_attention",
@@ -64,7 +40,7 @@
64
  "mtp_num_hidden_layers": 1,
65
  "mtp_use_dedicated_embeddings": false,
66
  "num_attention_heads": 1,
67
- "num_hidden_layers": 32,
68
  "num_key_value_heads": 1,
69
  "pad_token_id": null,
70
  "partial_rotary_factor": 0.25,
@@ -89,7 +65,7 @@
89
  "video_token_id": 248057,
90
  "vision_config": {
91
  "deepstack_visual_indexes": [],
92
- "depth": 27,
93
  "dtype": "bfloat16",
94
  "hidden_act": "gelu_pytorch_tanh",
95
  "hidden_size": 32,
 
19
  "initializer_range": 0.02,
20
  "intermediate_size": 64,
21
  "layer_types": [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  "linear_attention",
23
  "linear_attention",
24
  "linear_attention",
 
40
  "mtp_num_hidden_layers": 1,
41
  "mtp_use_dedicated_embeddings": false,
42
  "num_attention_heads": 1,
43
+ "num_hidden_layers": 8,
44
  "num_key_value_heads": 1,
45
  "pad_token_id": null,
46
  "partial_rotary_factor": 0.25,
 
65
  "video_token_id": 248057,
66
  "vision_config": {
67
  "deepstack_visual_indexes": [],
68
+ "depth": 2,
69
  "dtype": "bfloat16",
70
  "hidden_act": "gelu_pytorch_tanh",
71
  "hidden_size": 32,
text_encoder/model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e978b54dce1147620893ccfc0e6b4ea09e1612b318a7c7eb8c2a22fa6396495b
3
- size 17474184
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d95a59e225028971ec117dc08ee36a90c7de8ab879ce452716abf56f225263b
3
+ size 16417224
transformer/config.json CHANGED
@@ -6,7 +6,7 @@
6
  "freq_dim": 32,
7
  "latent_channels": 128,
8
  "num_heads": 2,
9
- "num_layers": 42,
10
  "rope_base": 10000.0,
11
  "text_dim": 32
12
  }
 
6
  "freq_dim": 32,
7
  "latent_channels": 128,
8
  "num_heads": 2,
9
+ "num_layers": 4,
10
  "rope_base": 10000.0,
11
  "text_dim": 32
12
  }
transformer/diffusion_pytorch_model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:86214daf0570af1eeee4e1fdcba9cfe63181e538f685e652dd02663e74e5c0c7
3
- size 3782792
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec23d054dfdc432e442046218737834d61ce0d4b33c1ad6736c8abdfb68a22e6
3
+ size 620224
transformer/pipeline_moss_image.py CHANGED
@@ -341,11 +341,11 @@ class MOSSImagePipeline(DiffusionPipeline):
341
  generator=None, latents=None, prompt_embeds=None, prompt_attention_mask=None,
342
  negative_prompt_embeds=None, negative_prompt_attention_mask=None,
343
  max_sequence_length=4096, output_type='pil', return_dict=True,
344
- uncond_skip_layers=(22,), slg_layers=None, slg_scale=0.0,
345
  slg_start=0.0, slg_stop=1.0):
346
  """Generate images with optional full-block skipping (zero-based indices).
347
 
348
- uncond_skip_layers defaults to (22,) and replaces CFG's negative-prompt
349
  prediction with a skipped-block prediction, retaining two forwards per
350
  step. Pass None or an empty sequence to disable skipping. slg_layers
351
  adds a skipped positive-prompt forward and the fp32 correction
 
341
  generator=None, latents=None, prompt_embeds=None, prompt_attention_mask=None,
342
  negative_prompt_embeds=None, negative_prompt_attention_mask=None,
343
  max_sequence_length=4096, output_type='pil', return_dict=True,
344
+ uncond_skip_layers=(2,), slg_layers=None, slg_scale=0.0,
345
  slg_start=0.0, slg_stop=1.0):
346
  """Generate images with optional full-block skipping (zero-based indices).
347
 
348
+ uncond_skip_layers defaults to (2,) and replaces CFG's negative-prompt
349
  prediction with a skipped-block prediction, retaining two forwards per
350
  step. Pass None or an empty sequence to disable skipping. slg_layers
351
  adds a skipped positive-prompt forward and the fp32 correction
vae/diffusion_pytorch_model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d4f21cadbc038798d0c1129ebc430f61b40bfa354f29c7d9785cefdd4b9729fa
3
  size 5841172
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a40fc1c545d1c3e3084b10ed0a3e9177c18508ea1d8cea3352a760079426b7b
3
  size 5841172