Text-to-Image
Diffusers
Safetensors
English
Chinese
LLaDAImagePipeline
image-generation
image-editing
image-to-image
Instructions to use inclusionAI/LLaDA-Image with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use inclusionAI/LLaDA-Image with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("inclusionAI/LLaDA-Image", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
init models
Browse files- .gitattributes +2 -0
- README.md +170 -3
- demo.png +3 -0
- model_index.json +36 -0
- queryformer/config.json +11 -0
- queryformer/diffusion_pytorch_model.safetensors +3 -0
- scheduler/scheduler_config.json +18 -0
- sigvq/config.json +17 -0
- sigvq/diffusion_pytorch_model.safetensors +3 -0
- text_encoder/config.json +59 -0
- text_encoder/configuration_llada2uni_moe.py +133 -0
- text_encoder/model-00001-of-00009.safetensors +3 -0
- text_encoder/model-00002-of-00009.safetensors +3 -0
- text_encoder/model-00003-of-00009.safetensors +3 -0
- text_encoder/model-00004-of-00009.safetensors +3 -0
- text_encoder/model-00005-of-00009.safetensors +3 -0
- text_encoder/model-00006-of-00009.safetensors +3 -0
- text_encoder/model-00007-of-00009.safetensors +3 -0
- text_encoder/model-00008-of-00009.safetensors +3 -0
- text_encoder/model-00009-of-00009.safetensors +3 -0
- text_encoder/model.safetensors.index.json +285 -0
- text_encoder/modeling_llada2uni_moe.py +1289 -0
- text_projection/config.json +11 -0
- text_projection/diffusion_pytorch_model.safetensors +3 -0
- tokenizer/special_tokens_map.json +37 -0
- tokenizer/tokenizer.json +3 -0
- tokenizer/tokenizer_config.json +0 -0
- transformer/config.json +31 -0
- transformer/diffusion_pytorch_model-00001-of-00004.safetensors +3 -0
- transformer/diffusion_pytorch_model-00002-of-00004.safetensors +3 -0
- transformer/diffusion_pytorch_model-00003-of-00004.safetensors +3 -0
- transformer/diffusion_pytorch_model-00004-of-00004.safetensors +3 -0
- transformer/diffusion_pytorch_model.safetensors.index.json +342 -0
- vae/config.json +39 -0
- vae/diffusion_pytorch_model.safetensors +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
demo.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,170 @@
|
|
| 1 |
-
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<h1 align="center">LLaDA-Image</h1>
|
| 2 |
+
|
| 3 |
+
<p align="center">
|
| 4 |
+
Welcome to the official repository for LLaDA-Image, a unified model for high-quality image generation and editing.
|
| 5 |
+
</p>
|
| 6 |
+
|
| 7 |
+
<p align="center">
|
| 8 |
+
<a href="https://github.com/inclusionAI/LLaDA-Image"><img src="https://img.shields.io/badge/GitHub-LLaDA--Image-181717?logo=github" alt="GitHub"></a>
|
| 9 |
+
<a href="https://huggingface.co/inclusionAI/LLaDA-Image"><img src="https://img.shields.io/badge/Hugging%20Face-Base-FFD21E?logo=huggingface" alt="LLaDA-Image Base on Hugging Face"></a>
|
| 10 |
+
<a href="https://huggingface.co/inclusionAI/LLaDA-Image-Turbo"><img src="https://img.shields.io/badge/Hugging%20Face-Turbo-FFD21E?logo=huggingface" alt="LLaDA-Image Turbo on Hugging Face"></a>
|
| 11 |
+
<a href="#"><img src="https://img.shields.io/badge/arXiv-Coming%20Soon-B31B1B?logo=arxiv" alt="arXiv"></a>
|
| 12 |
+
</p>
|
| 13 |
+
|
| 14 |
+
<p align="center">
|
| 15 |
+
<img src="demo.png" alt="LLaDA-Image showcase" width="100%">
|
| 16 |
+
</p>
|
| 17 |
+
|
| 18 |
+
## Introduction
|
| 19 |
+
|
| 20 |
+
LLaDA-Image is a competitive 6B-parameter open-source unified image generation and editing model family. It includes **LLaDA-Image**, a 50-step Base model for high-quality text-to-image generation and instruction-guided editing, and **LLaDA-Image-Turbo**, a 4-step distilled model for fast generation and editing. Both variants support practical text-to-image generation, VQ-conditioned generation, reference-image editing, and Chinese--English text rendering.
|
| 21 |
+
|
| 22 |
+
This repository provides the checkpoints and Diffusers-based inference code for the LLaDA-Image model family.
|
| 23 |
+
|
| 24 |
+
## News
|
| 25 |
+
|
| 26 |
+
- **TODO:** We released the LLaDA-Image Base and Turbo checkpoints together with the inference code.
|
| 27 |
+
|
| 28 |
+
## Highlights
|
| 29 |
+
|
| 30 |
+
- **Unified generation and editing.** A single checkpoint supports text-to-image generation and reference-preserving, instruction-guided editing without a separate editing backbone.
|
| 31 |
+
- **Realistic image generation.** LLaDA-Image produces high-quality images with rich visual details, natural lighting, and coherent compositions.
|
| 32 |
+
- **Image-only pre-training for visual-prior learning.** The report establishes the visual prior through image-only pre-training and mid-training before introducing paired language supervision and joint generation--editing training.
|
| 33 |
+
- **Efficient inference with distilled model.** LLaDA-Image-Turbo uses Twin-DMD distillation to deliver fast image generation and editing in only 2--4 sampling steps.
|
| 34 |
+
- **SOTA on Qwen-Image-Bench.** LLaDA-Image achieves state-of-the-art overall scores of 53.53 in English and 53.38 in Chinese.
|
| 35 |
+
|
| 36 |
+
## Model Zoo
|
| 37 |
+
|
| 38 |
+
| Model | Description | Sampling steps | Hugging Face |
|
| 39 |
+
| --- | --- | ---: | --- |
|
| 40 |
+
| **LLaDA-Image** | Base model for high-fidelity text-to-image generation and instruction-guided editing. | 50 | [inclusionAI/LLaDA-Image](https://huggingface.co/inclusionAI/LLaDA-Image) |
|
| 41 |
+
| **LLaDA-Image-Turbo** | Distilled model for fast generation and editing. | 4 | [inclusionAI/LLaDA-Image-Turbo](https://huggingface.co/inclusionAI/LLaDA-Image-Turbo) |
|
| 42 |
+
|
| 43 |
+
## Quick Start
|
| 44 |
+
|
| 45 |
+
### 1. Create an environment
|
| 46 |
+
|
| 47 |
+
The implementation has been used with Python 3.11, PyTorch 2.8, Transformers 4.57.6, and Diffusers 0.39.0.
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
git clone https://github.com/inclusionAI/LLaDA-Image.git
|
| 51 |
+
cd LLaDA-Image
|
| 52 |
+
|
| 53 |
+
pip install -r requirements.txt
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
The published LLaDA2 text encoder uses `veomni.ops.fused_moe_forward`. Install a compatible LLaDA2 / VeOmni runtime before running inference.
|
| 57 |
+
|
| 58 |
+
### 2. Run inference
|
| 59 |
+
|
| 60 |
+
The pipeline accepts a prompt and, for editing, an optional reference image.
|
| 61 |
+
|
| 62 |
+
#### LLaDA-Image (Base)
|
| 63 |
+
|
| 64 |
+
Use the Base checkpoint for high-fidelity generation and editing. Its recommended sampling configuration is **50 steps**.
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
import torch
|
| 68 |
+
|
| 69 |
+
from src import LLaDAImagePipeline
|
| 70 |
+
|
| 71 |
+
# Load the pipeline. The model is downloaded from Hugging Face on first use.
|
| 72 |
+
pipe = LLaDAImagePipeline.from_pretrained(
|
| 73 |
+
"inclusionAI/LLaDA-Image",
|
| 74 |
+
torch_dtype=torch.bfloat16,
|
| 75 |
+
device="cuda",
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
# Generate an image.
|
| 79 |
+
prompt = (
|
| 80 |
+
"A cinematic photograph of a red fox standing in fresh snow, "
|
| 81 |
+
"soft winter light, detailed fur, shallow depth of field"
|
| 82 |
+
)
|
| 83 |
+
negative_prompt = ""
|
| 84 |
+
|
| 85 |
+
image = pipe(
|
| 86 |
+
prompt=prompt,
|
| 87 |
+
negative_prompt=negative_prompt,
|
| 88 |
+
generation_mode="text",
|
| 89 |
+
height=1024,
|
| 90 |
+
width=1024,
|
| 91 |
+
num_inference_steps=50,
|
| 92 |
+
guidance_scale=5.0,
|
| 93 |
+
generator=torch.Generator("cuda").manual_seed(42),
|
| 94 |
+
).images[0]
|
| 95 |
+
|
| 96 |
+
image.save("llada-image-base.png")
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
#### LLaDA-Image-Turbo
|
| 100 |
+
|
| 101 |
+
Use the Turbo checkpoint for fast generation and editing. Its recommended sampling configuration is **4 steps**.
|
| 102 |
+
|
| 103 |
+
```python
|
| 104 |
+
import torch
|
| 105 |
+
|
| 106 |
+
from src import LLaDAImagePipeline
|
| 107 |
+
|
| 108 |
+
# Load the distilled Turbo checkpoint.
|
| 109 |
+
pipe = LLaDAImagePipeline.from_pretrained(
|
| 110 |
+
"inclusionAI/LLaDA-Image-Turbo",
|
| 111 |
+
torch_dtype=torch.bfloat16,
|
| 112 |
+
device="cuda",
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
prompt = "A quiet observatory above a sea of clouds at sunrise, golden light, wide-angle photograph"
|
| 116 |
+
|
| 117 |
+
image = pipe(
|
| 118 |
+
prompt=prompt,
|
| 119 |
+
generation_mode="text",
|
| 120 |
+
height=1024,
|
| 121 |
+
width=1024,
|
| 122 |
+
num_inference_steps=4,
|
| 123 |
+
guidance_scale=1.0,
|
| 124 |
+
generator=torch.Generator("cuda").manual_seed(42),
|
| 125 |
+
).images[0]
|
| 126 |
+
|
| 127 |
+
image.save("llada-image-turbo.png")
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
#### Generation modes
|
| 131 |
+
|
| 132 |
+
Both checkpoints support the following modes. Text and VQ-conditioned generation require height and width divisible by 16; image editing requires dimensions divisible by 32.
|
| 133 |
+
|
| 134 |
+
**VQ-conditioned generation** uses the LLaDA2 model to produce image VQ tokens from the prompt, which SigVQ embeds before diffusion. Do not provide an input image in VQ mode.
|
| 135 |
+
|
| 136 |
+
```python
|
| 137 |
+
image = pipe(
|
| 138 |
+
prompt="A quiet observatory above a sea of clouds at sunrise",
|
| 139 |
+
generation_mode="vq",
|
| 140 |
+
height=1024,
|
| 141 |
+
width=1024,
|
| 142 |
+
num_inference_steps=50, # Use 4 for LLaDA-Image-Turbo.
|
| 143 |
+
guidance_scale=5.0, # Use 1.0 for few-step inference.
|
| 144 |
+
generator=torch.Generator("cuda").manual_seed(42),
|
| 145 |
+
).images[0]
|
| 146 |
+
```
|
| 147 |
+
|
| 148 |
+
**Image editing** requires a reference image:
|
| 149 |
+
|
| 150 |
+
```python
|
| 151 |
+
from diffusers.utils import load_image
|
| 152 |
+
|
| 153 |
+
reference_image = load_image("/path/to/input.png")
|
| 154 |
+
image = pipe(
|
| 155 |
+
prompt="Turn it into a watercolor painting",
|
| 156 |
+
image=reference_image,
|
| 157 |
+
generation_mode="editing",
|
| 158 |
+
height=1024,
|
| 159 |
+
width=1024,
|
| 160 |
+
num_inference_steps=50, # Use 4 for LLaDA-Image-Turbo.
|
| 161 |
+
guidance_scale=5.0, # Use 1.0 for few-step inference.
|
| 162 |
+
generator=torch.Generator("cuda").manual_seed(43),
|
| 163 |
+
).images[0]
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
## Citation
|
| 167 |
+
|
| 168 |
+
If you find LLaDA-Image useful for your research or applications, please consider citing our work.
|
| 169 |
+
|
| 170 |
+
TODO
|
demo.png
ADDED
|
Git LFS Details
|
model_index.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "LLaDAImagePipeline",
|
| 3 |
+
"_diffusers_version": "0.40.0.dev0",
|
| 4 |
+
"queryformer": [
|
| 5 |
+
"diffusers",
|
| 6 |
+
"LLaDAImageQueryFormerModel"
|
| 7 |
+
],
|
| 8 |
+
"scheduler": [
|
| 9 |
+
"diffusers",
|
| 10 |
+
"FlowMatchEulerDiscreteScheduler"
|
| 11 |
+
],
|
| 12 |
+
"sigvq": [
|
| 13 |
+
"diffusers",
|
| 14 |
+
"LLaDAImageSigVQModel"
|
| 15 |
+
],
|
| 16 |
+
"text_encoder": [
|
| 17 |
+
"modeling_llada2uni_moe",
|
| 18 |
+
"LLaDA2MoeModelLM"
|
| 19 |
+
],
|
| 20 |
+
"text_projection": [
|
| 21 |
+
"diffusers",
|
| 22 |
+
"LLaDAImageTextProjectionModel"
|
| 23 |
+
],
|
| 24 |
+
"tokenizer": [
|
| 25 |
+
"transformers",
|
| 26 |
+
"PreTrainedTokenizerFast"
|
| 27 |
+
],
|
| 28 |
+
"transformer": [
|
| 29 |
+
"diffusers",
|
| 30 |
+
"LLaDAImageTransformer2DModel"
|
| 31 |
+
],
|
| 32 |
+
"vae": [
|
| 33 |
+
"diffusers",
|
| 34 |
+
"AutoencoderKLFlux2"
|
| 35 |
+
]
|
| 36 |
+
}
|
queryformer/config.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "LLaDAImageQueryFormerModel",
|
| 3 |
+
"_diffusers_version": "0.40.0.dev0",
|
| 4 |
+
"dropout": 0.0,
|
| 5 |
+
"hidden_size": 2048,
|
| 6 |
+
"intermediate_size": 8192,
|
| 7 |
+
"norm_eps": 1e-06,
|
| 8 |
+
"num_attention_heads": 16,
|
| 9 |
+
"num_hidden_layers": 1,
|
| 10 |
+
"num_queries": 256
|
| 11 |
+
}
|
queryformer/diffusion_pytorch_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:35cef6a3eecc7fac7558887afe8fc185759da6d936e92676c1b28d5e39a059fd
|
| 3 |
+
size 101749704
|
scheduler/scheduler_config.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "FlowMatchEulerDiscreteScheduler",
|
| 3 |
+
"_diffusers_version": "0.40.0.dev0",
|
| 4 |
+
"base_image_seq_len": 256,
|
| 5 |
+
"base_shift": 0.5,
|
| 6 |
+
"invert_sigmas": false,
|
| 7 |
+
"max_image_seq_len": 4096,
|
| 8 |
+
"max_shift": 1.15,
|
| 9 |
+
"num_train_timesteps": 1000,
|
| 10 |
+
"shift": 1.0,
|
| 11 |
+
"shift_terminal": null,
|
| 12 |
+
"stochastic_sampling": false,
|
| 13 |
+
"time_shift_type": "exponential",
|
| 14 |
+
"use_beta_sigmas": false,
|
| 15 |
+
"use_dynamic_shifting": false,
|
| 16 |
+
"use_exponential_sigmas": false,
|
| 17 |
+
"use_karras_sigmas": false
|
| 18 |
+
}
|
sigvq/config.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "LLaDAImageSigVQModel",
|
| 3 |
+
"_diffusers_version": "0.40.0.dev0",
|
| 4 |
+
"attention_bias": true,
|
| 5 |
+
"attention_dropout": 0.0,
|
| 6 |
+
"codebook_embed_dim": 2048,
|
| 7 |
+
"codebook_size": 16384,
|
| 8 |
+
"hidden_size": 1536,
|
| 9 |
+
"image_size": 2048,
|
| 10 |
+
"in_channels": 3,
|
| 11 |
+
"intermediate_size": 6144,
|
| 12 |
+
"norm_eps": 1e-06,
|
| 13 |
+
"num_attention_heads": 16,
|
| 14 |
+
"num_hidden_layers": 40,
|
| 15 |
+
"patch_size": 16,
|
| 16 |
+
"semantic_embed_dim": 4096
|
| 17 |
+
}
|
sigvq/diffusion_pytorch_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e4681b698911069c8d7fa8e89505ba16d4c76b9926e2795ea81483f97d79f960
|
| 3 |
+
size 2594014384
|
text_encoder/config.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LLaDA2MoeModelLM"
|
| 4 |
+
],
|
| 5 |
+
"auto_map": {
|
| 6 |
+
"AutoConfig": "configuration_llada2uni_moe.LLaDA2MoeConfig",
|
| 7 |
+
"AutoModel": "modeling_llada2uni_moe.LLaDA2MoeModelLM",
|
| 8 |
+
"AutoModelForCausalLM": "modeling_llada2uni_moe.LLaDA2MoeModelLM"
|
| 9 |
+
},
|
| 10 |
+
"attention_dropout": 0.0,
|
| 11 |
+
"embedding_dropout": 0.0,
|
| 12 |
+
"first_k_dense_replace": 1,
|
| 13 |
+
"head_dim": 128,
|
| 14 |
+
"hidden_act": "silu",
|
| 15 |
+
"hidden_size": 2048,
|
| 16 |
+
"image_token_offset": 157184,
|
| 17 |
+
"initializer_range": 0.02,
|
| 18 |
+
"intermediate_size": 5120,
|
| 19 |
+
"max_position_embeddings": 16384,
|
| 20 |
+
"model_type": "llada2_moe_veomni",
|
| 21 |
+
"moe_intermediate_size": 512,
|
| 22 |
+
"moe_router_enable_expert_bias": true,
|
| 23 |
+
"n_group": 8,
|
| 24 |
+
"norm_topk_prob": true,
|
| 25 |
+
"num_attention_heads": 16,
|
| 26 |
+
"num_experts": 256,
|
| 27 |
+
"num_experts_per_tok": 8,
|
| 28 |
+
"num_hidden_layers": 20,
|
| 29 |
+
"num_key_value_heads": 4,
|
| 30 |
+
"num_shared_experts": 1,
|
| 31 |
+
"output_dropout": 0.0,
|
| 32 |
+
"output_router_logits": false,
|
| 33 |
+
"pad_token_id": 156892,
|
| 34 |
+
"partial_rotary_factor": 0.5,
|
| 35 |
+
"rms_norm_eps": 1e-06,
|
| 36 |
+
"rope_scaling": {
|
| 37 |
+
"mrope_section": [
|
| 38 |
+
16,
|
| 39 |
+
24,
|
| 40 |
+
24
|
| 41 |
+
],
|
| 42 |
+
"rope_type": "default",
|
| 43 |
+
"type": "default"
|
| 44 |
+
},
|
| 45 |
+
"rope_theta": 600000,
|
| 46 |
+
"router_dtype": "fp32",
|
| 47 |
+
"routed_scaling_factor": 2.5,
|
| 48 |
+
"score_function": "sigmoid",
|
| 49 |
+
"sliding_window": null,
|
| 50 |
+
"tie_word_embeddings": false,
|
| 51 |
+
"topk_group": 4,
|
| 52 |
+
"torch_dtype": "bfloat16",
|
| 53 |
+
"transformers_version": "4.51.0",
|
| 54 |
+
"use_bias": false,
|
| 55 |
+
"use_cache": false,
|
| 56 |
+
"use_qk_norm": true,
|
| 57 |
+
"use_qkv_bias": false,
|
| 58 |
+
"vocab_size": 173568
|
| 59 |
+
}
|
text_encoder/configuration_llada2uni_moe.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2025 Antgroup and The HuggingFace Inc. team. All rights reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""LLaDA2 MoE model configuration."""
|
| 15 |
+
|
| 16 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class LLaDA2MoeConfig(PretrainedConfig):
|
| 20 |
+
r"""
|
| 21 |
+
Configuration class for the LLaDA2 MoE model.
|
| 22 |
+
|
| 23 |
+
```python
|
| 24 |
+
>>> from configuration_llada2uni_moe import LLaDA2MoeConfig
|
| 25 |
+
>>> config = LLaDA2MoeConfig()
|
| 26 |
+
```
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
# Keep the original value because it selects the fused-expert implementation.
|
| 30 |
+
model_type = "llada2_moe_veomni"
|
| 31 |
+
|
| 32 |
+
def __init__(
|
| 33 |
+
self,
|
| 34 |
+
vocab_size=30592,
|
| 35 |
+
hidden_size=1024,
|
| 36 |
+
intermediate_size=None,
|
| 37 |
+
num_hidden_layers=24,
|
| 38 |
+
num_attention_heads=16,
|
| 39 |
+
num_key_value_heads=0,
|
| 40 |
+
head_dim=None,
|
| 41 |
+
hidden_act="silu",
|
| 42 |
+
use_qkv_bias=False,
|
| 43 |
+
use_qk_norm=True,
|
| 44 |
+
use_bias=True,
|
| 45 |
+
rms_norm_eps=1e-05,
|
| 46 |
+
tie_word_embeddings=False,
|
| 47 |
+
attention_dropout=0.1,
|
| 48 |
+
initializer_range=0.02,
|
| 49 |
+
max_position_embeddings=16384,
|
| 50 |
+
rope_theta=10000.0,
|
| 51 |
+
rope_parameters=None,
|
| 52 |
+
rope_scaling=None,
|
| 53 |
+
partial_rotary_factor=0.5,
|
| 54 |
+
use_cache=True,
|
| 55 |
+
sliding_window=None,
|
| 56 |
+
pad_token_id=126081,
|
| 57 |
+
# Image
|
| 58 |
+
image_token_offset=157184,
|
| 59 |
+
# MoE
|
| 60 |
+
num_experts=16,
|
| 61 |
+
num_shared_experts=0,
|
| 62 |
+
num_experts_per_tok=2,
|
| 63 |
+
n_group=8,
|
| 64 |
+
topk_group=4,
|
| 65 |
+
routed_scaling_factor=2.5,
|
| 66 |
+
moe_router_enable_expert_bias=True,
|
| 67 |
+
norm_topk_prob=True,
|
| 68 |
+
router_dtype="fp32",
|
| 69 |
+
score_function="sigmoid",
|
| 70 |
+
moe_intermediate_size=None,
|
| 71 |
+
first_k_dense_replace=0,
|
| 72 |
+
output_router_logits=False,
|
| 73 |
+
**kwargs,
|
| 74 |
+
):
|
| 75 |
+
self.vocab_size = vocab_size
|
| 76 |
+
self.hidden_size = hidden_size
|
| 77 |
+
self.intermediate_size = intermediate_size
|
| 78 |
+
self.num_hidden_layers = num_hidden_layers
|
| 79 |
+
self.num_attention_heads = num_attention_heads
|
| 80 |
+
self.num_key_value_heads = num_key_value_heads
|
| 81 |
+
self.head_dim = head_dim or hidden_size // num_attention_heads
|
| 82 |
+
self.hidden_act = hidden_act
|
| 83 |
+
self.use_qkv_bias = use_qkv_bias
|
| 84 |
+
self.use_qk_norm = use_qk_norm
|
| 85 |
+
self.use_bias = use_bias
|
| 86 |
+
self.rms_norm_eps = rms_norm_eps
|
| 87 |
+
self.attention_dropout = attention_dropout
|
| 88 |
+
self.initializer_range = initializer_range
|
| 89 |
+
self.max_position_embeddings = max_position_embeddings
|
| 90 |
+
self.rope_theta = rope_theta
|
| 91 |
+
self.rope_scaling = rope_scaling
|
| 92 |
+
self.partial_rotary_factor = partial_rotary_factor
|
| 93 |
+
self.use_cache = use_cache
|
| 94 |
+
self.sliding_window = sliding_window
|
| 95 |
+
|
| 96 |
+
# Image token offset: VQ codebook indices are shifted by this amount in the vocabulary
|
| 97 |
+
self.image_token_offset = image_token_offset
|
| 98 |
+
|
| 99 |
+
# RoPE parameters dict — used by LLaDA2MoeRotaryEmbedding
|
| 100 |
+
if rope_parameters is None:
|
| 101 |
+
rope_parameters = {
|
| 102 |
+
"rope_type": "default",
|
| 103 |
+
"rope_theta": rope_theta,
|
| 104 |
+
"partial_rotary_factor": partial_rotary_factor,
|
| 105 |
+
}
|
| 106 |
+
self.rope_parameters = rope_parameters
|
| 107 |
+
|
| 108 |
+
# MoE
|
| 109 |
+
self.num_experts = num_experts
|
| 110 |
+
self.num_shared_experts = num_shared_experts
|
| 111 |
+
self.num_experts_per_tok = num_experts_per_tok
|
| 112 |
+
self.n_group = n_group
|
| 113 |
+
self.topk_group = topk_group
|
| 114 |
+
self.routed_scaling_factor = routed_scaling_factor
|
| 115 |
+
self.moe_router_enable_expert_bias = moe_router_enable_expert_bias
|
| 116 |
+
self.norm_topk_prob = norm_topk_prob
|
| 117 |
+
self.router_dtype = router_dtype
|
| 118 |
+
self.score_function = score_function
|
| 119 |
+
self.moe_intermediate_size = moe_intermediate_size
|
| 120 |
+
self.first_k_dense_replace = first_k_dense_replace
|
| 121 |
+
self.output_router_logits = output_router_logits
|
| 122 |
+
|
| 123 |
+
# FP8 quantization flag — set to True to use FP8Linear for experts
|
| 124 |
+
self.use_fp8_experts = kwargs.pop("use_fp8_experts", False)
|
| 125 |
+
|
| 126 |
+
super().__init__(
|
| 127 |
+
pad_token_id=pad_token_id,
|
| 128 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 129 |
+
**kwargs,
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
__all__ = ["LLaDA2MoeConfig"]
|
text_encoder/model-00001-of-00009.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:53ddc3caa23c3fd6d6647d74a2a2bd090246b0f4a68867b6adb81dc57a533f0e
|
| 3 |
+
size 3919613264
|
text_encoder/model-00002-of-00009.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fde42e3a6252b518784e4466d82e60a32483ccd62d5ddddd727e47d2a5658814
|
| 3 |
+
size 3814736336
|
text_encoder/model-00003-of-00009.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:49833bce9b494bb38b41cc09c0d1fa524049a5453c44281aa6f5d6d68c2b0b0b
|
| 3 |
+
size 2907713032
|
text_encoder/model-00004-of-00009.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:185d22d685c8fd64d20d22a270ff6aac37a22844687d1e86c31f2d48d3419b36
|
| 3 |
+
size 3814744776
|
text_encoder/model-00005-of-00009.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:01465d5a3e350af8fe8223ce0b4a5b490fb8195614793b8510034cbecefe6c46
|
| 3 |
+
size 3822089560
|
text_encoder/model-00006-of-00009.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e1e138183e022b164920c9053f4dd6a4fe0f67bb0242fbd4def662e7c681eb9
|
| 3 |
+
size 3843062184
|
text_encoder/model-00007-of-00009.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:61af85a19dc55e70f9561925288278c9c5444c39578ce1f7cc9441c7df7e344d
|
| 3 |
+
size 3814740584
|
text_encoder/model-00008-of-00009.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:15cb3644556bab824da307941e044d66daf0c69feeb48ec95faa990211c8fdd3
|
| 3 |
+
size 3814740584
|
text_encoder/model-00009-of-00009.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:de12711a3e750cfd21efa3b56814c85b2033ff46cbec80e02aa446f8eb6f0e10
|
| 3 |
+
size 2894101424
|
text_encoder/model.safetensors.index.json
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_size": 32645504512
|
| 4 |
+
},
|
| 5 |
+
"weight_map": {
|
| 6 |
+
"model.language_model.layers.0.attention.dense.weight": "model-00001-of-00009.safetensors",
|
| 7 |
+
"model.language_model.layers.0.attention.key_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 8 |
+
"model.language_model.layers.0.attention.query_key_value.weight": "model-00001-of-00009.safetensors",
|
| 9 |
+
"model.language_model.layers.0.attention.query_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 10 |
+
"model.language_model.layers.0.input_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 11 |
+
"model.language_model.layers.0.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
|
| 12 |
+
"model.language_model.layers.0.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
|
| 13 |
+
"model.language_model.layers.0.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
|
| 14 |
+
"model.language_model.layers.0.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 15 |
+
"model.language_model.layers.1.attention.dense.weight": "model-00001-of-00009.safetensors",
|
| 16 |
+
"model.language_model.layers.1.attention.key_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 17 |
+
"model.language_model.layers.1.attention.query_key_value.weight": "model-00001-of-00009.safetensors",
|
| 18 |
+
"model.language_model.layers.1.attention.query_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 19 |
+
"model.language_model.layers.1.input_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 20 |
+
"model.language_model.layers.1.mlp.experts.down_proj": "model-00001-of-00009.safetensors",
|
| 21 |
+
"model.language_model.layers.1.mlp.experts.gate_proj": "model-00001-of-00009.safetensors",
|
| 22 |
+
"model.language_model.layers.1.mlp.experts.up_proj": "model-00001-of-00009.safetensors",
|
| 23 |
+
"model.language_model.layers.1.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 24 |
+
"model.language_model.layers.1.mlp.gate.weight": "model-00001-of-00009.safetensors",
|
| 25 |
+
"model.language_model.layers.1.mlp.shared_experts.down_proj.weight": "model-00001-of-00009.safetensors",
|
| 26 |
+
"model.language_model.layers.1.mlp.shared_experts.gate_proj.weight": "model-00001-of-00009.safetensors",
|
| 27 |
+
"model.language_model.layers.1.mlp.shared_experts.up_proj.weight": "model-00001-of-00009.safetensors",
|
| 28 |
+
"model.language_model.layers.1.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 29 |
+
"model.language_model.layers.10.attention.dense.weight": "model-00003-of-00009.safetensors",
|
| 30 |
+
"model.language_model.layers.10.attention.key_layernorm.weight": "model-00003-of-00009.safetensors",
|
| 31 |
+
"model.language_model.layers.10.attention.query_key_value.weight": "model-00003-of-00009.safetensors",
|
| 32 |
+
"model.language_model.layers.10.attention.query_layernorm.weight": "model-00003-of-00009.safetensors",
|
| 33 |
+
"model.language_model.layers.10.input_layernorm.weight": "model-00003-of-00009.safetensors",
|
| 34 |
+
"model.language_model.layers.10.mlp.experts.down_proj": "model-00003-of-00009.safetensors",
|
| 35 |
+
"model.language_model.layers.10.mlp.experts.gate_proj": "model-00003-of-00009.safetensors",
|
| 36 |
+
"model.language_model.layers.10.mlp.experts.up_proj": "model-00003-of-00009.safetensors",
|
| 37 |
+
"model.language_model.layers.10.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 38 |
+
"model.language_model.layers.10.mlp.gate.weight": "model-00003-of-00009.safetensors",
|
| 39 |
+
"model.language_model.layers.10.mlp.shared_experts.down_proj.weight": "model-00003-of-00009.safetensors",
|
| 40 |
+
"model.language_model.layers.10.mlp.shared_experts.gate_proj.weight": "model-00003-of-00009.safetensors",
|
| 41 |
+
"model.language_model.layers.10.mlp.shared_experts.up_proj.weight": "model-00003-of-00009.safetensors",
|
| 42 |
+
"model.language_model.layers.10.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
|
| 43 |
+
"model.language_model.layers.11.attention.dense.weight": "model-00003-of-00009.safetensors",
|
| 44 |
+
"model.language_model.layers.11.attention.key_layernorm.weight": "model-00003-of-00009.safetensors",
|
| 45 |
+
"model.language_model.layers.11.attention.query_key_value.weight": "model-00003-of-00009.safetensors",
|
| 46 |
+
"model.language_model.layers.11.attention.query_layernorm.weight": "model-00003-of-00009.safetensors",
|
| 47 |
+
"model.language_model.layers.11.input_layernorm.weight": "model-00005-of-00009.safetensors",
|
| 48 |
+
"model.language_model.layers.11.mlp.experts.down_proj": "model-00006-of-00009.safetensors",
|
| 49 |
+
"model.language_model.layers.11.mlp.experts.gate_proj": "model-00003-of-00009.safetensors",
|
| 50 |
+
"model.language_model.layers.11.mlp.experts.up_proj": "model-00004-of-00009.safetensors",
|
| 51 |
+
"model.language_model.layers.11.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 52 |
+
"model.language_model.layers.11.mlp.gate.weight": "model-00006-of-00009.safetensors",
|
| 53 |
+
"model.language_model.layers.11.mlp.shared_experts.down_proj.weight": "model-00006-of-00009.safetensors",
|
| 54 |
+
"model.language_model.layers.11.mlp.shared_experts.gate_proj.weight": "model-00006-of-00009.safetensors",
|
| 55 |
+
"model.language_model.layers.11.mlp.shared_experts.up_proj.weight": "model-00006-of-00009.safetensors",
|
| 56 |
+
"model.language_model.layers.11.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 57 |
+
"model.language_model.layers.12.attention.dense.weight": "model-00006-of-00009.safetensors",
|
| 58 |
+
"model.language_model.layers.12.attention.key_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 59 |
+
"model.language_model.layers.12.attention.query_key_value.weight": "model-00006-of-00009.safetensors",
|
| 60 |
+
"model.language_model.layers.12.attention.query_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 61 |
+
"model.language_model.layers.12.input_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 62 |
+
"model.language_model.layers.12.mlp.experts.down_proj": "model-00006-of-00009.safetensors",
|
| 63 |
+
"model.language_model.layers.12.mlp.experts.gate_proj": "model-00006-of-00009.safetensors",
|
| 64 |
+
"model.language_model.layers.12.mlp.experts.up_proj": "model-00006-of-00009.safetensors",
|
| 65 |
+
"model.language_model.layers.12.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 66 |
+
"model.language_model.layers.12.mlp.gate.weight": "model-00006-of-00009.safetensors",
|
| 67 |
+
"model.language_model.layers.12.mlp.shared_experts.down_proj.weight": "model-00006-of-00009.safetensors",
|
| 68 |
+
"model.language_model.layers.12.mlp.shared_experts.gate_proj.weight": "model-00006-of-00009.safetensors",
|
| 69 |
+
"model.language_model.layers.12.mlp.shared_experts.up_proj.weight": "model-00006-of-00009.safetensors",
|
| 70 |
+
"model.language_model.layers.12.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 71 |
+
"model.language_model.layers.13.attention.dense.weight": "model-00006-of-00009.safetensors",
|
| 72 |
+
"model.language_model.layers.13.attention.key_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 73 |
+
"model.language_model.layers.13.attention.query_key_value.weight": "model-00006-of-00009.safetensors",
|
| 74 |
+
"model.language_model.layers.13.attention.query_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 75 |
+
"model.language_model.layers.13.input_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 76 |
+
"model.language_model.layers.13.mlp.experts.down_proj": "model-00006-of-00009.safetensors",
|
| 77 |
+
"model.language_model.layers.13.mlp.experts.gate_proj": "model-00006-of-00009.safetensors",
|
| 78 |
+
"model.language_model.layers.13.mlp.experts.up_proj": "model-00006-of-00009.safetensors",
|
| 79 |
+
"model.language_model.layers.13.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 80 |
+
"model.language_model.layers.13.mlp.gate.weight": "model-00006-of-00009.safetensors",
|
| 81 |
+
"model.language_model.layers.13.mlp.shared_experts.down_proj.weight": "model-00006-of-00009.safetensors",
|
| 82 |
+
"model.language_model.layers.13.mlp.shared_experts.gate_proj.weight": "model-00006-of-00009.safetensors",
|
| 83 |
+
"model.language_model.layers.13.mlp.shared_experts.up_proj.weight": "model-00006-of-00009.safetensors",
|
| 84 |
+
"model.language_model.layers.13.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 85 |
+
"model.language_model.layers.14.attention.dense.weight": "model-00006-of-00009.safetensors",
|
| 86 |
+
"model.language_model.layers.14.attention.key_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 87 |
+
"model.language_model.layers.14.attention.query_key_value.weight": "model-00006-of-00009.safetensors",
|
| 88 |
+
"model.language_model.layers.14.attention.query_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 89 |
+
"model.language_model.layers.14.input_layernorm.weight": "model-00006-of-00009.safetensors",
|
| 90 |
+
"model.language_model.layers.14.mlp.experts.down_proj": "model-00007-of-00009.safetensors",
|
| 91 |
+
"model.language_model.layers.14.mlp.experts.gate_proj": "model-00007-of-00009.safetensors",
|
| 92 |
+
"model.language_model.layers.14.mlp.experts.up_proj": "model-00007-of-00009.safetensors",
|
| 93 |
+
"model.language_model.layers.14.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 94 |
+
"model.language_model.layers.14.mlp.gate.weight": "model-00007-of-00009.safetensors",
|
| 95 |
+
"model.language_model.layers.14.mlp.shared_experts.down_proj.weight": "model-00007-of-00009.safetensors",
|
| 96 |
+
"model.language_model.layers.14.mlp.shared_experts.gate_proj.weight": "model-00007-of-00009.safetensors",
|
| 97 |
+
"model.language_model.layers.14.mlp.shared_experts.up_proj.weight": "model-00007-of-00009.safetensors",
|
| 98 |
+
"model.language_model.layers.14.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
|
| 99 |
+
"model.language_model.layers.15.attention.dense.weight": "model-00007-of-00009.safetensors",
|
| 100 |
+
"model.language_model.layers.15.attention.key_layernorm.weight": "model-00007-of-00009.safetensors",
|
| 101 |
+
"model.language_model.layers.15.attention.query_key_value.weight": "model-00007-of-00009.safetensors",
|
| 102 |
+
"model.language_model.layers.15.attention.query_layernorm.weight": "model-00007-of-00009.safetensors",
|
| 103 |
+
"model.language_model.layers.15.input_layernorm.weight": "model-00007-of-00009.safetensors",
|
| 104 |
+
"model.language_model.layers.15.mlp.experts.down_proj": "model-00007-of-00009.safetensors",
|
| 105 |
+
"model.language_model.layers.15.mlp.experts.gate_proj": "model-00007-of-00009.safetensors",
|
| 106 |
+
"model.language_model.layers.15.mlp.experts.up_proj": "model-00007-of-00009.safetensors",
|
| 107 |
+
"model.language_model.layers.15.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 108 |
+
"model.language_model.layers.15.mlp.gate.weight": "model-00007-of-00009.safetensors",
|
| 109 |
+
"model.language_model.layers.15.mlp.shared_experts.down_proj.weight": "model-00007-of-00009.safetensors",
|
| 110 |
+
"model.language_model.layers.15.mlp.shared_experts.gate_proj.weight": "model-00007-of-00009.safetensors",
|
| 111 |
+
"model.language_model.layers.15.mlp.shared_experts.up_proj.weight": "model-00007-of-00009.safetensors",
|
| 112 |
+
"model.language_model.layers.15.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
|
| 113 |
+
"model.language_model.layers.16.attention.dense.weight": "model-00007-of-00009.safetensors",
|
| 114 |
+
"model.language_model.layers.16.attention.key_layernorm.weight": "model-00007-of-00009.safetensors",
|
| 115 |
+
"model.language_model.layers.16.attention.query_key_value.weight": "model-00007-of-00009.safetensors",
|
| 116 |
+
"model.language_model.layers.16.attention.query_layernorm.weight": "model-00007-of-00009.safetensors",
|
| 117 |
+
"model.language_model.layers.16.input_layernorm.weight": "model-00007-of-00009.safetensors",
|
| 118 |
+
"model.language_model.layers.16.mlp.experts.down_proj": "model-00007-of-00009.safetensors",
|
| 119 |
+
"model.language_model.layers.16.mlp.experts.gate_proj": "model-00008-of-00009.safetensors",
|
| 120 |
+
"model.language_model.layers.16.mlp.experts.up_proj": "model-00008-of-00009.safetensors",
|
| 121 |
+
"model.language_model.layers.16.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 122 |
+
"model.language_model.layers.16.mlp.gate.weight": "model-00008-of-00009.safetensors",
|
| 123 |
+
"model.language_model.layers.16.mlp.shared_experts.down_proj.weight": "model-00008-of-00009.safetensors",
|
| 124 |
+
"model.language_model.layers.16.mlp.shared_experts.gate_proj.weight": "model-00008-of-00009.safetensors",
|
| 125 |
+
"model.language_model.layers.16.mlp.shared_experts.up_proj.weight": "model-00008-of-00009.safetensors",
|
| 126 |
+
"model.language_model.layers.16.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
|
| 127 |
+
"model.language_model.layers.17.attention.dense.weight": "model-00008-of-00009.safetensors",
|
| 128 |
+
"model.language_model.layers.17.attention.key_layernorm.weight": "model-00008-of-00009.safetensors",
|
| 129 |
+
"model.language_model.layers.17.attention.query_key_value.weight": "model-00008-of-00009.safetensors",
|
| 130 |
+
"model.language_model.layers.17.attention.query_layernorm.weight": "model-00008-of-00009.safetensors",
|
| 131 |
+
"model.language_model.layers.17.input_layernorm.weight": "model-00008-of-00009.safetensors",
|
| 132 |
+
"model.language_model.layers.17.mlp.experts.down_proj": "model-00008-of-00009.safetensors",
|
| 133 |
+
"model.language_model.layers.17.mlp.experts.gate_proj": "model-00008-of-00009.safetensors",
|
| 134 |
+
"model.language_model.layers.17.mlp.experts.up_proj": "model-00008-of-00009.safetensors",
|
| 135 |
+
"model.language_model.layers.17.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 136 |
+
"model.language_model.layers.17.mlp.gate.weight": "model-00008-of-00009.safetensors",
|
| 137 |
+
"model.language_model.layers.17.mlp.shared_experts.down_proj.weight": "model-00008-of-00009.safetensors",
|
| 138 |
+
"model.language_model.layers.17.mlp.shared_experts.gate_proj.weight": "model-00008-of-00009.safetensors",
|
| 139 |
+
"model.language_model.layers.17.mlp.shared_experts.up_proj.weight": "model-00008-of-00009.safetensors",
|
| 140 |
+
"model.language_model.layers.17.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
|
| 141 |
+
"model.language_model.layers.18.attention.dense.weight": "model-00008-of-00009.safetensors",
|
| 142 |
+
"model.language_model.layers.18.attention.key_layernorm.weight": "model-00008-of-00009.safetensors",
|
| 143 |
+
"model.language_model.layers.18.attention.query_key_value.weight": "model-00008-of-00009.safetensors",
|
| 144 |
+
"model.language_model.layers.18.attention.query_layernorm.weight": "model-00008-of-00009.safetensors",
|
| 145 |
+
"model.language_model.layers.18.input_layernorm.weight": "model-00008-of-00009.safetensors",
|
| 146 |
+
"model.language_model.layers.18.mlp.experts.down_proj": "model-00008-of-00009.safetensors",
|
| 147 |
+
"model.language_model.layers.18.mlp.experts.gate_proj": "model-00008-of-00009.safetensors",
|
| 148 |
+
"model.language_model.layers.18.mlp.experts.up_proj": "model-00009-of-00009.safetensors",
|
| 149 |
+
"model.language_model.layers.18.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 150 |
+
"model.language_model.layers.18.mlp.gate.weight": "model-00009-of-00009.safetensors",
|
| 151 |
+
"model.language_model.layers.18.mlp.shared_experts.down_proj.weight": "model-00009-of-00009.safetensors",
|
| 152 |
+
"model.language_model.layers.18.mlp.shared_experts.gate_proj.weight": "model-00009-of-00009.safetensors",
|
| 153 |
+
"model.language_model.layers.18.mlp.shared_experts.up_proj.weight": "model-00009-of-00009.safetensors",
|
| 154 |
+
"model.language_model.layers.18.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
|
| 155 |
+
"model.language_model.layers.19.attention.dense.weight": "model-00009-of-00009.safetensors",
|
| 156 |
+
"model.language_model.layers.19.attention.key_layernorm.weight": "model-00009-of-00009.safetensors",
|
| 157 |
+
"model.language_model.layers.19.attention.query_key_value.weight": "model-00009-of-00009.safetensors",
|
| 158 |
+
"model.language_model.layers.19.attention.query_layernorm.weight": "model-00009-of-00009.safetensors",
|
| 159 |
+
"model.language_model.layers.19.input_layernorm.weight": "model-00009-of-00009.safetensors",
|
| 160 |
+
"model.language_model.layers.19.mlp.experts.down_proj": "model-00009-of-00009.safetensors",
|
| 161 |
+
"model.language_model.layers.19.mlp.experts.gate_proj": "model-00009-of-00009.safetensors",
|
| 162 |
+
"model.language_model.layers.19.mlp.experts.up_proj": "model-00009-of-00009.safetensors",
|
| 163 |
+
"model.language_model.layers.19.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 164 |
+
"model.language_model.layers.19.mlp.gate.weight": "model-00009-of-00009.safetensors",
|
| 165 |
+
"model.language_model.layers.19.mlp.shared_experts.down_proj.weight": "model-00009-of-00009.safetensors",
|
| 166 |
+
"model.language_model.layers.19.mlp.shared_experts.gate_proj.weight": "model-00009-of-00009.safetensors",
|
| 167 |
+
"model.language_model.layers.19.mlp.shared_experts.up_proj.weight": "model-00009-of-00009.safetensors",
|
| 168 |
+
"model.language_model.layers.19.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
|
| 169 |
+
"model.language_model.layers.2.attention.dense.weight": "model-00001-of-00009.safetensors",
|
| 170 |
+
"model.language_model.layers.2.attention.key_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 171 |
+
"model.language_model.layers.2.attention.query_key_value.weight": "model-00001-of-00009.safetensors",
|
| 172 |
+
"model.language_model.layers.2.attention.query_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 173 |
+
"model.language_model.layers.2.input_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 174 |
+
"model.language_model.layers.2.mlp.experts.down_proj": "model-00001-of-00009.safetensors",
|
| 175 |
+
"model.language_model.layers.2.mlp.experts.gate_proj": "model-00001-of-00009.safetensors",
|
| 176 |
+
"model.language_model.layers.2.mlp.experts.up_proj": "model-00001-of-00009.safetensors",
|
| 177 |
+
"model.language_model.layers.2.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 178 |
+
"model.language_model.layers.2.mlp.gate.weight": "model-00001-of-00009.safetensors",
|
| 179 |
+
"model.language_model.layers.2.mlp.shared_experts.down_proj.weight": "model-00001-of-00009.safetensors",
|
| 180 |
+
"model.language_model.layers.2.mlp.shared_experts.gate_proj.weight": "model-00001-of-00009.safetensors",
|
| 181 |
+
"model.language_model.layers.2.mlp.shared_experts.up_proj.weight": "model-00001-of-00009.safetensors",
|
| 182 |
+
"model.language_model.layers.2.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 183 |
+
"model.language_model.layers.3.attention.dense.weight": "model-00001-of-00009.safetensors",
|
| 184 |
+
"model.language_model.layers.3.attention.key_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 185 |
+
"model.language_model.layers.3.attention.query_key_value.weight": "model-00001-of-00009.safetensors",
|
| 186 |
+
"model.language_model.layers.3.attention.query_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 187 |
+
"model.language_model.layers.3.input_layernorm.weight": "model-00001-of-00009.safetensors",
|
| 188 |
+
"model.language_model.layers.3.mlp.experts.down_proj": "model-00001-of-00009.safetensors",
|
| 189 |
+
"model.language_model.layers.3.mlp.experts.gate_proj": "model-00002-of-00009.safetensors",
|
| 190 |
+
"model.language_model.layers.3.mlp.experts.up_proj": "model-00002-of-00009.safetensors",
|
| 191 |
+
"model.language_model.layers.3.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 192 |
+
"model.language_model.layers.3.mlp.gate.weight": "model-00002-of-00009.safetensors",
|
| 193 |
+
"model.language_model.layers.3.mlp.shared_experts.down_proj.weight": "model-00002-of-00009.safetensors",
|
| 194 |
+
"model.language_model.layers.3.mlp.shared_experts.gate_proj.weight": "model-00002-of-00009.safetensors",
|
| 195 |
+
"model.language_model.layers.3.mlp.shared_experts.up_proj.weight": "model-00002-of-00009.safetensors",
|
| 196 |
+
"model.language_model.layers.3.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
|
| 197 |
+
"model.language_model.layers.4.attention.dense.weight": "model-00002-of-00009.safetensors",
|
| 198 |
+
"model.language_model.layers.4.attention.key_layernorm.weight": "model-00002-of-00009.safetensors",
|
| 199 |
+
"model.language_model.layers.4.attention.query_key_value.weight": "model-00002-of-00009.safetensors",
|
| 200 |
+
"model.language_model.layers.4.attention.query_layernorm.weight": "model-00002-of-00009.safetensors",
|
| 201 |
+
"model.language_model.layers.4.input_layernorm.weight": "model-00002-of-00009.safetensors",
|
| 202 |
+
"model.language_model.layers.4.mlp.experts.down_proj": "model-00002-of-00009.safetensors",
|
| 203 |
+
"model.language_model.layers.4.mlp.experts.gate_proj": "model-00002-of-00009.safetensors",
|
| 204 |
+
"model.language_model.layers.4.mlp.experts.up_proj": "model-00002-of-00009.safetensors",
|
| 205 |
+
"model.language_model.layers.4.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 206 |
+
"model.language_model.layers.4.mlp.gate.weight": "model-00002-of-00009.safetensors",
|
| 207 |
+
"model.language_model.layers.4.mlp.shared_experts.down_proj.weight": "model-00002-of-00009.safetensors",
|
| 208 |
+
"model.language_model.layers.4.mlp.shared_experts.gate_proj.weight": "model-00002-of-00009.safetensors",
|
| 209 |
+
"model.language_model.layers.4.mlp.shared_experts.up_proj.weight": "model-00002-of-00009.safetensors",
|
| 210 |
+
"model.language_model.layers.4.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
|
| 211 |
+
"model.language_model.layers.5.attention.dense.weight": "model-00002-of-00009.safetensors",
|
| 212 |
+
"model.language_model.layers.5.attention.key_layernorm.weight": "model-00002-of-00009.safetensors",
|
| 213 |
+
"model.language_model.layers.5.attention.query_key_value.weight": "model-00002-of-00009.safetensors",
|
| 214 |
+
"model.language_model.layers.5.attention.query_layernorm.weight": "model-00002-of-00009.safetensors",
|
| 215 |
+
"model.language_model.layers.5.input_layernorm.weight": "model-00004-of-00009.safetensors",
|
| 216 |
+
"model.language_model.layers.5.mlp.experts.down_proj": "model-00004-of-00009.safetensors",
|
| 217 |
+
"model.language_model.layers.5.mlp.experts.gate_proj": "model-00002-of-00009.safetensors",
|
| 218 |
+
"model.language_model.layers.5.mlp.experts.up_proj": "model-00002-of-00009.safetensors",
|
| 219 |
+
"model.language_model.layers.5.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 220 |
+
"model.language_model.layers.5.mlp.gate.weight": "model-00004-of-00009.safetensors",
|
| 221 |
+
"model.language_model.layers.5.mlp.shared_experts.down_proj.weight": "model-00004-of-00009.safetensors",
|
| 222 |
+
"model.language_model.layers.5.mlp.shared_experts.gate_proj.weight": "model-00004-of-00009.safetensors",
|
| 223 |
+
"model.language_model.layers.5.mlp.shared_experts.up_proj.weight": "model-00004-of-00009.safetensors",
|
| 224 |
+
"model.language_model.layers.5.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
|
| 225 |
+
"model.language_model.layers.6.attention.dense.weight": "model-00004-of-00009.safetensors",
|
| 226 |
+
"model.language_model.layers.6.attention.key_layernorm.weight": "model-00004-of-00009.safetensors",
|
| 227 |
+
"model.language_model.layers.6.attention.query_key_value.weight": "model-00004-of-00009.safetensors",
|
| 228 |
+
"model.language_model.layers.6.attention.query_layernorm.weight": "model-00004-of-00009.safetensors",
|
| 229 |
+
"model.language_model.layers.6.input_layernorm.weight": "model-00004-of-00009.safetensors",
|
| 230 |
+
"model.language_model.layers.6.mlp.experts.down_proj": "model-00004-of-00009.safetensors",
|
| 231 |
+
"model.language_model.layers.6.mlp.experts.gate_proj": "model-00004-of-00009.safetensors",
|
| 232 |
+
"model.language_model.layers.6.mlp.experts.up_proj": "model-00004-of-00009.safetensors",
|
| 233 |
+
"model.language_model.layers.6.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 234 |
+
"model.language_model.layers.6.mlp.gate.weight": "model-00004-of-00009.safetensors",
|
| 235 |
+
"model.language_model.layers.6.mlp.shared_experts.down_proj.weight": "model-00004-of-00009.safetensors",
|
| 236 |
+
"model.language_model.layers.6.mlp.shared_experts.gate_proj.weight": "model-00004-of-00009.safetensors",
|
| 237 |
+
"model.language_model.layers.6.mlp.shared_experts.up_proj.weight": "model-00004-of-00009.safetensors",
|
| 238 |
+
"model.language_model.layers.6.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
|
| 239 |
+
"model.language_model.layers.7.attention.dense.weight": "model-00004-of-00009.safetensors",
|
| 240 |
+
"model.language_model.layers.7.attention.key_layernorm.weight": "model-00004-of-00009.safetensors",
|
| 241 |
+
"model.language_model.layers.7.attention.query_key_value.weight": "model-00004-of-00009.safetensors",
|
| 242 |
+
"model.language_model.layers.7.attention.query_layernorm.weight": "model-00004-of-00009.safetensors",
|
| 243 |
+
"model.language_model.layers.7.input_layernorm.weight": "model-00004-of-00009.safetensors",
|
| 244 |
+
"model.language_model.layers.7.mlp.experts.down_proj": "model-00004-of-00009.safetensors",
|
| 245 |
+
"model.language_model.layers.7.mlp.experts.gate_proj": "model-00004-of-00009.safetensors",
|
| 246 |
+
"model.language_model.layers.7.mlp.experts.up_proj": "model-00005-of-00009.safetensors",
|
| 247 |
+
"model.language_model.layers.7.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 248 |
+
"model.language_model.layers.7.mlp.gate.weight": "model-00005-of-00009.safetensors",
|
| 249 |
+
"model.language_model.layers.7.mlp.shared_experts.down_proj.weight": "model-00005-of-00009.safetensors",
|
| 250 |
+
"model.language_model.layers.7.mlp.shared_experts.gate_proj.weight": "model-00005-of-00009.safetensors",
|
| 251 |
+
"model.language_model.layers.7.mlp.shared_experts.up_proj.weight": "model-00005-of-00009.safetensors",
|
| 252 |
+
"model.language_model.layers.7.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
|
| 253 |
+
"model.language_model.layers.8.attention.dense.weight": "model-00005-of-00009.safetensors",
|
| 254 |
+
"model.language_model.layers.8.attention.key_layernorm.weight": "model-00005-of-00009.safetensors",
|
| 255 |
+
"model.language_model.layers.8.attention.query_key_value.weight": "model-00005-of-00009.safetensors",
|
| 256 |
+
"model.language_model.layers.8.attention.query_layernorm.weight": "model-00005-of-00009.safetensors",
|
| 257 |
+
"model.language_model.layers.8.input_layernorm.weight": "model-00005-of-00009.safetensors",
|
| 258 |
+
"model.language_model.layers.8.mlp.experts.down_proj": "model-00005-of-00009.safetensors",
|
| 259 |
+
"model.language_model.layers.8.mlp.experts.gate_proj": "model-00005-of-00009.safetensors",
|
| 260 |
+
"model.language_model.layers.8.mlp.experts.up_proj": "model-00005-of-00009.safetensors",
|
| 261 |
+
"model.language_model.layers.8.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 262 |
+
"model.language_model.layers.8.mlp.gate.weight": "model-00005-of-00009.safetensors",
|
| 263 |
+
"model.language_model.layers.8.mlp.shared_experts.down_proj.weight": "model-00005-of-00009.safetensors",
|
| 264 |
+
"model.language_model.layers.8.mlp.shared_experts.gate_proj.weight": "model-00005-of-00009.safetensors",
|
| 265 |
+
"model.language_model.layers.8.mlp.shared_experts.up_proj.weight": "model-00005-of-00009.safetensors",
|
| 266 |
+
"model.language_model.layers.8.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
|
| 267 |
+
"model.language_model.layers.9.attention.dense.weight": "model-00005-of-00009.safetensors",
|
| 268 |
+
"model.language_model.layers.9.attention.key_layernorm.weight": "model-00005-of-00009.safetensors",
|
| 269 |
+
"model.language_model.layers.9.attention.query_key_value.weight": "model-00005-of-00009.safetensors",
|
| 270 |
+
"model.language_model.layers.9.attention.query_layernorm.weight": "model-00005-of-00009.safetensors",
|
| 271 |
+
"model.language_model.layers.9.input_layernorm.weight": "model-00005-of-00009.safetensors",
|
| 272 |
+
"model.language_model.layers.9.mlp.experts.down_proj": "model-00005-of-00009.safetensors",
|
| 273 |
+
"model.language_model.layers.9.mlp.experts.gate_proj": "model-00005-of-00009.safetensors",
|
| 274 |
+
"model.language_model.layers.9.mlp.experts.up_proj": "model-00005-of-00009.safetensors",
|
| 275 |
+
"model.language_model.layers.9.mlp.gate.expert_bias": "model-00009-of-00009.safetensors",
|
| 276 |
+
"model.language_model.layers.9.mlp.gate.weight": "model-00005-of-00009.safetensors",
|
| 277 |
+
"model.language_model.layers.9.mlp.shared_experts.down_proj.weight": "model-00005-of-00009.safetensors",
|
| 278 |
+
"model.language_model.layers.9.mlp.shared_experts.gate_proj.weight": "model-00005-of-00009.safetensors",
|
| 279 |
+
"model.language_model.layers.9.mlp.shared_experts.up_proj.weight": "model-00005-of-00009.safetensors",
|
| 280 |
+
"model.language_model.layers.9.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
|
| 281 |
+
"model.language_model.norm.weight": "model-00009-of-00009.safetensors",
|
| 282 |
+
"model.language_model.word_embeddings.weight": "model-00003-of-00009.safetensors",
|
| 283 |
+
"model.lm_head.weight": "model-00009-of-00009.safetensors"
|
| 284 |
+
}
|
| 285 |
+
}
|
text_encoder/modeling_llada2uni_moe.py
ADDED
|
@@ -0,0 +1,1289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2025 Antgroup and The HuggingFace Inc. team. All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
|
| 5 |
+
# and OPT implementations in this library. It has been modified from its
|
| 6 |
+
# original forms to accommodate minor architectural differences compared
|
| 7 |
+
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
|
| 8 |
+
#
|
| 9 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 10 |
+
# you may not use this file except in compliance with the License.
|
| 11 |
+
# You may obtain a copy of the License at
|
| 12 |
+
#
|
| 13 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 14 |
+
#
|
| 15 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 16 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 17 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 18 |
+
# See the License for the specific language governing permissions and
|
| 19 |
+
# limitations under the License.
|
| 20 |
+
"""PyTorch implementation of the fused LLaDA2 MoE model."""
|
| 21 |
+
|
| 22 |
+
from dataclasses import dataclass
|
| 23 |
+
import math
|
| 24 |
+
from typing import List, Optional, Tuple, Union
|
| 25 |
+
import warnings
|
| 26 |
+
|
| 27 |
+
import torch
|
| 28 |
+
import torch.nn as nn
|
| 29 |
+
import torch.nn.functional as F
|
| 30 |
+
|
| 31 |
+
from transformers.activations import ACT2FN
|
| 32 |
+
from transformers.cache_utils import Cache, DynamicCache
|
| 33 |
+
from transformers.generation import GenerationMixin
|
| 34 |
+
from transformers.modeling_attn_mask_utils import (
|
| 35 |
+
_prepare_4d_attention_mask,
|
| 36 |
+
_prepare_4d_causal_attention_mask,
|
| 37 |
+
_prepare_4d_causal_attention_mask_for_sdpa,
|
| 38 |
+
)
|
| 39 |
+
from transformers.modeling_outputs import ModelOutput, MoeModelOutputWithPast
|
| 40 |
+
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
|
| 41 |
+
from transformers.modeling_utils import PreTrainedModel
|
| 42 |
+
from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS
|
| 43 |
+
from transformers.utils import logging
|
| 44 |
+
from veomni.ops import fused_moe_forward
|
| 45 |
+
|
| 46 |
+
from .configuration_llada2uni_moe import LLaDA2MoeConfig
|
| 47 |
+
|
| 48 |
+
logger = logging.get_logger(__name__)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class LLaDA2MoeRMSNorm(nn.Module):
|
| 52 |
+
"""RMSNorm used by the LLaDA2 model."""
|
| 53 |
+
|
| 54 |
+
def __init__(self, hidden_size, eps=1e-6):
|
| 55 |
+
super().__init__()
|
| 56 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 57 |
+
self.variance_epsilon = eps
|
| 58 |
+
|
| 59 |
+
def forward(self, hidden_states):
|
| 60 |
+
input_dtype = hidden_states.dtype
|
| 61 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 62 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 63 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 64 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
# Preserve the historical spelling used by the original implementation.
|
| 68 |
+
LLaDA2MoERMSNorm = LLaDA2MoeRMSNorm
|
| 69 |
+
ALL_LAYERNORM_LAYERS.append(LLaDA2MoeRMSNorm)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
class LLaDA2MoePreTrainedModel(PreTrainedModel):
|
| 73 |
+
config_class = LLaDA2MoeConfig
|
| 74 |
+
base_model_prefix = "model"
|
| 75 |
+
supports_gradient_checkpointing = True
|
| 76 |
+
_no_split_modules = ["LLaDA2MoeDecoderLayer"]
|
| 77 |
+
_skip_keys_device_placement = "past_key_values"
|
| 78 |
+
_supports_flash_attn_2 = True
|
| 79 |
+
_supports_sdpa = True
|
| 80 |
+
_supports_cache_class = True
|
| 81 |
+
_supports_flash_attn = True
|
| 82 |
+
_can_compile_fullgraph = True
|
| 83 |
+
_supports_attention_backend = True
|
| 84 |
+
|
| 85 |
+
def _init_weights(self, module):
|
| 86 |
+
std = self.config.initializer_range
|
| 87 |
+
if isinstance(module, nn.Linear):
|
| 88 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 89 |
+
if module.bias is not None:
|
| 90 |
+
module.bias.data.zero_()
|
| 91 |
+
elif isinstance(module, nn.Embedding):
|
| 92 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 93 |
+
if module.padding_idx is not None:
|
| 94 |
+
module.weight.data[module.padding_idx].zero_()
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def rotate_half(hidden_states):
|
| 98 |
+
first, second = hidden_states.chunk(2, dim=-1)
|
| 99 |
+
return torch.cat((-second, first), dim=-1)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def apply_rotary_pos_emb(query, key, cos, sin, position_ids=None, unsqueeze_dim=1):
|
| 103 |
+
"""Apply RoPE to the rotary part of query and key states."""
|
| 104 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 105 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 106 |
+
rotary_dim = cos.shape[-1]
|
| 107 |
+
query_rotary, query_pass = query[..., :rotary_dim], query[..., rotary_dim:]
|
| 108 |
+
key_rotary, key_pass = key[..., :rotary_dim], key[..., rotary_dim:]
|
| 109 |
+
query_rotary = query_rotary * cos + rotate_half(query_rotary) * sin
|
| 110 |
+
key_rotary = key_rotary * cos + rotate_half(key_rotary) * sin
|
| 111 |
+
return torch.cat((query_rotary, query_pass), dim=-1), torch.cat(
|
| 112 |
+
(key_rotary, key_pass), dim=-1
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
class LLaDA2MoeRotaryEmbedding(nn.Module):
|
| 117 |
+
def __init__(self, config: LLaDA2MoeConfig, device=None):
|
| 118 |
+
super().__init__()
|
| 119 |
+
# BC: "rope_type" was originally "type"
|
| 120 |
+
if hasattr(config, "rope_scaling") and config.rope_scaling is not None:
|
| 121 |
+
self.rope_type = config.rope_scaling.get(
|
| 122 |
+
"rope_type", config.rope_scaling.get("type")
|
| 123 |
+
)
|
| 124 |
+
else:
|
| 125 |
+
self.rope_type = "default"
|
| 126 |
+
self.max_seq_len_cached = config.max_position_embeddings
|
| 127 |
+
self.original_max_seq_len = config.max_position_embeddings
|
| 128 |
+
|
| 129 |
+
self.config = config
|
| 130 |
+
self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
|
| 131 |
+
|
| 132 |
+
inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device)
|
| 133 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 134 |
+
self.original_inv_freq = self.inv_freq
|
| 135 |
+
|
| 136 |
+
@torch.no_grad()
|
| 137 |
+
@dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope)
|
| 138 |
+
def forward(self, x, position_ids):
|
| 139 |
+
inv_freq_expanded = (
|
| 140 |
+
self.inv_freq[None, :, None]
|
| 141 |
+
.float()
|
| 142 |
+
.expand(position_ids.shape[0], -1, 1)
|
| 143 |
+
.to(x.device)
|
| 144 |
+
)
|
| 145 |
+
position_ids_expanded = position_ids[:, None, :].float()
|
| 146 |
+
|
| 147 |
+
device_type = (
|
| 148 |
+
x.device.type
|
| 149 |
+
if isinstance(x.device.type, str) and x.device.type != "mps"
|
| 150 |
+
else "cpu"
|
| 151 |
+
)
|
| 152 |
+
with torch.autocast(device_type=device_type, enabled=False): # Force float32
|
| 153 |
+
freqs = (
|
| 154 |
+
inv_freq_expanded.float() @ position_ids_expanded.float()
|
| 155 |
+
).transpose(1, 2)
|
| 156 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 157 |
+
cos = emb.cos() * self.attention_scaling
|
| 158 |
+
sin = emb.sin() * self.attention_scaling
|
| 159 |
+
|
| 160 |
+
return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
class LLaDA2MoeMLP(nn.Module):
|
| 164 |
+
def __init__(self, config: LLaDA2MoeConfig, intermediate_size: int):
|
| 165 |
+
super().__init__()
|
| 166 |
+
self.config = config
|
| 167 |
+
self.hidden_size = config.hidden_size
|
| 168 |
+
self.intermediate_size = intermediate_size
|
| 169 |
+
|
| 170 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 171 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 172 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
|
| 173 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
| 174 |
+
|
| 175 |
+
def forward(self, x):
|
| 176 |
+
return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
class LLaDA2MoeGate(nn.Module):
|
| 180 |
+
def __init__(self, config):
|
| 181 |
+
super().__init__()
|
| 182 |
+
self.config = config
|
| 183 |
+
self.top_k = config.num_experts_per_tok
|
| 184 |
+
self.num_experts = config.num_experts
|
| 185 |
+
|
| 186 |
+
self.n_group = config.n_group
|
| 187 |
+
self.topk_group = config.topk_group
|
| 188 |
+
|
| 189 |
+
self.gating_dim = config.hidden_size
|
| 190 |
+
self.weight = nn.Parameter(torch.empty((self.num_experts, self.gating_dim)))
|
| 191 |
+
self.routed_scaling_factor = config.routed_scaling_factor
|
| 192 |
+
|
| 193 |
+
self.register_buffer("expert_bias", torch.zeros((self.num_experts)))
|
| 194 |
+
self.reset_parameters()
|
| 195 |
+
|
| 196 |
+
def reset_parameters(self) -> None:
|
| 197 |
+
import torch.nn.init as init
|
| 198 |
+
|
| 199 |
+
init.kaiming_uniform_(self.weight, a=math.sqrt(5))
|
| 200 |
+
|
| 201 |
+
def group_limited_topk(
|
| 202 |
+
self,
|
| 203 |
+
scores: torch.Tensor,
|
| 204 |
+
):
|
| 205 |
+
num_tokens, _ = scores.size()
|
| 206 |
+
group_scores = (
|
| 207 |
+
scores.view(num_tokens, self.n_group, -1).topk(2, dim=-1)[0].sum(dim=-1)
|
| 208 |
+
)
|
| 209 |
+
group_idx = torch.topk(group_scores, k=self.topk_group, dim=-1, sorted=False)[1]
|
| 210 |
+
group_mask = torch.zeros_like(group_scores)
|
| 211 |
+
group_mask.scatter_(1, group_idx, 1)
|
| 212 |
+
|
| 213 |
+
score_mask = (
|
| 214 |
+
group_mask.unsqueeze(-1)
|
| 215 |
+
.expand(num_tokens, self.n_group, self.num_experts // self.n_group)
|
| 216 |
+
.reshape(num_tokens, -1)
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
masked_scores = scores.masked_fill(~score_mask.bool(), float("-inf"))
|
| 220 |
+
probs, top_indices = torch.topk(masked_scores, k=self.top_k, dim=-1)
|
| 221 |
+
|
| 222 |
+
return probs, top_indices
|
| 223 |
+
|
| 224 |
+
def forward(self, hidden_states):
|
| 225 |
+
hidden_states = hidden_states.view(-1, hidden_states.shape[-1])
|
| 226 |
+
logits = F.linear(
|
| 227 |
+
hidden_states.type(torch.float32), self.weight.type(torch.float32)
|
| 228 |
+
)
|
| 229 |
+
|
| 230 |
+
scores = torch.sigmoid(logits.float()).type_as(logits)
|
| 231 |
+
|
| 232 |
+
scores_for_routing = scores + self.expert_bias
|
| 233 |
+
_, topk_idx = self.group_limited_topk(scores_for_routing)
|
| 234 |
+
|
| 235 |
+
scores = torch.gather(scores, dim=1, index=topk_idx).type_as(logits)
|
| 236 |
+
|
| 237 |
+
topk_weight = (
|
| 238 |
+
scores / (scores.sum(dim=-1, keepdim=True) + 1e-20)
|
| 239 |
+
if self.top_k > 1
|
| 240 |
+
else scores
|
| 241 |
+
)
|
| 242 |
+
topk_weight = topk_weight * self.routed_scaling_factor
|
| 243 |
+
|
| 244 |
+
return topk_idx, topk_weight, logits
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
class LLaDA2MoeExperts(nn.Module):
|
| 248 |
+
def __init__(self, config):
|
| 249 |
+
super().__init__()
|
| 250 |
+
self.num_experts = config.num_experts
|
| 251 |
+
self.hidden_dim = config.hidden_size
|
| 252 |
+
self.intermediate_size = config.moe_intermediate_size
|
| 253 |
+
self.gate_proj = torch.nn.Parameter(
|
| 254 |
+
torch.empty(self.num_experts, self.intermediate_size, self.hidden_dim),
|
| 255 |
+
requires_grad=True,
|
| 256 |
+
)
|
| 257 |
+
self.up_proj = torch.nn.Parameter(
|
| 258 |
+
torch.empty(self.num_experts, self.intermediate_size, self.hidden_dim),
|
| 259 |
+
requires_grad=True,
|
| 260 |
+
)
|
| 261 |
+
self.down_proj = torch.nn.Parameter(
|
| 262 |
+
torch.empty(self.num_experts, self.hidden_dim, self.intermediate_size),
|
| 263 |
+
requires_grad=True,
|
| 264 |
+
)
|
| 265 |
+
|
| 266 |
+
def forward(self, hidden_states, routing_weights, selected_experts):
|
| 267 |
+
return fused_moe_forward(
|
| 268 |
+
module=self,
|
| 269 |
+
num_experts=self.num_experts,
|
| 270 |
+
routing_weights=routing_weights,
|
| 271 |
+
selected_experts=selected_experts,
|
| 272 |
+
hidden_states=hidden_states,
|
| 273 |
+
fc1_1_weight=self.gate_proj,
|
| 274 |
+
fc1_2_weight=self.up_proj,
|
| 275 |
+
fc2_weight=self.down_proj,
|
| 276 |
+
)
|
| 277 |
+
|
| 278 |
+
def reset_parameters(self):
|
| 279 |
+
"""
|
| 280 |
+
Initialize the parameters of all expert networks.
|
| 281 |
+
Uses different initialization strategies for different projection layers.
|
| 282 |
+
"""
|
| 283 |
+
for expert_id in range(self.num_experts):
|
| 284 |
+
nn.init.kaiming_uniform_(self.gate_proj[expert_id], a=math.sqrt(5))
|
| 285 |
+
nn.init.kaiming_uniform_(self.up_proj[expert_id], a=math.sqrt(5))
|
| 286 |
+
nn.init.xavier_uniform_(self.down_proj[expert_id])
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
class LLaDA2MoeSparseMoeBlock(nn.Module):
|
| 290 |
+
"""Fused routed experts plus a shared expert."""
|
| 291 |
+
|
| 292 |
+
def __init__(self, config: LLaDA2MoeConfig):
|
| 293 |
+
super().__init__()
|
| 294 |
+
self.config = config
|
| 295 |
+
self.experts = LLaDA2MoeExperts(config)
|
| 296 |
+
self.gate = LLaDA2MoeGate(config)
|
| 297 |
+
if config.num_shared_experts is not None:
|
| 298 |
+
self.shared_experts = LLaDA2MoeMLP(
|
| 299 |
+
config=config,
|
| 300 |
+
intermediate_size=config.moe_intermediate_size
|
| 301 |
+
* config.num_shared_experts,
|
| 302 |
+
)
|
| 303 |
+
|
| 304 |
+
def forward(self, hidden_states):
|
| 305 |
+
identity = hidden_states
|
| 306 |
+
bsz, seq_len, h = hidden_states.shape
|
| 307 |
+
topk_idx, topk_weight, router_logits = self.gate(hidden_states)
|
| 308 |
+
hidden_states = hidden_states.view(-1, hidden_states.shape[-1])
|
| 309 |
+
y = self.experts(
|
| 310 |
+
hidden_states, routing_weights=topk_weight, selected_experts=topk_idx
|
| 311 |
+
).reshape(bsz, seq_len, h)
|
| 312 |
+
if self.config.num_shared_experts is not None:
|
| 313 |
+
y = y + self.shared_experts(identity)
|
| 314 |
+
return y, (
|
| 315 |
+
router_logits.view(bsz, seq_len, -1),
|
| 316 |
+
topk_idx.view(bsz, seq_len, -1),
|
| 317 |
+
)
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
| 321 |
+
"""
|
| 322 |
+
This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
|
| 323 |
+
num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
|
| 324 |
+
"""
|
| 325 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
| 326 |
+
if n_rep == 1:
|
| 327 |
+
return hidden_states
|
| 328 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(
|
| 329 |
+
batch, num_key_value_heads, n_rep, slen, head_dim
|
| 330 |
+
)
|
| 331 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
class LLaDA2MoeAttention(nn.Module):
|
| 335 |
+
"""Multi-headed attention from 'Attention Is All You Need' paper"""
|
| 336 |
+
|
| 337 |
+
def __init__(self, config: LLaDA2MoeConfig, layer_idx: Optional[int] = None):
|
| 338 |
+
super().__init__()
|
| 339 |
+
self.config = config
|
| 340 |
+
self.layer_idx = layer_idx
|
| 341 |
+
if layer_idx is None:
|
| 342 |
+
logger.warning_once(
|
| 343 |
+
f"Instantiating {self.__class__.__name__} without passing `layer_idx` is not recommended and will "
|
| 344 |
+
"to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` "
|
| 345 |
+
"when creating this class."
|
| 346 |
+
)
|
| 347 |
+
|
| 348 |
+
self.attention_dropout = config.attention_dropout
|
| 349 |
+
self.hidden_size = config.hidden_size
|
| 350 |
+
self.num_heads = config.num_attention_heads
|
| 351 |
+
self.head_dim = config.head_dim or self.hidden_size // self.num_heads
|
| 352 |
+
partial_rotary_factor = (
|
| 353 |
+
config.partial_rotary_factor
|
| 354 |
+
if hasattr(config, "partial_rotary_factor")
|
| 355 |
+
else 1.0
|
| 356 |
+
)
|
| 357 |
+
self.rope_dim = int(self.head_dim * partial_rotary_factor)
|
| 358 |
+
self.num_key_value_heads = config.num_key_value_heads
|
| 359 |
+
self.num_key_value_groups = self.num_heads // self.num_key_value_heads
|
| 360 |
+
self.max_position_embeddings = config.max_position_embeddings
|
| 361 |
+
self.rope_theta = config.rope_theta
|
| 362 |
+
self.is_causal = False
|
| 363 |
+
|
| 364 |
+
self.query_key_value = nn.Linear(
|
| 365 |
+
self.hidden_size,
|
| 366 |
+
(self.num_heads + 2 * self.num_key_value_heads) * self.head_dim,
|
| 367 |
+
bias=config.use_qkv_bias,
|
| 368 |
+
)
|
| 369 |
+
|
| 370 |
+
self.query_layernorm = LLaDA2MoERMSNorm(self.head_dim, eps=config.rms_norm_eps)
|
| 371 |
+
self.key_layernorm = LLaDA2MoERMSNorm(self.head_dim, eps=config.rms_norm_eps)
|
| 372 |
+
self.dense = nn.Linear(
|
| 373 |
+
self.num_heads * self.head_dim, self.hidden_size, bias=config.use_bias
|
| 374 |
+
)
|
| 375 |
+
|
| 376 |
+
def forward(
|
| 377 |
+
self,
|
| 378 |
+
hidden_states: torch.Tensor,
|
| 379 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 380 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 381 |
+
past_key_value: Optional[Cache] = None,
|
| 382 |
+
output_attentions: bool = False,
|
| 383 |
+
use_cache: bool = False,
|
| 384 |
+
position_embeddings: Optional[
|
| 385 |
+
Tuple[torch.Tensor, torch.Tensor]
|
| 386 |
+
] = None, # necessary, but kept here for BC
|
| 387 |
+
**kwargs,
|
| 388 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
| 389 |
+
if "padding_mask" in kwargs:
|
| 390 |
+
warnings.warn(
|
| 391 |
+
"Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
|
| 392 |
+
)
|
| 393 |
+
|
| 394 |
+
bsz, q_len, _ = hidden_states.size()
|
| 395 |
+
|
| 396 |
+
qkv = self.query_key_value(hidden_states)
|
| 397 |
+
qkv = qkv.view(
|
| 398 |
+
bsz, q_len, self.num_heads + 2 * self.num_key_value_heads, self.head_dim
|
| 399 |
+
)
|
| 400 |
+
|
| 401 |
+
query_states, key_states, value_states = qkv.split(
|
| 402 |
+
[self.num_heads, self.num_key_value_heads, self.num_key_value_heads], dim=-2
|
| 403 |
+
)
|
| 404 |
+
query_states = query_states.transpose(1, 2)
|
| 405 |
+
key_states = key_states.transpose(1, 2)
|
| 406 |
+
value_states = value_states.transpose(1, 2)
|
| 407 |
+
|
| 408 |
+
query_states = self.query_layernorm(query_states)
|
| 409 |
+
key_states = self.key_layernorm(key_states)
|
| 410 |
+
|
| 411 |
+
kv_seq_len = key_states.shape[-2]
|
| 412 |
+
if past_key_value is not None:
|
| 413 |
+
if self.layer_idx is None:
|
| 414 |
+
raise ValueError(
|
| 415 |
+
f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
|
| 416 |
+
"for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
|
| 417 |
+
"with a layer index."
|
| 418 |
+
)
|
| 419 |
+
kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
|
| 420 |
+
cos, sin = position_embeddings
|
| 421 |
+
query_states, key_states = apply_rotary_pos_emb(
|
| 422 |
+
query_states, key_states, cos, sin, position_ids
|
| 423 |
+
)
|
| 424 |
+
|
| 425 |
+
if past_key_value is not None:
|
| 426 |
+
cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
|
| 427 |
+
key_states, value_states = past_key_value.update(
|
| 428 |
+
key_states, value_states, self.layer_idx, cache_kwargs
|
| 429 |
+
)
|
| 430 |
+
|
| 431 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
| 432 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
| 433 |
+
|
| 434 |
+
attn_weights = torch.matmul(
|
| 435 |
+
query_states, key_states.transpose(2, 3)
|
| 436 |
+
) / math.sqrt(self.head_dim)
|
| 437 |
+
|
| 438 |
+
if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
|
| 439 |
+
raise ValueError(
|
| 440 |
+
f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
|
| 441 |
+
f" {attn_weights.size()}"
|
| 442 |
+
)
|
| 443 |
+
if attention_mask is not None:
|
| 444 |
+
if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
|
| 445 |
+
raise ValueError(
|
| 446 |
+
f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
|
| 447 |
+
)
|
| 448 |
+
attn_weights = attn_weights + attention_mask
|
| 449 |
+
|
| 450 |
+
attn_weights = nn.functional.softmax(
|
| 451 |
+
attn_weights, dim=-1, dtype=torch.float32
|
| 452 |
+
).to(query_states.dtype)
|
| 453 |
+
attn_weights = nn.functional.dropout(
|
| 454 |
+
attn_weights, p=self.attention_dropout, training=self.training
|
| 455 |
+
)
|
| 456 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 457 |
+
|
| 458 |
+
if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
|
| 459 |
+
raise ValueError(
|
| 460 |
+
f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
|
| 461 |
+
f" {attn_output.size()}"
|
| 462 |
+
)
|
| 463 |
+
|
| 464 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 465 |
+
|
| 466 |
+
attn_output = attn_output.reshape(bsz, q_len, -1)
|
| 467 |
+
|
| 468 |
+
attn_output = self.dense(attn_output)
|
| 469 |
+
|
| 470 |
+
if not output_attentions:
|
| 471 |
+
attn_weights = None
|
| 472 |
+
|
| 473 |
+
return attn_output, attn_weights, past_key_value
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
class LLaDA2MoeSdpaAttention(LLaDA2MoeAttention):
|
| 477 |
+
"""
|
| 478 |
+
LLaDA2Moe attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
|
| 479 |
+
`LLaDA2MoeAttention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
|
| 480 |
+
SDPA API.
|
| 481 |
+
"""
|
| 482 |
+
|
| 483 |
+
def forward(
|
| 484 |
+
self,
|
| 485 |
+
hidden_states: torch.Tensor,
|
| 486 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 487 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 488 |
+
past_key_value: Optional[Cache] = None,
|
| 489 |
+
output_attentions: bool = False,
|
| 490 |
+
use_cache: bool = False,
|
| 491 |
+
position_embeddings: Optional[
|
| 492 |
+
Tuple[torch.Tensor, torch.Tensor]
|
| 493 |
+
] = None, # necessary, but kept here for BC
|
| 494 |
+
**kwargs,
|
| 495 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
| 496 |
+
if output_attentions:
|
| 497 |
+
logger.warning_once(
|
| 498 |
+
"LLaDA2MoeModel is using LLaDA2MoeSdpaAttention, but `torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to the manual attention implementation, "
|
| 499 |
+
'but specifying the manual implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
|
| 500 |
+
)
|
| 501 |
+
return super().forward(
|
| 502 |
+
hidden_states=hidden_states,
|
| 503 |
+
attention_mask=attention_mask,
|
| 504 |
+
position_ids=position_ids,
|
| 505 |
+
past_key_value=past_key_value,
|
| 506 |
+
output_attentions=output_attentions,
|
| 507 |
+
use_cache=use_cache,
|
| 508 |
+
)
|
| 509 |
+
|
| 510 |
+
bsz, q_len, _ = hidden_states.size()
|
| 511 |
+
|
| 512 |
+
qkv = self.query_key_value(hidden_states)
|
| 513 |
+
qkv = qkv.view(
|
| 514 |
+
bsz, q_len, self.num_heads + 2 * self.num_key_value_heads, self.head_dim
|
| 515 |
+
)
|
| 516 |
+
|
| 517 |
+
query_states, key_states, value_states = qkv.split(
|
| 518 |
+
[self.num_heads, self.num_key_value_heads, self.num_key_value_heads], dim=-2
|
| 519 |
+
)
|
| 520 |
+
query_states = query_states.transpose(1, 2)
|
| 521 |
+
key_states = key_states.transpose(1, 2)
|
| 522 |
+
value_states = value_states.transpose(1, 2)
|
| 523 |
+
|
| 524 |
+
query_states = self.query_layernorm(query_states)
|
| 525 |
+
key_states = self.key_layernorm(key_states)
|
| 526 |
+
|
| 527 |
+
kv_seq_len = key_states.shape[-2]
|
| 528 |
+
if past_key_value is not None:
|
| 529 |
+
kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
|
| 530 |
+
cos, sin = position_embeddings
|
| 531 |
+
|
| 532 |
+
query_states, key_states = apply_rotary_pos_emb(
|
| 533 |
+
query_states, key_states, cos, sin, position_ids
|
| 534 |
+
)
|
| 535 |
+
|
| 536 |
+
if past_key_value is not None:
|
| 537 |
+
cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
|
| 538 |
+
key_states, value_states = past_key_value.update(
|
| 539 |
+
key_states, value_states, self.layer_idx, cache_kwargs
|
| 540 |
+
)
|
| 541 |
+
|
| 542 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
| 543 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
| 544 |
+
|
| 545 |
+
if attention_mask is not None:
|
| 546 |
+
if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
|
| 547 |
+
raise ValueError(
|
| 548 |
+
f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
|
| 549 |
+
)
|
| 550 |
+
|
| 551 |
+
# SDPA with memory-efficient backend is currently (torch==2.1.2) bugged with non-contiguous inputs with custom attn_mask,
|
| 552 |
+
# Reference: https://github.com/pytorch/pytorch/issues/112577.
|
| 553 |
+
if query_states.device.type == "cuda" and attention_mask is not None:
|
| 554 |
+
query_states = query_states.contiguous()
|
| 555 |
+
key_states = key_states.contiguous()
|
| 556 |
+
value_states = value_states.contiguous()
|
| 557 |
+
|
| 558 |
+
attn_output = torch.nn.functional.scaled_dot_product_attention(
|
| 559 |
+
query_states,
|
| 560 |
+
key_states,
|
| 561 |
+
value_states,
|
| 562 |
+
attn_mask=attention_mask,
|
| 563 |
+
dropout_p=self.attention_dropout if self.training else 0.0,
|
| 564 |
+
# The q_len > 1 is necessary to match with AttentionMaskConverter.to_causal_4d that does not create a causal mask in case q_len == 1.
|
| 565 |
+
is_causal=self.is_causal and attention_mask is None and q_len > 1,
|
| 566 |
+
)
|
| 567 |
+
|
| 568 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 569 |
+
attn_output = attn_output.reshape(bsz, q_len, -1)
|
| 570 |
+
|
| 571 |
+
attn_output = self.dense(attn_output)
|
| 572 |
+
|
| 573 |
+
return attn_output, None, past_key_value
|
| 574 |
+
|
| 575 |
+
|
| 576 |
+
ATTENTION_CLASSES = {
|
| 577 |
+
"eager": LLaDA2MoeSdpaAttention,
|
| 578 |
+
"flash_attention_2": LLaDA2MoeSdpaAttention,
|
| 579 |
+
"sdpa": LLaDA2MoeSdpaAttention,
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
|
| 583 |
+
class LLaDA2MoeDecoderLayer(nn.Module):
|
| 584 |
+
def __init__(self, config: LLaDA2MoeConfig, layer_idx: int):
|
| 585 |
+
super().__init__()
|
| 586 |
+
self.hidden_size = config.hidden_size
|
| 587 |
+
|
| 588 |
+
self.attention = ATTENTION_CLASSES[config._attn_implementation](
|
| 589 |
+
config=config, layer_idx=layer_idx
|
| 590 |
+
)
|
| 591 |
+
|
| 592 |
+
self.mlp = (
|
| 593 |
+
LLaDA2MoeSparseMoeBlock(config)
|
| 594 |
+
if (
|
| 595 |
+
config.num_experts is not None
|
| 596 |
+
and layer_idx >= config.first_k_dense_replace
|
| 597 |
+
)
|
| 598 |
+
else LLaDA2MoeMLP(config=config, intermediate_size=config.intermediate_size)
|
| 599 |
+
)
|
| 600 |
+
self.input_layernorm = LLaDA2MoERMSNorm(
|
| 601 |
+
config.hidden_size, eps=config.rms_norm_eps
|
| 602 |
+
)
|
| 603 |
+
self.post_attention_layernorm = LLaDA2MoERMSNorm(
|
| 604 |
+
config.hidden_size, eps=config.rms_norm_eps
|
| 605 |
+
)
|
| 606 |
+
|
| 607 |
+
def forward(
|
| 608 |
+
self,
|
| 609 |
+
hidden_states: torch.Tensor,
|
| 610 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 611 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 612 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
| 613 |
+
output_attentions: Optional[bool] = False,
|
| 614 |
+
output_router_logits: Optional[bool] = False,
|
| 615 |
+
use_cache: Optional[bool] = False,
|
| 616 |
+
position_embeddings: Optional[
|
| 617 |
+
Tuple[torch.Tensor, torch.Tensor]
|
| 618 |
+
] = None, # necessary, but kept here for BC
|
| 619 |
+
**kwargs,
|
| 620 |
+
) -> Tuple[
|
| 621 |
+
torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]
|
| 622 |
+
]:
|
| 623 |
+
"""
|
| 624 |
+
Args:
|
| 625 |
+
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
|
| 626 |
+
attention_mask (`torch.FloatTensor`, *optional*):
|
| 627 |
+
attention mask of size `(batch_size, sequence_length)` if flash attention is used or `(batch_size, 1,
|
| 628 |
+
query_sequence_length, key_sequence_length)` if default attention is used.
|
| 629 |
+
position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 630 |
+
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
|
| 631 |
+
config.n_positions - 1]`.
|
| 632 |
+
past_key_value (`Tuple(torch.FloatTensor)`, *optional*):
|
| 633 |
+
cached past key and value projection states
|
| 634 |
+
output_attentions (`bool`, *optional*):
|
| 635 |
+
Whether to return the attentions tensors of all attention layers. See `attentions` under
|
| 636 |
+
returned tensors for more detail.
|
| 637 |
+
output_router_logits (`bool`, *optional*):
|
| 638 |
+
Whether or not to return the logits of all the routers. They are useful for computing the router loss,
|
| 639 |
+
and should not be returned during inference.
|
| 640 |
+
use_cache (`bool`, *optional*):
|
| 641 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
|
| 642 |
+
(see `past_key_values`).
|
| 643 |
+
"""
|
| 644 |
+
if "padding_mask" in kwargs:
|
| 645 |
+
warnings.warn(
|
| 646 |
+
"Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
|
| 647 |
+
)
|
| 648 |
+
residual = hidden_states
|
| 649 |
+
|
| 650 |
+
hidden_states = self.input_layernorm(hidden_states)
|
| 651 |
+
|
| 652 |
+
hidden_states, self_attn_weights, present_key_value = self.attention(
|
| 653 |
+
hidden_states=hidden_states,
|
| 654 |
+
attention_mask=attention_mask,
|
| 655 |
+
position_ids=position_ids,
|
| 656 |
+
past_key_value=past_key_value,
|
| 657 |
+
output_attentions=output_attentions,
|
| 658 |
+
position_embeddings=position_embeddings,
|
| 659 |
+
use_cache=use_cache,
|
| 660 |
+
)
|
| 661 |
+
hidden_states = residual + hidden_states
|
| 662 |
+
|
| 663 |
+
residual = hidden_states
|
| 664 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 665 |
+
hidden_states = self.mlp(hidden_states)
|
| 666 |
+
if isinstance(hidden_states, tuple):
|
| 667 |
+
hidden_states, router_logits = hidden_states
|
| 668 |
+
else:
|
| 669 |
+
router_logits = None
|
| 670 |
+
hidden_states = residual + hidden_states.to(residual.device)
|
| 671 |
+
|
| 672 |
+
outputs = (hidden_states,)
|
| 673 |
+
|
| 674 |
+
if output_attentions:
|
| 675 |
+
outputs += (self_attn_weights,)
|
| 676 |
+
|
| 677 |
+
if use_cache:
|
| 678 |
+
outputs += (present_key_value,)
|
| 679 |
+
|
| 680 |
+
if output_router_logits:
|
| 681 |
+
outputs += (router_logits,)
|
| 682 |
+
|
| 683 |
+
return outputs
|
| 684 |
+
|
| 685 |
+
|
| 686 |
+
def calculate_pack_position_ids(
|
| 687 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 688 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
| 689 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 690 |
+
past_key_values_length: int = 0,
|
| 691 |
+
cu_lengths_list: Optional[List[torch.Tensor]] = None,
|
| 692 |
+
):
|
| 693 |
+
"""Build continuous or per-sequence packed position IDs."""
|
| 694 |
+
if position_ids is not None:
|
| 695 |
+
return position_ids
|
| 696 |
+
|
| 697 |
+
if input_ids is not None:
|
| 698 |
+
device = input_ids.device
|
| 699 |
+
batch_size, seq_length = input_ids.shape
|
| 700 |
+
elif inputs_embeds is not None:
|
| 701 |
+
device = inputs_embeds.device
|
| 702 |
+
batch_size, seq_length, _ = inputs_embeds.shape
|
| 703 |
+
else:
|
| 704 |
+
raise ValueError("You have to specify either input_ids or inputs_embeds")
|
| 705 |
+
|
| 706 |
+
if cu_lengths_list is not None:
|
| 707 |
+
all_position_ids = []
|
| 708 |
+
|
| 709 |
+
for i in range(batch_size):
|
| 710 |
+
cu_seqlens = cu_lengths_list[i].to(device)
|
| 711 |
+
starts = cu_seqlens[:-1]
|
| 712 |
+
lengths = cu_seqlens[1:] - cu_seqlens[:-1]
|
| 713 |
+
total_len = cu_seqlens[-1].item()
|
| 714 |
+
global_positions = torch.arange(total_len, device=device, dtype=torch.long)
|
| 715 |
+
subtraction_mask = torch.repeat_interleave(starts, lengths)
|
| 716 |
+
current_pos_ids = global_positions - subtraction_mask
|
| 717 |
+
all_position_ids.append(current_pos_ids)
|
| 718 |
+
|
| 719 |
+
position_ids = torch.nn.utils.rnn.pad_sequence(
|
| 720 |
+
all_position_ids,
|
| 721 |
+
batch_first=True,
|
| 722 |
+
padding_value=0,
|
| 723 |
+
)
|
| 724 |
+
|
| 725 |
+
if position_ids.shape[1] < seq_length:
|
| 726 |
+
pad_right = seq_length - position_ids.shape[1]
|
| 727 |
+
position_ids = F.pad(position_ids, (0, pad_right), "constant", 0)
|
| 728 |
+
else:
|
| 729 |
+
position_ids = torch.arange(
|
| 730 |
+
past_key_values_length,
|
| 731 |
+
seq_length + past_key_values_length,
|
| 732 |
+
dtype=torch.long,
|
| 733 |
+
device=device,
|
| 734 |
+
)
|
| 735 |
+
position_ids = position_ids.unsqueeze(0).expand(batch_size, -1)
|
| 736 |
+
|
| 737 |
+
return position_ids
|
| 738 |
+
|
| 739 |
+
|
| 740 |
+
class LLaDA2MoeModel(LLaDA2MoePreTrainedModel):
|
| 741 |
+
"""
|
| 742 |
+
Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`LLaDA2MoeDecoderLayer`]
|
| 743 |
+
Args:
|
| 744 |
+
config: LLaDA2MoeConfig
|
| 745 |
+
"""
|
| 746 |
+
|
| 747 |
+
def __init__(self, config: LLaDA2MoeConfig):
|
| 748 |
+
super().__init__(config)
|
| 749 |
+
self.padding_idx = config.pad_token_id
|
| 750 |
+
self.vocab_size = config.vocab_size
|
| 751 |
+
|
| 752 |
+
self.word_embeddings = nn.Embedding(
|
| 753 |
+
config.vocab_size, config.hidden_size, self.padding_idx
|
| 754 |
+
)
|
| 755 |
+
self.layers = nn.ModuleList(
|
| 756 |
+
[
|
| 757 |
+
LLaDA2MoeDecoderLayer(config, layer_idx)
|
| 758 |
+
for layer_idx in range(config.num_hidden_layers)
|
| 759 |
+
]
|
| 760 |
+
)
|
| 761 |
+
|
| 762 |
+
self._use_sdpa = config._attn_implementation == "sdpa"
|
| 763 |
+
self._use_flash_attention_2 = config._attn_implementation == "flash_attention_2"
|
| 764 |
+
self.norm = LLaDA2MoERMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 765 |
+
self.rotary_emb = LLaDA2MoeRotaryEmbedding(config=config)
|
| 766 |
+
self.gradient_checkpointing = False
|
| 767 |
+
|
| 768 |
+
self.post_init()
|
| 769 |
+
|
| 770 |
+
def get_input_embeddings(self):
|
| 771 |
+
return self.word_embeddings
|
| 772 |
+
|
| 773 |
+
def set_input_embeddings(self, value):
|
| 774 |
+
self.word_embeddings = value
|
| 775 |
+
|
| 776 |
+
def forward(
|
| 777 |
+
self,
|
| 778 |
+
input_ids: torch.LongTensor = None,
|
| 779 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 780 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 781 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 782 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 783 |
+
use_cache: Optional[bool] = None,
|
| 784 |
+
output_attentions: Optional[bool] = None,
|
| 785 |
+
output_hidden_states: Optional[bool] = None,
|
| 786 |
+
output_router_logits: Optional[bool] = None,
|
| 787 |
+
cu_lengths_list: Optional[List] = None,
|
| 788 |
+
return_dict: Optional[bool] = None,
|
| 789 |
+
**kwargs,
|
| 790 |
+
) -> Union[Tuple, MoeModelOutputWithPast]:
|
| 791 |
+
output_attentions = (
|
| 792 |
+
output_attentions
|
| 793 |
+
if output_attentions is not None
|
| 794 |
+
else self.config.output_attentions
|
| 795 |
+
)
|
| 796 |
+
output_hidden_states = (
|
| 797 |
+
output_hidden_states
|
| 798 |
+
if output_hidden_states is not None
|
| 799 |
+
else self.config.output_hidden_states
|
| 800 |
+
)
|
| 801 |
+
output_router_logits = (
|
| 802 |
+
output_router_logits
|
| 803 |
+
if output_router_logits is not None
|
| 804 |
+
else self.config.output_router_logits
|
| 805 |
+
)
|
| 806 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
| 807 |
+
|
| 808 |
+
return_dict = (
|
| 809 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
| 810 |
+
)
|
| 811 |
+
|
| 812 |
+
if input_ids is not None and inputs_embeds is not None:
|
| 813 |
+
raise ValueError(
|
| 814 |
+
"You cannot specify both input_ids and inputs_embeds at the same time"
|
| 815 |
+
)
|
| 816 |
+
elif input_ids is not None:
|
| 817 |
+
batch_size, seq_length = input_ids.shape[:2]
|
| 818 |
+
elif inputs_embeds is not None:
|
| 819 |
+
batch_size, seq_length = inputs_embeds.shape[:2]
|
| 820 |
+
else:
|
| 821 |
+
raise ValueError("You have to specify either input_ids or inputs_embeds")
|
| 822 |
+
|
| 823 |
+
if self.gradient_checkpointing and self.training:
|
| 824 |
+
if use_cache:
|
| 825 |
+
logger.warning_once(
|
| 826 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`transformers."
|
| 827 |
+
)
|
| 828 |
+
use_cache = False
|
| 829 |
+
|
| 830 |
+
past_key_values_length = 0
|
| 831 |
+
if use_cache:
|
| 832 |
+
use_legacy_cache = not isinstance(past_key_values, Cache)
|
| 833 |
+
if use_legacy_cache:
|
| 834 |
+
past_key_values = DynamicCache.from_legacy_cache(past_key_values)
|
| 835 |
+
past_key_values_length = past_key_values.get_usable_length(seq_length)
|
| 836 |
+
|
| 837 |
+
if position_ids is None:
|
| 838 |
+
position_ids = calculate_pack_position_ids(
|
| 839 |
+
input_ids,
|
| 840 |
+
inputs_embeds,
|
| 841 |
+
position_ids,
|
| 842 |
+
past_key_values_length,
|
| 843 |
+
cu_lengths_list,
|
| 844 |
+
)
|
| 845 |
+
|
| 846 |
+
if inputs_embeds is None:
|
| 847 |
+
inputs_embeds = self.word_embeddings(input_ids)
|
| 848 |
+
|
| 849 |
+
if hasattr(attention_mask, "dim") and attention_mask.dim() == 2:
|
| 850 |
+
if self._use_sdpa and not output_attentions:
|
| 851 |
+
# output_attentions=True can not be supported when using SDPA, and we fall back on
|
| 852 |
+
# the manual implementation that requires a 4D causal mask in all cases.
|
| 853 |
+
attention_mask = _prepare_4d_causal_attention_mask_for_sdpa(
|
| 854 |
+
attention_mask,
|
| 855 |
+
(batch_size, seq_length),
|
| 856 |
+
inputs_embeds,
|
| 857 |
+
past_key_values_length,
|
| 858 |
+
)
|
| 859 |
+
else:
|
| 860 |
+
if attention_mask is not None:
|
| 861 |
+
attention_mask = _prepare_4d_attention_mask(
|
| 862 |
+
attention_mask, inputs_embeds.dtype
|
| 863 |
+
)
|
| 864 |
+
else:
|
| 865 |
+
attention_mask = _prepare_4d_causal_attention_mask(
|
| 866 |
+
attention_mask,
|
| 867 |
+
(batch_size, seq_length),
|
| 868 |
+
inputs_embeds,
|
| 869 |
+
past_key_values_length,
|
| 870 |
+
)
|
| 871 |
+
hidden_states = inputs_embeds
|
| 872 |
+
|
| 873 |
+
position_embeddings = self.rotary_emb(hidden_states, position_ids)
|
| 874 |
+
|
| 875 |
+
all_hidden_states = () if output_hidden_states else None
|
| 876 |
+
all_self_attns = () if output_attentions else None
|
| 877 |
+
all_router_logits = () if output_router_logits else None
|
| 878 |
+
next_decoder_cache = None
|
| 879 |
+
|
| 880 |
+
for decoder_layer in self.layers:
|
| 881 |
+
if output_hidden_states:
|
| 882 |
+
all_hidden_states += (hidden_states,)
|
| 883 |
+
|
| 884 |
+
if self.gradient_checkpointing and self.training:
|
| 885 |
+
layer_outputs = self._gradient_checkpointing_func(
|
| 886 |
+
decoder_layer.__call__,
|
| 887 |
+
hidden_states,
|
| 888 |
+
attention_mask,
|
| 889 |
+
position_ids,
|
| 890 |
+
past_key_values,
|
| 891 |
+
output_attentions,
|
| 892 |
+
output_router_logits,
|
| 893 |
+
use_cache,
|
| 894 |
+
position_embeddings,
|
| 895 |
+
)
|
| 896 |
+
else:
|
| 897 |
+
layer_outputs = decoder_layer(
|
| 898 |
+
hidden_states,
|
| 899 |
+
attention_mask=attention_mask,
|
| 900 |
+
position_ids=position_ids,
|
| 901 |
+
past_key_value=past_key_values,
|
| 902 |
+
output_attentions=output_attentions,
|
| 903 |
+
output_router_logits=output_router_logits,
|
| 904 |
+
use_cache=use_cache,
|
| 905 |
+
position_embeddings=position_embeddings,
|
| 906 |
+
)
|
| 907 |
+
hidden_states = layer_outputs[0]
|
| 908 |
+
|
| 909 |
+
if use_cache:
|
| 910 |
+
next_decoder_cache = layer_outputs[2 if output_attentions else 1]
|
| 911 |
+
|
| 912 |
+
if output_attentions:
|
| 913 |
+
all_self_attns += (layer_outputs[1],)
|
| 914 |
+
|
| 915 |
+
if output_router_logits and layer_outputs[-1] is not None:
|
| 916 |
+
all_router_logits += (layer_outputs[-1],)
|
| 917 |
+
|
| 918 |
+
hidden_states = self.norm(hidden_states)
|
| 919 |
+
|
| 920 |
+
if output_hidden_states:
|
| 921 |
+
all_hidden_states += (hidden_states,)
|
| 922 |
+
|
| 923 |
+
next_cache = None
|
| 924 |
+
if use_cache:
|
| 925 |
+
next_cache = (
|
| 926 |
+
next_decoder_cache.to_legacy_cache()
|
| 927 |
+
if use_legacy_cache
|
| 928 |
+
else next_decoder_cache
|
| 929 |
+
)
|
| 930 |
+
if not return_dict:
|
| 931 |
+
return tuple(
|
| 932 |
+
v
|
| 933 |
+
for v in [
|
| 934 |
+
hidden_states,
|
| 935 |
+
next_cache,
|
| 936 |
+
all_hidden_states,
|
| 937 |
+
all_self_attns,
|
| 938 |
+
all_router_logits,
|
| 939 |
+
]
|
| 940 |
+
if v is not None
|
| 941 |
+
)
|
| 942 |
+
return MoeModelOutputWithPast(
|
| 943 |
+
last_hidden_state=hidden_states,
|
| 944 |
+
past_key_values=next_cache,
|
| 945 |
+
hidden_states=all_hidden_states,
|
| 946 |
+
attentions=all_self_attns,
|
| 947 |
+
router_logits=all_router_logits,
|
| 948 |
+
)
|
| 949 |
+
|
| 950 |
+
|
| 951 |
+
@dataclass
|
| 952 |
+
class LLaDA2MoeCausalLMOutputWithPast(ModelOutput):
|
| 953 |
+
r"""
|
| 954 |
+
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
|
| 955 |
+
Training loss.
|
| 956 |
+
logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
|
| 957 |
+
Prediction scores for each vocabulary token before SoftMax.
|
| 958 |
+
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
|
| 959 |
+
It is a [`~cache_utils.Cache`] instance. For more details, see our [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache).
|
| 960 |
+
|
| 961 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
|
| 962 |
+
`past_key_values` input) to speed up sequential decoding.
|
| 963 |
+
rope_deltas (`torch.LongTensor` of shape `(batch_size, )`, *optional*):
|
| 964 |
+
The offset between the sequence length and rotary position indices.
|
| 965 |
+
"""
|
| 966 |
+
|
| 967 |
+
loss: Optional[torch.FloatTensor] = None
|
| 968 |
+
z_loss: Optional[torch.FloatTensor] = None
|
| 969 |
+
logits: Optional[torch.FloatTensor] = None
|
| 970 |
+
past_key_values: Optional[Cache] = None
|
| 971 |
+
hidden_states: Optional[tuple[torch.FloatTensor]] = None
|
| 972 |
+
attentions: Optional[tuple[torch.FloatTensor]] = None
|
| 973 |
+
rope_deltas: Optional[torch.LongTensor] = None
|
| 974 |
+
|
| 975 |
+
|
| 976 |
+
class LLaDA2MoeBackbone(nn.Module):
|
| 977 |
+
"""Container for the model backbone and output head."""
|
| 978 |
+
|
| 979 |
+
def __init__(self, config: LLaDA2MoeConfig):
|
| 980 |
+
super().__init__()
|
| 981 |
+
self.language_model = LLaDA2MoeModel(config)
|
| 982 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 983 |
+
|
| 984 |
+
def get_input_embeddings(self):
|
| 985 |
+
return self.language_model.get_input_embeddings()
|
| 986 |
+
|
| 987 |
+
def set_input_embeddings(self, value):
|
| 988 |
+
self.language_model.set_input_embeddings(value)
|
| 989 |
+
|
| 990 |
+
def forward(self, *args, **kwargs):
|
| 991 |
+
return self.language_model(*args, **kwargs)
|
| 992 |
+
|
| 993 |
+
|
| 994 |
+
class LLaDA2MoeModelLM(LLaDA2MoePreTrainedModel, GenerationMixin):
|
| 995 |
+
"""Fused LLaDA2 MoE model."""
|
| 996 |
+
|
| 997 |
+
accepts_loss_kwargs = False
|
| 998 |
+
|
| 999 |
+
def __init__(self, config: LLaDA2MoeConfig):
|
| 1000 |
+
super().__init__(config)
|
| 1001 |
+
self.model = LLaDA2MoeBackbone(config)
|
| 1002 |
+
self.img_token_id = 157184
|
| 1003 |
+
self.img_start_id = 157185
|
| 1004 |
+
self.img_end_id = 157186
|
| 1005 |
+
self.img_pad_id = 157187
|
| 1006 |
+
self.post_init()
|
| 1007 |
+
|
| 1008 |
+
@property
|
| 1009 |
+
def language_model(self):
|
| 1010 |
+
return self.model.language_model
|
| 1011 |
+
|
| 1012 |
+
def get_input_embeddings(self):
|
| 1013 |
+
return self.model.get_input_embeddings()
|
| 1014 |
+
|
| 1015 |
+
def set_input_embeddings(self, value):
|
| 1016 |
+
self.model.set_input_embeddings(value)
|
| 1017 |
+
|
| 1018 |
+
def get_output_embeddings(self):
|
| 1019 |
+
return self.model.lm_head
|
| 1020 |
+
|
| 1021 |
+
def set_output_embeddings(self, value):
|
| 1022 |
+
self.model.lm_head = value
|
| 1023 |
+
|
| 1024 |
+
def get_decoder(self):
|
| 1025 |
+
return self.model.language_model
|
| 1026 |
+
|
| 1027 |
+
def set_decoder(self, decoder):
|
| 1028 |
+
self.model.language_model = decoder
|
| 1029 |
+
|
| 1030 |
+
def forward(
|
| 1031 |
+
self,
|
| 1032 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1033 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1034 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1035 |
+
past_key_values: Optional[Cache] = None,
|
| 1036 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1037 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1038 |
+
use_cache: Optional[bool] = None,
|
| 1039 |
+
output_attentions: Optional[bool] = None,
|
| 1040 |
+
output_router_logits: Optional[bool] = None,
|
| 1041 |
+
output_hidden_states: Optional[bool] = None,
|
| 1042 |
+
return_dict: Optional[bool] = None,
|
| 1043 |
+
logits_to_keep: Union[int, torch.Tensor] = 0,
|
| 1044 |
+
cu_lengths_list: Optional[List] = None,
|
| 1045 |
+
**kwargs,
|
| 1046 |
+
) -> Union[tuple, LLaDA2MoeCausalLMOutputWithPast]:
|
| 1047 |
+
return_dict = (
|
| 1048 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
| 1049 |
+
)
|
| 1050 |
+
if inputs_embeds is None:
|
| 1051 |
+
if input_ids is None:
|
| 1052 |
+
raise ValueError("Provide either input_ids or inputs_embeds")
|
| 1053 |
+
inputs_embeds = self.get_input_embeddings()(input_ids)
|
| 1054 |
+
|
| 1055 |
+
outputs = self.model(
|
| 1056 |
+
input_ids=None,
|
| 1057 |
+
attention_mask=attention_mask,
|
| 1058 |
+
position_ids=position_ids,
|
| 1059 |
+
past_key_values=past_key_values,
|
| 1060 |
+
inputs_embeds=inputs_embeds,
|
| 1061 |
+
use_cache=use_cache,
|
| 1062 |
+
output_attentions=output_attentions,
|
| 1063 |
+
output_router_logits=output_router_logits,
|
| 1064 |
+
output_hidden_states=output_hidden_states,
|
| 1065 |
+
return_dict=True,
|
| 1066 |
+
cu_lengths_list=cu_lengths_list,
|
| 1067 |
+
**kwargs,
|
| 1068 |
+
)
|
| 1069 |
+
hidden_states = outputs.last_hidden_state
|
| 1070 |
+
indices = (
|
| 1071 |
+
slice(-logits_to_keep, None)
|
| 1072 |
+
if isinstance(logits_to_keep, int)
|
| 1073 |
+
else logits_to_keep
|
| 1074 |
+
)
|
| 1075 |
+
logits = self.model.lm_head(hidden_states[:, indices, :])
|
| 1076 |
+
|
| 1077 |
+
loss = None
|
| 1078 |
+
if labels is not None:
|
| 1079 |
+
loss = F.cross_entropy(
|
| 1080 |
+
logits.reshape(-1, logits.shape[-1]), labels.reshape(-1)
|
| 1081 |
+
)
|
| 1082 |
+
|
| 1083 |
+
if not return_dict:
|
| 1084 |
+
result = (
|
| 1085 |
+
logits,
|
| 1086 |
+
outputs.past_key_values,
|
| 1087 |
+
outputs.hidden_states,
|
| 1088 |
+
outputs.attentions,
|
| 1089 |
+
)
|
| 1090 |
+
return ((loss,) + result) if loss is not None else result
|
| 1091 |
+
return LLaDA2MoeCausalLMOutputWithPast(
|
| 1092 |
+
loss=loss,
|
| 1093 |
+
z_loss=None,
|
| 1094 |
+
logits=logits,
|
| 1095 |
+
past_key_values=outputs.past_key_values,
|
| 1096 |
+
hidden_states=outputs.hidden_states,
|
| 1097 |
+
attentions=outputs.attentions,
|
| 1098 |
+
rope_deltas=None,
|
| 1099 |
+
)
|
| 1100 |
+
|
| 1101 |
+
@staticmethod
|
| 1102 |
+
def _top_k_logits(logits, k):
|
| 1103 |
+
if k is None or k <= 0:
|
| 1104 |
+
return logits
|
| 1105 |
+
values, _ = torch.topk(logits, min(k, logits.shape[-1]))
|
| 1106 |
+
return torch.where(logits < values[..., -1, None], -torch.inf, logits)
|
| 1107 |
+
|
| 1108 |
+
@staticmethod
|
| 1109 |
+
def _top_p_logits(logits, p):
|
| 1110 |
+
if p is None or p >= 1.0:
|
| 1111 |
+
return logits
|
| 1112 |
+
sorted_logits, sorted_indices = torch.sort(logits, descending=True)
|
| 1113 |
+
cumulative_probs = torch.cumsum(F.softmax(sorted_logits, dim=-1), dim=-1)
|
| 1114 |
+
sorted_mask = cumulative_probs > p
|
| 1115 |
+
sorted_mask[..., 1:] = sorted_mask[..., :-1].clone()
|
| 1116 |
+
sorted_mask[..., 0] = False
|
| 1117 |
+
mask = torch.zeros_like(sorted_mask).scatter(-1, sorted_indices, sorted_mask)
|
| 1118 |
+
return logits.masked_fill(mask, -torch.inf)
|
| 1119 |
+
|
| 1120 |
+
def _sample_with_temperature_topk_topp(
|
| 1121 |
+
self, logits, temperature=1.0, top_k=0, top_p=1.0
|
| 1122 |
+
):
|
| 1123 |
+
original_shape = logits.shape[:-1]
|
| 1124 |
+
logits = logits.reshape(-1, logits.shape[-1])
|
| 1125 |
+
if (
|
| 1126 |
+
temperature == 0.0
|
| 1127 |
+
and (top_k in (None, 0))
|
| 1128 |
+
and (top_p is None or top_p >= 1.0)
|
| 1129 |
+
):
|
| 1130 |
+
probs = F.softmax(logits, dim=-1)
|
| 1131 |
+
token = logits.argmax(dim=-1, keepdim=True)
|
| 1132 |
+
token_prob = probs.gather(-1, token)
|
| 1133 |
+
return token.view(*original_shape), token_prob.view(*original_shape)
|
| 1134 |
+
if temperature > 0 and temperature != 1.0:
|
| 1135 |
+
logits = logits / temperature
|
| 1136 |
+
logits = self._top_k_logits(logits, top_k)
|
| 1137 |
+
logits = self._top_p_logits(logits, top_p)
|
| 1138 |
+
probs = F.softmax(logits, dim=-1)
|
| 1139 |
+
token = torch.multinomial(probs, num_samples=1)
|
| 1140 |
+
token_prob = probs.gather(-1, token)
|
| 1141 |
+
return token.view(*original_shape), token_prob.view(*original_shape)
|
| 1142 |
+
|
| 1143 |
+
@staticmethod
|
| 1144 |
+
def _get_num_transfer_tokens(block_length, steps):
|
| 1145 |
+
if steps == 0:
|
| 1146 |
+
return torch.empty(0, dtype=torch.int64)
|
| 1147 |
+
schedule = torch.full((steps,), block_length // steps, dtype=torch.int64)
|
| 1148 |
+
schedule[: block_length % steps] += 1
|
| 1149 |
+
return schedule
|
| 1150 |
+
|
| 1151 |
+
@torch.no_grad()
|
| 1152 |
+
def generate_bd_image_logic(
|
| 1153 |
+
self,
|
| 1154 |
+
data: Optional[dict] = None,
|
| 1155 |
+
temperature: float = 0.0,
|
| 1156 |
+
block_length: int = 32,
|
| 1157 |
+
steps: int = 32,
|
| 1158 |
+
gen_length: int = 2048,
|
| 1159 |
+
top_p: Optional[float] = None,
|
| 1160 |
+
top_k: Optional[int] = None,
|
| 1161 |
+
eos_early_stop: bool = True,
|
| 1162 |
+
minimal_topk: int = 1,
|
| 1163 |
+
threshold: float = 0.95,
|
| 1164 |
+
eos_id: int = 156892,
|
| 1165 |
+
mask_id: int = 156895,
|
| 1166 |
+
cfg_scale: float = 1.0,
|
| 1167 |
+
mode: str = "eoi",
|
| 1168 |
+
):
|
| 1169 |
+
"""Generate discrete image tokens with the original block-diffusion logic."""
|
| 1170 |
+
if data is None or "input_ids" not in data:
|
| 1171 |
+
raise ValueError("data must contain input_ids")
|
| 1172 |
+
steps = min(steps, gen_length // minimal_topk)
|
| 1173 |
+
input_ids = data["input_ids"]
|
| 1174 |
+
eoi_id = 156902
|
| 1175 |
+
prompt_length = input_ids.shape[1]
|
| 1176 |
+
num_blocks = (prompt_length + gen_length + block_length - 1) // block_length
|
| 1177 |
+
total_length = num_blocks * block_length
|
| 1178 |
+
|
| 1179 |
+
block_mask = torch.tril(torch.ones(num_blocks, num_blocks, device=self.device))
|
| 1180 |
+
full_attention_mask = (
|
| 1181 |
+
block_mask.repeat_interleave(block_length, 0)
|
| 1182 |
+
.repeat_interleave(block_length, 1)[None, None]
|
| 1183 |
+
.bool()
|
| 1184 |
+
)
|
| 1185 |
+
position_ids = torch.arange(total_length, device=self.device).unsqueeze(0)
|
| 1186 |
+
x = torch.full((1, total_length), mask_id, dtype=torch.long, device=self.device)
|
| 1187 |
+
x[:, :prompt_length] = input_ids
|
| 1188 |
+
prefill_blocks = prompt_length // block_length
|
| 1189 |
+
schedule = self._get_num_transfer_tokens(block_length, steps)
|
| 1190 |
+
use_cfg = cfg_scale != 1.0
|
| 1191 |
+
|
| 1192 |
+
if use_cfg:
|
| 1193 |
+
uncond_ids = data.get("uncond_ids", [27, 411, 19483, 29])
|
| 1194 |
+
if torch.is_tensor(uncond_ids):
|
| 1195 |
+
uncond_ids = uncond_ids.flatten().tolist()
|
| 1196 |
+
pad_len = prompt_length - len(uncond_ids)
|
| 1197 |
+
if pad_len < 0:
|
| 1198 |
+
raise ValueError(
|
| 1199 |
+
"The unconditional prompt is longer than the conditional prompt"
|
| 1200 |
+
)
|
| 1201 |
+
uncond_input = torch.full(
|
| 1202 |
+
(1, prompt_length), mask_id, dtype=torch.long, device=self.device
|
| 1203 |
+
)
|
| 1204 |
+
uncond_input[0, -len(uncond_ids) :] = torch.tensor(
|
| 1205 |
+
uncond_ids, device=self.device
|
| 1206 |
+
)
|
| 1207 |
+
uncond_attention_mask = full_attention_mask.clone()
|
| 1208 |
+
uncond_attention_mask[:, :, :, :pad_len] = False
|
| 1209 |
+
uncond_position_ids = torch.cat(
|
| 1210 |
+
[
|
| 1211 |
+
torch.zeros(pad_len, device=self.device, dtype=torch.long),
|
| 1212 |
+
torch.arange(total_length - pad_len, device=self.device),
|
| 1213 |
+
]
|
| 1214 |
+
).unsqueeze(0)
|
| 1215 |
+
|
| 1216 |
+
for block_index in range(prefill_blocks, num_blocks):
|
| 1217 |
+
window_end = (block_index + 1) * block_length
|
| 1218 |
+
current = x[:, :window_end]
|
| 1219 |
+
current_mask = full_attention_mask[:, :, :window_end, :window_end]
|
| 1220 |
+
current_positions = position_ids[:, :window_end]
|
| 1221 |
+
|
| 1222 |
+
for step_index in range(steps):
|
| 1223 |
+
active = current[:, -block_length:] == mask_id
|
| 1224 |
+
if not active.any():
|
| 1225 |
+
break
|
| 1226 |
+
if use_cfg:
|
| 1227 |
+
unconditional = current.clone()
|
| 1228 |
+
unconditional[:, :prompt_length] = uncond_input
|
| 1229 |
+
combined_ids = torch.cat([current, unconditional], dim=0)
|
| 1230 |
+
combined_positions = torch.cat(
|
| 1231 |
+
[current_positions, uncond_position_ids[:, :window_end]], dim=0
|
| 1232 |
+
)
|
| 1233 |
+
combined_mask = torch.cat(
|
| 1234 |
+
[
|
| 1235 |
+
current_mask,
|
| 1236 |
+
uncond_attention_mask[:, :, :window_end, :window_end],
|
| 1237 |
+
],
|
| 1238 |
+
dim=0,
|
| 1239 |
+
)
|
| 1240 |
+
logits = self(
|
| 1241 |
+
input_ids=combined_ids,
|
| 1242 |
+
attention_mask=combined_mask,
|
| 1243 |
+
position_ids=combined_positions,
|
| 1244 |
+
).logits
|
| 1245 |
+
conditional_logits, unconditional_logits = logits.chunk(2, dim=0)
|
| 1246 |
+
active_logits = unconditional_logits[
|
| 1247 |
+
:, -block_length:
|
| 1248 |
+
] + cfg_scale * (
|
| 1249 |
+
conditional_logits[:, -block_length:]
|
| 1250 |
+
- unconditional_logits[:, -block_length:]
|
| 1251 |
+
)
|
| 1252 |
+
else:
|
| 1253 |
+
active_logits = self(
|
| 1254 |
+
input_ids=current,
|
| 1255 |
+
attention_mask=current_mask,
|
| 1256 |
+
position_ids=current_positions,
|
| 1257 |
+
).logits[:, -block_length:]
|
| 1258 |
+
|
| 1259 |
+
tokens, confidence = self._sample_with_temperature_topk_topp(
|
| 1260 |
+
active_logits, temperature=temperature, top_k=top_k, top_p=top_p
|
| 1261 |
+
)
|
| 1262 |
+
count = schedule[step_index].item()
|
| 1263 |
+
scores = torch.where(active, confidence, -torch.inf)
|
| 1264 |
+
selected = torch.zeros_like(tokens, dtype=torch.bool)
|
| 1265 |
+
high_confidence = scores[0] > threshold
|
| 1266 |
+
if high_confidence.sum().item() >= count:
|
| 1267 |
+
selected[0] = high_confidence
|
| 1268 |
+
else:
|
| 1269 |
+
_, indices = torch.topk(
|
| 1270 |
+
scores[0], k=min(count, active.sum().item())
|
| 1271 |
+
)
|
| 1272 |
+
selected[0, indices] = True
|
| 1273 |
+
current[:, -block_length:][selected] = tokens[selected]
|
| 1274 |
+
|
| 1275 |
+
stop_token = eoi_id if mode == "eoi" else eos_id
|
| 1276 |
+
positions = (current[0, prompt_length:] == stop_token).nonzero(
|
| 1277 |
+
as_tuple=True
|
| 1278 |
+
)[0]
|
| 1279 |
+
if eos_early_stop and len(positions) > 0:
|
| 1280 |
+
stop_position = positions[0].item() + prompt_length
|
| 1281 |
+
if (current[0, prompt_length:stop_position] != mask_id).all():
|
| 1282 |
+
x[:, :window_end] = current
|
| 1283 |
+
return x[:, : stop_position + 1]
|
| 1284 |
+
|
| 1285 |
+
x[:, :window_end] = current
|
| 1286 |
+
return x[:, : prompt_length + gen_length]
|
| 1287 |
+
|
| 1288 |
+
|
| 1289 |
+
__all__ = ["LLaDA2MoeModelLM", "LLaDA2MoeModel", "LLaDA2MoePreTrainedModel"]
|
text_projection/config.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "LLaDAImageTextProjectionModel",
|
| 3 |
+
"_diffusers_version": "0.40.0.dev0",
|
| 4 |
+
"attention_dropout": 0.0,
|
| 5 |
+
"hidden_size": 2048,
|
| 6 |
+
"intermediate_size": 8960,
|
| 7 |
+
"norm_eps": 1e-06,
|
| 8 |
+
"num_attention_heads": 32,
|
| 9 |
+
"num_hidden_layers": 6,
|
| 10 |
+
"projection_dim": 2560
|
| 11 |
+
}
|
text_projection/diffusion_pytorch_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:484e8061b6cbaf0c51f15fe738a50c78fc6c2eeedea6a2461a6c42454c1842a9
|
| 3 |
+
size 652457384
|
tokenizer/special_tokens_map.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<|startoftext|>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"cls_token": {
|
| 10 |
+
"content": "[CLS]",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"eos_token": {
|
| 17 |
+
"content": "<|endoftext|>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"mask_token": {
|
| 24 |
+
"content": "<|mask|>",
|
| 25 |
+
"lstrip": false,
|
| 26 |
+
"normalized": false,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
},
|
| 30 |
+
"pad_token": {
|
| 31 |
+
"content": "<|endoftext|>",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": false,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false
|
| 36 |
+
}
|
| 37 |
+
}
|
tokenizer/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2197aeddaf09785316673451ca6fb86dcfcfdb108972a3145d106b8fa4c927e6
|
| 3 |
+
size 15297062
|
tokenizer/tokenizer_config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
transformer/config.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "LLaDAImageTransformer2DModel",
|
| 3 |
+
"_diffusers_version": "0.40.0.dev0",
|
| 4 |
+
"all_f_patch_size": [
|
| 5 |
+
1
|
| 6 |
+
],
|
| 7 |
+
"all_patch_size": [
|
| 8 |
+
1
|
| 9 |
+
],
|
| 10 |
+
"axes_dims": [
|
| 11 |
+
32,
|
| 12 |
+
48,
|
| 13 |
+
48
|
| 14 |
+
],
|
| 15 |
+
"axes_lens": [
|
| 16 |
+
32768,
|
| 17 |
+
1024,
|
| 18 |
+
1024
|
| 19 |
+
],
|
| 20 |
+
"cap_feat_dim": 2560,
|
| 21 |
+
"dim": 3840,
|
| 22 |
+
"in_channels": 128,
|
| 23 |
+
"n_heads": 30,
|
| 24 |
+
"n_layers": 30,
|
| 25 |
+
"n_refiner_layers": 2,
|
| 26 |
+
"norm_eps": 1e-05,
|
| 27 |
+
"qk_norm": true,
|
| 28 |
+
"rope_theta": 256.0,
|
| 29 |
+
"semantic_feat_dim": 4096,
|
| 30 |
+
"t_scale": 1000.0
|
| 31 |
+
}
|
transformer/diffusion_pytorch_model-00001-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4b4e6aa2553c0e77a9f6788e458ff5cfa63461a5adc52717a53f5961259690dd
|
| 3 |
+
size 4270676320
|
transformer/diffusion_pytorch_model-00002-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e65be04b75285a4eebd3d5db8b65f9626bb6310fb85dbb680be94adaec960196
|
| 3 |
+
size 4263909104
|
transformer/diffusion_pytorch_model-00003-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2a1ad2ae7bb3c85a91fc334ad2e78fa4806447c2db80fd1224bb5327a6d81595
|
| 3 |
+
size 4280490520
|
transformer/diffusion_pytorch_model-00004-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:85f7db3fdf86db51925ba43207c459baf94723685c12209a76748cbcc21d8652
|
| 3 |
+
size 265421296
|
transformer/diffusion_pytorch_model.safetensors.index.json
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 8 |
+
"all_final_layer.1-1.linear.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 9 |
+
"all_final_layer.1-1.linear.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 10 |
+
"all_x_embedder.1-1.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 11 |
+
"all_x_embedder.1-1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 12 |
+
"cap_embedder.1.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 13 |
+
"cap_embedder.1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 14 |
+
"cap_pad_token": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 15 |
+
"context_refiner.0.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 16 |
+
"context_refiner.0.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 17 |
+
"context_refiner.0.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 18 |
+
"context_refiner.0.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 19 |
+
"context_refiner.0.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 20 |
+
"context_refiner.0.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 21 |
+
"context_refiner.0.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 22 |
+
"context_refiner.1.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 23 |
+
"context_refiner.1.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 24 |
+
"context_refiner.1.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 25 |
+
"context_refiner.1.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 26 |
+
"context_refiner.1.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 27 |
+
"context_refiner.1.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 28 |
+
"context_refiner.1.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 29 |
+
"layers.0.adaLN_modulation.0.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 30 |
+
"layers.0.adaLN_modulation.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 31 |
+
"layers.0.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 32 |
+
"layers.0.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 33 |
+
"layers.0.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 34 |
+
"layers.0.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 35 |
+
"layers.0.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 36 |
+
"layers.0.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 37 |
+
"layers.0.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 38 |
+
"layers.1.adaLN_modulation.0.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 39 |
+
"layers.1.adaLN_modulation.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 40 |
+
"layers.1.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 41 |
+
"layers.1.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 42 |
+
"layers.1.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 43 |
+
"layers.1.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 44 |
+
"layers.1.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 45 |
+
"layers.1.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 46 |
+
"layers.1.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 47 |
+
"layers.10.adaLN_modulation.0.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 48 |
+
"layers.10.adaLN_modulation.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 49 |
+
"layers.10.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 50 |
+
"layers.10.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 51 |
+
"layers.10.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 52 |
+
"layers.10.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 53 |
+
"layers.10.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 54 |
+
"layers.10.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 55 |
+
"layers.10.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 56 |
+
"layers.11.adaLN_modulation.0.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 57 |
+
"layers.11.adaLN_modulation.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 58 |
+
"layers.11.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 59 |
+
"layers.11.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 60 |
+
"layers.11.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 61 |
+
"layers.11.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 62 |
+
"layers.11.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 63 |
+
"layers.11.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 64 |
+
"layers.11.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 65 |
+
"layers.12.adaLN_modulation.0.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 66 |
+
"layers.12.adaLN_modulation.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 67 |
+
"layers.12.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 68 |
+
"layers.12.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 69 |
+
"layers.12.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 70 |
+
"layers.12.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 71 |
+
"layers.12.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 72 |
+
"layers.12.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 73 |
+
"layers.12.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 74 |
+
"layers.13.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 75 |
+
"layers.13.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 76 |
+
"layers.13.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 77 |
+
"layers.13.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 78 |
+
"layers.13.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 79 |
+
"layers.13.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 80 |
+
"layers.13.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 81 |
+
"layers.13.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 82 |
+
"layers.13.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 83 |
+
"layers.14.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 84 |
+
"layers.14.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 85 |
+
"layers.14.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 86 |
+
"layers.14.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 87 |
+
"layers.14.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 88 |
+
"layers.14.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 89 |
+
"layers.14.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 90 |
+
"layers.14.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 91 |
+
"layers.14.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 92 |
+
"layers.15.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 93 |
+
"layers.15.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 94 |
+
"layers.15.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 95 |
+
"layers.15.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 96 |
+
"layers.15.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 97 |
+
"layers.15.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 98 |
+
"layers.15.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 99 |
+
"layers.15.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 100 |
+
"layers.15.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 101 |
+
"layers.16.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 102 |
+
"layers.16.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 103 |
+
"layers.16.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 104 |
+
"layers.16.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 105 |
+
"layers.16.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 106 |
+
"layers.16.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 107 |
+
"layers.16.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 108 |
+
"layers.16.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 109 |
+
"layers.16.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 110 |
+
"layers.17.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 111 |
+
"layers.17.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 112 |
+
"layers.17.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 113 |
+
"layers.17.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 114 |
+
"layers.17.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 115 |
+
"layers.17.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 116 |
+
"layers.17.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 117 |
+
"layers.17.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 118 |
+
"layers.17.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 119 |
+
"layers.18.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 120 |
+
"layers.18.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 121 |
+
"layers.18.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 122 |
+
"layers.18.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 123 |
+
"layers.18.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 124 |
+
"layers.18.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 125 |
+
"layers.18.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 126 |
+
"layers.18.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 127 |
+
"layers.18.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 128 |
+
"layers.19.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 129 |
+
"layers.19.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 130 |
+
"layers.19.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 131 |
+
"layers.19.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 132 |
+
"layers.19.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 133 |
+
"layers.19.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 134 |
+
"layers.19.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 135 |
+
"layers.19.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 136 |
+
"layers.19.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 137 |
+
"layers.2.adaLN_modulation.0.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 138 |
+
"layers.2.adaLN_modulation.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 139 |
+
"layers.2.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 140 |
+
"layers.2.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 141 |
+
"layers.2.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 142 |
+
"layers.2.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 143 |
+
"layers.2.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 144 |
+
"layers.2.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 145 |
+
"layers.2.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 146 |
+
"layers.20.adaLN_modulation.0.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 147 |
+
"layers.20.adaLN_modulation.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 148 |
+
"layers.20.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 149 |
+
"layers.20.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 150 |
+
"layers.20.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 151 |
+
"layers.20.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 152 |
+
"layers.20.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 153 |
+
"layers.20.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 154 |
+
"layers.20.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 155 |
+
"layers.21.adaLN_modulation.0.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 156 |
+
"layers.21.adaLN_modulation.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 157 |
+
"layers.21.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 158 |
+
"layers.21.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 159 |
+
"layers.21.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 160 |
+
"layers.21.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 161 |
+
"layers.21.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 162 |
+
"layers.21.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 163 |
+
"layers.21.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 164 |
+
"layers.22.adaLN_modulation.0.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 165 |
+
"layers.22.adaLN_modulation.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 166 |
+
"layers.22.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 167 |
+
"layers.22.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 168 |
+
"layers.22.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 169 |
+
"layers.22.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 170 |
+
"layers.22.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 171 |
+
"layers.22.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 172 |
+
"layers.22.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 173 |
+
"layers.23.adaLN_modulation.0.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 174 |
+
"layers.23.adaLN_modulation.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 175 |
+
"layers.23.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 176 |
+
"layers.23.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 177 |
+
"layers.23.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 178 |
+
"layers.23.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 179 |
+
"layers.23.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 180 |
+
"layers.23.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 181 |
+
"layers.23.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 182 |
+
"layers.24.adaLN_modulation.0.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 183 |
+
"layers.24.adaLN_modulation.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 184 |
+
"layers.24.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 185 |
+
"layers.24.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 186 |
+
"layers.24.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 187 |
+
"layers.24.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 188 |
+
"layers.24.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 189 |
+
"layers.24.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 190 |
+
"layers.24.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 191 |
+
"layers.25.adaLN_modulation.0.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 192 |
+
"layers.25.adaLN_modulation.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 193 |
+
"layers.25.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 194 |
+
"layers.25.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 195 |
+
"layers.25.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 196 |
+
"layers.25.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 197 |
+
"layers.25.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 198 |
+
"layers.25.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 199 |
+
"layers.25.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 200 |
+
"layers.26.adaLN_modulation.0.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 201 |
+
"layers.26.adaLN_modulation.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 202 |
+
"layers.26.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 203 |
+
"layers.26.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 204 |
+
"layers.26.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 205 |
+
"layers.26.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 206 |
+
"layers.26.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 207 |
+
"layers.26.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 208 |
+
"layers.26.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 209 |
+
"layers.27.adaLN_modulation.0.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 210 |
+
"layers.27.adaLN_modulation.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 211 |
+
"layers.27.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 212 |
+
"layers.27.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 213 |
+
"layers.27.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 214 |
+
"layers.27.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 215 |
+
"layers.27.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 216 |
+
"layers.27.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 217 |
+
"layers.27.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 218 |
+
"layers.28.adaLN_modulation.0.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 219 |
+
"layers.28.adaLN_modulation.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 220 |
+
"layers.28.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 221 |
+
"layers.28.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 222 |
+
"layers.28.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 223 |
+
"layers.28.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 224 |
+
"layers.28.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 225 |
+
"layers.28.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 226 |
+
"layers.28.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 227 |
+
"layers.29.adaLN_modulation.0.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 228 |
+
"layers.29.adaLN_modulation.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 229 |
+
"layers.29.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 230 |
+
"layers.29.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 231 |
+
"layers.29.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 232 |
+
"layers.29.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 233 |
+
"layers.29.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 234 |
+
"layers.29.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 235 |
+
"layers.29.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 236 |
+
"layers.3.adaLN_modulation.0.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 237 |
+
"layers.3.adaLN_modulation.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 238 |
+
"layers.3.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 239 |
+
"layers.3.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 240 |
+
"layers.3.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 241 |
+
"layers.3.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 242 |
+
"layers.3.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 243 |
+
"layers.3.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 244 |
+
"layers.3.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 245 |
+
"layers.4.adaLN_modulation.0.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 246 |
+
"layers.4.adaLN_modulation.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 247 |
+
"layers.4.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 248 |
+
"layers.4.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 249 |
+
"layers.4.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 250 |
+
"layers.4.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 251 |
+
"layers.4.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 252 |
+
"layers.4.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 253 |
+
"layers.4.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 254 |
+
"layers.5.adaLN_modulation.0.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 255 |
+
"layers.5.adaLN_modulation.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 256 |
+
"layers.5.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 257 |
+
"layers.5.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 258 |
+
"layers.5.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 259 |
+
"layers.5.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 260 |
+
"layers.5.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 261 |
+
"layers.5.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 262 |
+
"layers.5.feed_forward.w3.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 263 |
+
"layers.6.adaLN_modulation.0.bias": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 264 |
+
"layers.6.adaLN_modulation.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 265 |
+
"layers.6.attention.to_k.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 266 |
+
"layers.6.attention.to_out.0.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 267 |
+
"layers.6.attention.to_q.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 268 |
+
"layers.6.attention.to_v.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 269 |
+
"layers.6.feed_forward.w1.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 270 |
+
"layers.6.feed_forward.w2.weight": "diffusion_pytorch_model-00001-of-00004.safetensors",
|
| 271 |
+
"layers.6.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 272 |
+
"layers.7.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 273 |
+
"layers.7.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 274 |
+
"layers.7.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 275 |
+
"layers.7.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 276 |
+
"layers.7.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 277 |
+
"layers.7.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 278 |
+
"layers.7.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 279 |
+
"layers.7.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 280 |
+
"layers.7.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 281 |
+
"layers.8.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 282 |
+
"layers.8.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 283 |
+
"layers.8.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 284 |
+
"layers.8.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 285 |
+
"layers.8.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 286 |
+
"layers.8.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 287 |
+
"layers.8.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 288 |
+
"layers.8.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 289 |
+
"layers.8.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 290 |
+
"layers.9.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 291 |
+
"layers.9.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 292 |
+
"layers.9.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 293 |
+
"layers.9.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 294 |
+
"layers.9.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 295 |
+
"layers.9.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 296 |
+
"layers.9.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 297 |
+
"layers.9.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 298 |
+
"layers.9.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 299 |
+
"noise_refiner.0.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 300 |
+
"noise_refiner.0.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 301 |
+
"noise_refiner.0.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 302 |
+
"noise_refiner.0.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 303 |
+
"noise_refiner.0.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 304 |
+
"noise_refiner.0.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 305 |
+
"noise_refiner.0.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 306 |
+
"noise_refiner.0.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 307 |
+
"noise_refiner.0.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 308 |
+
"noise_refiner.1.adaLN_modulation.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 309 |
+
"noise_refiner.1.adaLN_modulation.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 310 |
+
"noise_refiner.1.attention.to_k.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 311 |
+
"noise_refiner.1.attention.to_out.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 312 |
+
"noise_refiner.1.attention.to_q.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 313 |
+
"noise_refiner.1.attention.to_v.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 314 |
+
"noise_refiner.1.feed_forward.w1.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 315 |
+
"noise_refiner.1.feed_forward.w2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 316 |
+
"noise_refiner.1.feed_forward.w3.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 317 |
+
"semantic_embedder.1.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 318 |
+
"semantic_embedder.1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 319 |
+
"sigvq_embedder.1.bias": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 320 |
+
"sigvq_embedder.1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 321 |
+
"sigvq_pad_token": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 322 |
+
"sigvq_refiner.0.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 323 |
+
"sigvq_refiner.0.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 324 |
+
"sigvq_refiner.0.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 325 |
+
"sigvq_refiner.0.attention.to_v.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 326 |
+
"sigvq_refiner.0.feed_forward.w1.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 327 |
+
"sigvq_refiner.0.feed_forward.w2.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 328 |
+
"sigvq_refiner.0.feed_forward.w3.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 329 |
+
"sigvq_refiner.1.attention.to_k.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 330 |
+
"sigvq_refiner.1.attention.to_out.0.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 331 |
+
"sigvq_refiner.1.attention.to_q.weight": "diffusion_pytorch_model-00003-of-00004.safetensors",
|
| 332 |
+
"sigvq_refiner.1.attention.to_v.weight": "diffusion_pytorch_model-00004-of-00004.safetensors",
|
| 333 |
+
"sigvq_refiner.1.feed_forward.w1.weight": "diffusion_pytorch_model-00004-of-00004.safetensors",
|
| 334 |
+
"sigvq_refiner.1.feed_forward.w2.weight": "diffusion_pytorch_model-00004-of-00004.safetensors",
|
| 335 |
+
"sigvq_refiner.1.feed_forward.w3.weight": "diffusion_pytorch_model-00004-of-00004.safetensors",
|
| 336 |
+
"t_embedder.mlp.0.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 337 |
+
"t_embedder.mlp.0.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 338 |
+
"t_embedder.mlp.2.bias": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 339 |
+
"t_embedder.mlp.2.weight": "diffusion_pytorch_model-00002-of-00004.safetensors",
|
| 340 |
+
"x_pad_token": "diffusion_pytorch_model-00002-of-00004.safetensors"
|
| 341 |
+
}
|
| 342 |
+
}
|
vae/config.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "AutoencoderKLFlux2",
|
| 3 |
+
"_diffusers_version": "0.36.0.dev0",
|
| 4 |
+
"act_fn": "silu",
|
| 5 |
+
"batch_norm_eps": 0.0001,
|
| 6 |
+
"batch_norm_momentum": 0.1,
|
| 7 |
+
"block_out_channels": [
|
| 8 |
+
128,
|
| 9 |
+
256,
|
| 10 |
+
512,
|
| 11 |
+
512
|
| 12 |
+
],
|
| 13 |
+
"down_block_types": [
|
| 14 |
+
"DownEncoderBlock2D",
|
| 15 |
+
"DownEncoderBlock2D",
|
| 16 |
+
"DownEncoderBlock2D",
|
| 17 |
+
"DownEncoderBlock2D"
|
| 18 |
+
],
|
| 19 |
+
"force_upcast": true,
|
| 20 |
+
"in_channels": 3,
|
| 21 |
+
"latent_channels": 32,
|
| 22 |
+
"layers_per_block": 2,
|
| 23 |
+
"mid_block_add_attention": true,
|
| 24 |
+
"norm_num_groups": 32,
|
| 25 |
+
"out_channels": 3,
|
| 26 |
+
"patch_size": [
|
| 27 |
+
2,
|
| 28 |
+
2
|
| 29 |
+
],
|
| 30 |
+
"sample_size": 1024,
|
| 31 |
+
"up_block_types": [
|
| 32 |
+
"UpDecoderBlock2D",
|
| 33 |
+
"UpDecoderBlock2D",
|
| 34 |
+
"UpDecoderBlock2D",
|
| 35 |
+
"UpDecoderBlock2D"
|
| 36 |
+
],
|
| 37 |
+
"use_post_quant_conv": true,
|
| 38 |
+
"use_quant_conv": true
|
| 39 |
+
}
|
vae/diffusion_pytorch_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:19874383f29bd4a716be716520647261e38aeaa50dcc29559e5f8d8186cf8f43
|
| 3 |
+
size 168120872
|