code-and-canvas commited on
Commit
936c3e3
·
verified ·
1 Parent(s): 311cbf9

Upload folder using huggingface_hub

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
README.md ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - coreml
5
+ - text-to-image
6
+ - wan
7
+ - dit
8
+ - apple-neural-engine
9
+ base_model: kpsss34/Walkyrie-1.3B-v2.0
10
+ pipeline_tag: text-to-image
11
+ ---
12
+
13
+ # Walkyrie-1.3B-v2.0 Core ML (Unquantized)
14
+
15
+ This repository contains the first native Apple Silicon Core ML conversion of the **Walkyrie-1.3B-v2.0** core transformer brain, an image model built on top of the Wan 2.1 Diffusion Transformer (DiT) framework.
16
+
17
+
18
+ ## Repository Layout
19
+ * `Walkyrie_1.3B_v2.0_float16.mlpackage`: The complete 30-block core DiT transformer layer, fully optimized to execute on the Apple Neural Engine (ANE) and Apple Graphics Processor (GPU).
20
+
21
+ ## Implementation & Pipeline Notes
22
+ This asset contains **only the core transformer block**. To build a complete text-to-image pipeline inside a native Swift application, you will need to pair this core package with a text tokenizer and a VAE decoder:
23
+ 1. **Text Encoder (UMT5-XXL):** Because compiling an 11B parameter text encoder directly to a static Core ML graph triggers high memory overhead during compilation on 16GB machines, it is highly recommended to run the UMT5 text layer as a raw weight array processed on the CPU/GPU via libraries like `swift-tokenizers` or `mlx-swift`.
24
+ 2. **VAE Decoder:** Can be mapped natively via standard Core ML convolutional upsampling to translate the finished transformer latents into viewable RGB images.
25
+
26
+ ---
27
+
28
+ ## 🛠️ Replication & Conversion Process
29
+
30
+ If you want to re-compile or modify this setup from scratch using the `silicon-alloy` converter or direct `coremltools` tracing, you must bypass several legacy architectural structural mismatches hardcoded into older diffusion conversion scripts.
31
+
32
+ The original codebase must be patched with the following workflow modifications:
33
+
34
+ ### 1. Alignment with Modern Diffusers Layer Naming
35
+ The newer Wan 2.1 architecture uses updated property names. Legacy scripts searching for sub-modules will throw immediate `AttributeErrors` unless mapped to the following properties:
36
+ * Change `.transformer_blocks` references to `.blocks`
37
+ * Change `.patch_embed` references to `.patch_embedding`
38
+
39
+ ### 2. Migrating to the Unified Condition Embedder
40
+ Older models process prompt token arrays and timesteps via isolated `.text_embed()` and `.time_embed()` functions. Wan 2.1 consolidates these into a single unified block.
41
+ * Remove the standalone text and time embedding calls.
42
+ * Call the unified module directly: `temb, timestep_proj, encoder_hidden_states, _ = self.model.condition_embedder(timestep, encoder_hidden_states, None)`
43
+ * Unflatten the resulting projection matrix into its multi-head layout before passing it along: `timestep_proj = timestep_proj.unflatten(1, (6, -1))`
44
+
45
+ ### 3. Spatial Tensor Flattening vs. 5D RoPE Tracking
46
+ The patch embedding layer outputs a 5D spatial video matrix structured as `[Batch, Hidden_Dim, Frames, Height, Width]`. The transformer blocks, however, expect a flattened 3D sequence token vector `[Batch, Sequence_Length, Hidden_Dim]`. Crucially, the Rotary Position Embedding (`.rope`) module still requires the 5D spatial layout to calculate coordinates.
47
+ * **The correct execution sequence:** Pass the 5D spatial matrix into the `.rope()` module *first* to extract your rotary embedding parameters: `image_rotary_emb = self.model.rope(hidden_states_5d)`
48
+ * Flatten and transpose the spatial matrix into sequence tokens *second*, right before launching your core transformer blocks loop: `hidden_states = hidden_states_5d.flatten(2).transpose(1, 2)`
49
+
50
+ ## Acknowledgements
51
+ * Original model weights trained and released by [kpsss34](https://huggingface.co/kpsss34).
52
+ * Core ML compilation achieved via the `silicon-alloy` framework.
Walkyrie_1.3B_v2.0_Float16.mlpackage/Data/com.apple.CoreML/model.mlmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8140fd2ac50ccc6dc2320d7ce704079266729e9b8e5e1c5b67bff28f8eb366b1
3
+ size 1086061
Walkyrie_1.3B_v2.0_Float16.mlpackage/Data/com.apple.CoreML/weights/0-weight.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:874cb4613dacae5dd59108cab44542f9987367fc8c8d3e2ca228f0e2f655bbd3
3
+ size 1444858944
Walkyrie_1.3B_v2.0_Float16.mlpackage/Data/com.apple.CoreML/weights/1-weight.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0143af7b5d2bc14bbcf50cad1cb0c6728aea4aef425511eafc2f8164ad058580
3
+ size 1393706240
Walkyrie_1.3B_v2.0_Float16.mlpackage/Manifest.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "fileFormatVersion": "1.0.0",
3
+ "itemInfoEntries": {
4
+ "7F0A0DF2-B8B0-4AFB-A834-C6BB686174A4": {
5
+ "author": "com.apple.CoreML",
6
+ "description": "CoreML Model Weights",
7
+ "name": "weights",
8
+ "path": "com.apple.CoreML/weights"
9
+ },
10
+ "ED98EB8D-7B7E-4D61-9248-72B31AEDE7A9": {
11
+ "author": "com.apple.CoreML",
12
+ "description": "CoreML Model Specification",
13
+ "name": "model.mlmodel",
14
+ "path": "com.apple.CoreML/model.mlmodel"
15
+ }
16
+ },
17
+ "rootModelIdentifier": "ED98EB8D-7B7E-4D61-9248-72B31AEDE7A9"
18
+ }
text_encoder/config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "UMT5EncoderModel"
4
+ ],
5
+ "classifier_dropout": 0.0,
6
+ "d_ff": 10240,
7
+ "d_kv": 64,
8
+ "d_model": 4096,
9
+ "decoder_start_token_id": 0,
10
+ "dense_act_fn": "gelu_new",
11
+ "dropout_rate": 0.1,
12
+ "dtype": "float32",
13
+ "eos_token_id": 1,
14
+ "feed_forward_proj": "gated-gelu",
15
+ "initializer_factor": 1.0,
16
+ "is_decoder": false,
17
+ "is_encoder_decoder": true,
18
+ "is_gated_act": true,
19
+ "layer_norm_epsilon": 1e-06,
20
+ "model_type": "umt5",
21
+ "num_decoder_layers": 24,
22
+ "num_heads": 64,
23
+ "num_layers": 1,
24
+ "output_past": true,
25
+ "pad_token_id": 0,
26
+ "relative_attention_max_distance": 128,
27
+ "relative_attention_num_buckets": 32,
28
+ "scalable_attention": true,
29
+ "tie_word_embeddings": true,
30
+ "tokenizer_class": "T5Tokenizer",
31
+ "transformers_version": "5.8.0",
32
+ "use_cache": true,
33
+ "vocab_size": 256384
34
+ }
text_encoder/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8acd5f1bbd6d5872c3614f05a494bfe9532aaeebc9d94e8a3d100e9bf5d57296
3
+ size 2486203808
vae/config.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "AutoencoderKLWan",
3
+ "_diffusers_version": "0.39.0.dev0",
4
+ "_name_or_path": "kpsss34/Walkyrie-1.3B-v1.0",
5
+ "attn_scales": [],
6
+ "base_dim": 96,
7
+ "decoder_base_dim": null,
8
+ "dim_mult": [
9
+ 1,
10
+ 2,
11
+ 4,
12
+ 4
13
+ ],
14
+ "dropout": 0.0,
15
+ "in_channels": 3,
16
+ "is_residual": false,
17
+ "latents_mean": [
18
+ -0.7571,
19
+ -0.7089,
20
+ -0.9113,
21
+ 0.1075,
22
+ -0.1745,
23
+ 0.9653,
24
+ -0.1517,
25
+ 1.5508,
26
+ 0.4134,
27
+ -0.0715,
28
+ 0.5517,
29
+ -0.3632,
30
+ -0.1922,
31
+ -0.9497,
32
+ 0.2503,
33
+ -0.2921
34
+ ],
35
+ "latents_std": [
36
+ 2.8184,
37
+ 1.4541,
38
+ 2.3275,
39
+ 2.6558,
40
+ 1.2196,
41
+ 1.7708,
42
+ 2.6052,
43
+ 2.0743,
44
+ 3.2687,
45
+ 2.1526,
46
+ 2.8652,
47
+ 1.5579,
48
+ 1.6382,
49
+ 1.1253,
50
+ 2.8251,
51
+ 1.916
52
+ ],
53
+ "num_res_blocks": 2,
54
+ "out_channels": 3,
55
+ "patch_size": null,
56
+ "scale_factor_spatial": 8,
57
+ "scale_factor_temporal": 4,
58
+ "temperal_downsample": [
59
+ false,
60
+ true,
61
+ true
62
+ ],
63
+ "z_dim": 16
64
+ }
vae/diffusion_pytorch_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8da83431220b1e9e55e04f3f84a6d5974d1de614b24fad99a3d0c399b0efd70a
3
+ size 507591892