Upload folder using huggingface_hub
Browse files- config.json +120 -0
- configuration_llada.py +463 -0
- generation_config.json +6 -0
- model-00001-of-00005.safetensors +3 -0
- model-00002-of-00005.safetensors +3 -0
- model-00003-of-00005.safetensors +3 -0
- model-00004-of-00005.safetensors +3 -0
- model-00005-of-00005.safetensors +3 -0
- model.safetensors.index.json +0 -0
- special_tokens_map.json +0 -0
- tokenizer.json +0 -0
- tokenizer_config.json +0 -0
- training_args.bin +3 -0
- vqvae/config.json +39 -0
- vqvae/diffusion_pytorch_model.fp16.safetensors +3 -0
- vqvae/diffusion_pytorch_model.safetensors +3 -0
config.json
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_type": "silu",
|
| 3 |
+
"add_faster_video": false,
|
| 4 |
+
"add_time_instruction": false,
|
| 5 |
+
"alibi": false,
|
| 6 |
+
"alibi_bias_max": 8.0,
|
| 7 |
+
"architectures": [
|
| 8 |
+
"LlavaLladaForMaskedDiffusion"
|
| 9 |
+
],
|
| 10 |
+
"attention_dropout": 0.0,
|
| 11 |
+
"attention_layer_norm": false,
|
| 12 |
+
"attention_layer_norm_with_affine": true,
|
| 13 |
+
"auto_map": {
|
| 14 |
+
"AutoConfig": "configuration_llada.LLaDAConfig",
|
| 15 |
+
"AutoModel": "modeling_llada.LLaDAModelLM",
|
| 16 |
+
"AutoModelForCausalLM": "modeling_llada.LLaDAModelLM"
|
| 17 |
+
},
|
| 18 |
+
"bias_for_layer_norm": false,
|
| 19 |
+
"block_group_size": 1,
|
| 20 |
+
"block_type": "llama",
|
| 21 |
+
"d_model": 4096,
|
| 22 |
+
"d_model_gen": 2048,
|
| 23 |
+
"downsample": true,
|
| 24 |
+
"dual_tower": true,
|
| 25 |
+
"dual_tower_layers": 16,
|
| 26 |
+
"effective_n_kv_heads": 32,
|
| 27 |
+
"embedding_dropout": 0.0,
|
| 28 |
+
"embedding_size": 127378,
|
| 29 |
+
"enc_use_image_branch": true,
|
| 30 |
+
"eos_token_id": 126081,
|
| 31 |
+
"faster_token_stride": 10,
|
| 32 |
+
"flash_attention": false,
|
| 33 |
+
"force_sample": false,
|
| 34 |
+
"gen_mlp_type": "dit2",
|
| 35 |
+
"image_aspect_ratio": "anyres",
|
| 36 |
+
"image_crop_resolution": null,
|
| 37 |
+
"image_enc_drop_rate": 0.5,
|
| 38 |
+
"image_grid_pinpoints": [
|
| 39 |
+
[
|
| 40 |
+
384,
|
| 41 |
+
768
|
| 42 |
+
],
|
| 43 |
+
[
|
| 44 |
+
768,
|
| 45 |
+
384
|
| 46 |
+
],
|
| 47 |
+
[
|
| 48 |
+
768,
|
| 49 |
+
768
|
| 50 |
+
],
|
| 51 |
+
[
|
| 52 |
+
1152,
|
| 53 |
+
384
|
| 54 |
+
],
|
| 55 |
+
[
|
| 56 |
+
384,
|
| 57 |
+
1152
|
| 58 |
+
]
|
| 59 |
+
],
|
| 60 |
+
"image_split_resolution": null,
|
| 61 |
+
"include_bias": false,
|
| 62 |
+
"include_qkv_bias": false,
|
| 63 |
+
"init_cutoff_factor": null,
|
| 64 |
+
"init_device": "cpu",
|
| 65 |
+
"init_fn": "mitchell",
|
| 66 |
+
"init_std": 0.02,
|
| 67 |
+
"input_emb_norm": false,
|
| 68 |
+
"layer_norm_type": "rms",
|
| 69 |
+
"layer_norm_with_affine": true,
|
| 70 |
+
"mask_token_id": 126336,
|
| 71 |
+
"max_sequence_length": 4096,
|
| 72 |
+
"mlp_hidden_size": 12288,
|
| 73 |
+
"mlp_hidden_size_gen": 8192,
|
| 74 |
+
"mlp_ratio": 4,
|
| 75 |
+
"mm_hidden_size": 1152,
|
| 76 |
+
"mm_newline_position": "grid",
|
| 77 |
+
"mm_patch_merge_type": "spatial_unpad",
|
| 78 |
+
"mm_pooler_ratio": 2,
|
| 79 |
+
"mm_projector_lr": null,
|
| 80 |
+
"mm_projector_type": "mlp2x_gelu",
|
| 81 |
+
"mm_resampler_type": "spatial_pool",
|
| 82 |
+
"mm_spatial_pool_mode": "conv",
|
| 83 |
+
"mm_spatial_pool_out_channels": 1152,
|
| 84 |
+
"mm_spatial_pool_stride": 2,
|
| 85 |
+
"mm_tunable_parts": "mm_vision_tower,mm_mlp_adapter,mm_vision_resampler,mm_language_model,mm_language_model_vision_parms",
|
| 86 |
+
"mm_use_im_patch_token": false,
|
| 87 |
+
"mm_use_im_start_end": false,
|
| 88 |
+
"mm_vision_select_feature": "patch",
|
| 89 |
+
"mm_vision_select_layer": -2,
|
| 90 |
+
"mm_vision_tower": "google/siglip-so400m-patch14-384",
|
| 91 |
+
"mm_vision_tower_lr": 2e-06,
|
| 92 |
+
"mm_vqvae": "jacklishufan/LaViDa-O-v1.0",
|
| 93 |
+
"model_type": "llada",
|
| 94 |
+
"multi_query_attention": null,
|
| 95 |
+
"n_heads": 32,
|
| 96 |
+
"n_kv_heads": 32,
|
| 97 |
+
"n_layers": 32,
|
| 98 |
+
"pad_token_id": 126081,
|
| 99 |
+
"pos_skipping_range": 4096,
|
| 100 |
+
"precision": "amp_bf16",
|
| 101 |
+
"prompt_drop_rate": 0.1,
|
| 102 |
+
"resampler_type": null,
|
| 103 |
+
"residual_dropout": 0.0,
|
| 104 |
+
"rms_norm_eps": 1e-05,
|
| 105 |
+
"rope": true,
|
| 106 |
+
"rope_full_precision": true,
|
| 107 |
+
"rope_theta": 500000.0,
|
| 108 |
+
"scale_logits": false,
|
| 109 |
+
"tie_word_embeddings": false,
|
| 110 |
+
"tokenizer_model_max_length": 8192,
|
| 111 |
+
"tokenizer_padding_side": "right",
|
| 112 |
+
"torch_dtype": "bfloat16",
|
| 113 |
+
"transformers_version": "4.50.3",
|
| 114 |
+
"use_cache": false,
|
| 115 |
+
"use_mm_proj": true,
|
| 116 |
+
"use_pos_skipping": false,
|
| 117 |
+
"vision_tower_pretrained": null,
|
| 118 |
+
"vocab_size": 127378,
|
| 119 |
+
"weight_tying": false
|
| 120 |
+
}
|
configuration_llada.py
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
LLaDA configuration
|
| 3 |
+
"""
|
| 4 |
+
from transformers import AutoConfig, PretrainedConfig
|
| 5 |
+
|
| 6 |
+
from enum import Enum
|
| 7 |
+
from os import PathLike
|
| 8 |
+
from typing import Union
|
| 9 |
+
from dataclasses import asdict, dataclass, field
|
| 10 |
+
from glob import glob
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
from typing import (
|
| 13 |
+
Any,
|
| 14 |
+
Dict,
|
| 15 |
+
Iterable,
|
| 16 |
+
List,
|
| 17 |
+
Optional,
|
| 18 |
+
Tuple,
|
| 19 |
+
Type,
|
| 20 |
+
TypeVar,
|
| 21 |
+
Union,
|
| 22 |
+
cast,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
__all__ = [
|
| 27 |
+
"ActivationType",
|
| 28 |
+
"ActivationCheckpointingStrategy",
|
| 29 |
+
"BlockType",
|
| 30 |
+
"LayerNormType",
|
| 31 |
+
"InitFnType",
|
| 32 |
+
"ModelConfig",
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
PathOrStr = Union[str, PathLike]
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class StrEnum(str, Enum):
|
| 39 |
+
"""
|
| 40 |
+
This is equivalent to Python's :class:`enum.StrEnum` since version 3.11.
|
| 41 |
+
We include this here for compatibility with older version of Python.
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
def __str__(self) -> str:
|
| 45 |
+
return self.value
|
| 46 |
+
|
| 47 |
+
def __repr__(self) -> str:
|
| 48 |
+
return f"'{str(self)}'"
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class LayerNormType(StrEnum):
|
| 52 |
+
default = "default"
|
| 53 |
+
"""
|
| 54 |
+
The default LayerNorm implementation, equivalent to PyTorch's built-in version.
|
| 55 |
+
"""
|
| 56 |
+
|
| 57 |
+
low_precision = "low_precision"
|
| 58 |
+
"""
|
| 59 |
+
A low-precision version of the default LayerNorm.
|
| 60 |
+
"""
|
| 61 |
+
|
| 62 |
+
rms = "rms"
|
| 63 |
+
"""
|
| 64 |
+
An RMSNorm implementation. When using ``torch.compile`` this is
|
| 65 |
+
probably the fastest implementation.
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
gemma_rms = "gemma_rms"
|
| 69 |
+
"""
|
| 70 |
+
An RMSNorm implementation by gemmma. When using ``torch.compile`` this is
|
| 71 |
+
probably the fastest implementation.
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
amd_compatible = "amd_compatible"
|
| 75 |
+
"""
|
| 76 |
+
LayerNorm implemented manually to work around an issue with ROCm.
|
| 77 |
+
"""
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class ActivationType(StrEnum):
|
| 81 |
+
gelu = "gelu"
|
| 82 |
+
relu = "relu"
|
| 83 |
+
silu = "silu"
|
| 84 |
+
swiglu = "swiglu"
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
class BlockType(StrEnum):
|
| 88 |
+
sequential = "sequential"
|
| 89 |
+
parallel = "parallel"
|
| 90 |
+
|
| 91 |
+
llama = "llama"
|
| 92 |
+
"""
|
| 93 |
+
A block similar to the sequential block with slightly different
|
| 94 |
+
implementations of operations like attention to imitate the behavior of Llama.
|
| 95 |
+
"""
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
class InitFnType(StrEnum):
|
| 99 |
+
mitchell = "mitchell"
|
| 100 |
+
"""
|
| 101 |
+
The strategy suggested to us by Mitchell Wortsman from UW.
|
| 102 |
+
This uses a truncated normal distribution with an adaptive standard deviation that depends
|
| 103 |
+
on the size of the weights as well as the depth of the layer.
|
| 104 |
+
"""
|
| 105 |
+
|
| 106 |
+
normal = "normal"
|
| 107 |
+
"""
|
| 108 |
+
All weights are initialized from the same normal distribution.
|
| 109 |
+
"""
|
| 110 |
+
|
| 111 |
+
kaiming_normal = "kaiming_normal"
|
| 112 |
+
"""
|
| 113 |
+
All weights are initialized with the Kaiming method from a normal distribution.
|
| 114 |
+
Note this currently won't work with FSDP.
|
| 115 |
+
"""
|
| 116 |
+
|
| 117 |
+
fan_in = "fan_in"
|
| 118 |
+
"""
|
| 119 |
+
"Fan-in variance scaling", i.e. normal with a standard deviation of ``1/sqrt(d_in)`` where ``d_in``
|
| 120 |
+
is the input dimensionality of the kernel.
|
| 121 |
+
"""
|
| 122 |
+
|
| 123 |
+
full_megatron = "full_megatron"
|
| 124 |
+
"""
|
| 125 |
+
This is what metaseq calls "full megatron init". It is the init used for Llama 2.
|
| 126 |
+
"""
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
@dataclass
|
| 130 |
+
class ModelConfig():
|
| 131 |
+
"""
|
| 132 |
+
LLaDA (model) configuration.
|
| 133 |
+
"""
|
| 134 |
+
|
| 135 |
+
# Note that the defaults for these attributes are equivalent to the base GPT2 model.
|
| 136 |
+
|
| 137 |
+
d_model: int = 768
|
| 138 |
+
"""
|
| 139 |
+
The hidden size of the model.
|
| 140 |
+
"""
|
| 141 |
+
|
| 142 |
+
n_heads: int = 12
|
| 143 |
+
"""
|
| 144 |
+
The number of self-attention heads.
|
| 145 |
+
"""
|
| 146 |
+
|
| 147 |
+
n_kv_heads: Optional[int] = None
|
| 148 |
+
"""
|
| 149 |
+
The number of heads to use for keys and values. Defaults to `n_heads`.
|
| 150 |
+
Set this to ``None`` or ``n_heads`` for normal multi-head attention.
|
| 151 |
+
Set this to 1 for multi-query attention.
|
| 152 |
+
Set it to some in-between value for Llama2-style grouped query attention.
|
| 153 |
+
"""
|
| 154 |
+
|
| 155 |
+
n_layers: int = 12
|
| 156 |
+
"""
|
| 157 |
+
The number of layers/blocks.
|
| 158 |
+
"""
|
| 159 |
+
|
| 160 |
+
mlp_ratio: int = 4
|
| 161 |
+
"""
|
| 162 |
+
The ratio of the inner MLP dimensionality to ``d_model``.
|
| 163 |
+
This is only used when ``mlp_hidden_size`` is not set.
|
| 164 |
+
"""
|
| 165 |
+
|
| 166 |
+
mlp_hidden_size: Optional[int] = None
|
| 167 |
+
"""
|
| 168 |
+
Set the exact hidden size for the MLP. Otherwise the inner MLP hidden size will be set to `mlp_ratio * d_model`.
|
| 169 |
+
"""
|
| 170 |
+
|
| 171 |
+
activation_type: ActivationType = ActivationType.swiglu
|
| 172 |
+
"""
|
| 173 |
+
The activation function to use within the MLP layers.
|
| 174 |
+
"""
|
| 175 |
+
|
| 176 |
+
block_type: BlockType = BlockType.sequential
|
| 177 |
+
"""
|
| 178 |
+
The transformer block implementation.
|
| 179 |
+
"""
|
| 180 |
+
|
| 181 |
+
block_group_size: int = 1
|
| 182 |
+
"""
|
| 183 |
+
The number of blocks to group together into a single parent block.
|
| 184 |
+
This has no affect on the number of parameters in the model and is only used to wrap groups
|
| 185 |
+
of blocks together with a single FSDP wrapper during training.
|
| 186 |
+
"""
|
| 187 |
+
|
| 188 |
+
alibi: bool = False
|
| 189 |
+
"""
|
| 190 |
+
If ``True``, use ALiBi embeddings. Mutually exclusive with ``rope``.
|
| 191 |
+
"""
|
| 192 |
+
|
| 193 |
+
alibi_bias_max: float = 8.0
|
| 194 |
+
"""
|
| 195 |
+
Maximum absolute value of ALiBi bias.
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
rope: bool = False
|
| 199 |
+
"""
|
| 200 |
+
Use rotary positional embeddings (RoPE). Mutually exclusive with ``alibi``.
|
| 201 |
+
"""
|
| 202 |
+
|
| 203 |
+
rope_full_precision: bool = True
|
| 204 |
+
"""
|
| 205 |
+
If ``True``, apply RoPE embeddings at full precision regardless of the input type. Otherwise,
|
| 206 |
+
apply RoPE at the precision of the input.
|
| 207 |
+
"""
|
| 208 |
+
|
| 209 |
+
flash_attention: bool = False
|
| 210 |
+
"""
|
| 211 |
+
If ``True``, use ``FlashAttention``.
|
| 212 |
+
"""
|
| 213 |
+
|
| 214 |
+
attention_dropout: float = 0.1
|
| 215 |
+
"""
|
| 216 |
+
The dropout probability within the attention modules.
|
| 217 |
+
"""
|
| 218 |
+
|
| 219 |
+
multi_query_attention: Optional[bool] = None
|
| 220 |
+
"""
|
| 221 |
+
Use the Multi-Query formulation of attention used in PaLM. This reduces the number of parameters
|
| 222 |
+
and is more efficient during inference.
|
| 223 |
+
"""
|
| 224 |
+
|
| 225 |
+
attention_layer_norm: bool = False
|
| 226 |
+
"""
|
| 227 |
+
Apply layer norm to the keys and queries within the attention mechanism.
|
| 228 |
+
This can help stabilize training.
|
| 229 |
+
"""
|
| 230 |
+
|
| 231 |
+
residual_dropout: float = 0.1
|
| 232 |
+
"""
|
| 233 |
+
The dropout probability for the MLP and attention output within each block.
|
| 234 |
+
"""
|
| 235 |
+
|
| 236 |
+
embedding_dropout: float = 0.1
|
| 237 |
+
"""
|
| 238 |
+
The dropout probability for embeddings.
|
| 239 |
+
"""
|
| 240 |
+
|
| 241 |
+
input_emb_norm: bool = False
|
| 242 |
+
"""
|
| 243 |
+
An input hidden_states norm implementation by gemmma.
|
| 244 |
+
"""
|
| 245 |
+
|
| 246 |
+
layer_norm_type: LayerNormType = LayerNormType.default
|
| 247 |
+
"""
|
| 248 |
+
The layernorm implementation to use.
|
| 249 |
+
"""
|
| 250 |
+
|
| 251 |
+
layer_norm_with_affine: bool = True
|
| 252 |
+
"""
|
| 253 |
+
Whether to include bias and weight parameters for the layer norms.
|
| 254 |
+
This only affects layer norms that are immediately followed by a linear layer in the forward pass,
|
| 255 |
+
so everything except QK-norms. To turn off affines for QK norms as well, set :attr:`attention_layer_norm_with_affine`
|
| 256 |
+
to ``False``.
|
| 257 |
+
"""
|
| 258 |
+
|
| 259 |
+
rms_norm_eps: float = 1e-05
|
| 260 |
+
"""
|
| 261 |
+
The rms layernorm eps param.
|
| 262 |
+
"""
|
| 263 |
+
|
| 264 |
+
attention_layer_norm_with_affine: bool = True
|
| 265 |
+
"""
|
| 266 |
+
Toggle affine transform for the QK norms.
|
| 267 |
+
"""
|
| 268 |
+
|
| 269 |
+
max_sequence_length: int = 1024
|
| 270 |
+
"""
|
| 271 |
+
The maximum input sequence length supported by the model.
|
| 272 |
+
"""
|
| 273 |
+
|
| 274 |
+
rope_theta: float = 10000.0
|
| 275 |
+
"""
|
| 276 |
+
The rope base param.
|
| 277 |
+
"""
|
| 278 |
+
|
| 279 |
+
include_qkv_bias: Optional[bool] = False
|
| 280 |
+
"""
|
| 281 |
+
Whether or not to include bias parameters in qkv linear layers.
|
| 282 |
+
"""
|
| 283 |
+
|
| 284 |
+
include_bias: bool = False
|
| 285 |
+
"""
|
| 286 |
+
Whether or not to include bias parameters in linear layers.
|
| 287 |
+
In PaLM, they got rid of all bias terms because they found that large
|
| 288 |
+
models tend to have near 0 bias terms anyway.
|
| 289 |
+
"""
|
| 290 |
+
|
| 291 |
+
bias_for_layer_norm: Optional[bool] = None
|
| 292 |
+
"""
|
| 293 |
+
Whether or not to include bias parameters in layer norm.
|
| 294 |
+
This is separate from the include_bias parameter, because of a ROCm crash when biases are disabled in
|
| 295 |
+
layer norm.
|
| 296 |
+
When this is None (the default), it inherits the setting from include_bias.
|
| 297 |
+
"""
|
| 298 |
+
|
| 299 |
+
scale_logits: bool = False
|
| 300 |
+
"""
|
| 301 |
+
If ``True``, scale the output logits by ``1 / sqrt(d_model)``.
|
| 302 |
+
"""
|
| 303 |
+
|
| 304 |
+
vocab_size: int = 50257
|
| 305 |
+
"""
|
| 306 |
+
Vocabulary size of the model.
|
| 307 |
+
"""
|
| 308 |
+
|
| 309 |
+
embedding_size: Optional[int] = 50304
|
| 310 |
+
"""
|
| 311 |
+
The number of embeddings, i.e. the number of tokens. If set to ``None`` it will default
|
| 312 |
+
to ``vocab_size``. If ``vocab_size`` is not a multiple of 128, setting this to the
|
| 313 |
+
next multiple of 128 that's greater than ``vocab_size`` can improve throughput
|
| 314 |
+
substantially.
|
| 315 |
+
"""
|
| 316 |
+
|
| 317 |
+
weight_tying: bool = True
|
| 318 |
+
"""
|
| 319 |
+
Whether to tie output linear weights to the input embedding.
|
| 320 |
+
"""
|
| 321 |
+
|
| 322 |
+
eos_token_id: int = 50256
|
| 323 |
+
"""
|
| 324 |
+
The ID of the end-of-sentence special token.
|
| 325 |
+
"""
|
| 326 |
+
|
| 327 |
+
pad_token_id: int = 50256
|
| 328 |
+
"""
|
| 329 |
+
The ID of the token to use for padding. Defaults to the ID of the EOS token.
|
| 330 |
+
"""
|
| 331 |
+
|
| 332 |
+
mask_token_id: Optional[int] = 50256
|
| 333 |
+
"""
|
| 334 |
+
The ID of the token to use for mask token. Defaults to the ID of the EOS token.
|
| 335 |
+
"""
|
| 336 |
+
|
| 337 |
+
init_device: Optional[str] = None
|
| 338 |
+
"""
|
| 339 |
+
The torch device to use when initializing the model parameters, e.g. "cpu", "cuda:0", "meta".
|
| 340 |
+
"""
|
| 341 |
+
|
| 342 |
+
init_fn: InitFnType = InitFnType.normal
|
| 343 |
+
"""
|
| 344 |
+
The weight initialization strategy.
|
| 345 |
+
"""
|
| 346 |
+
|
| 347 |
+
init_std: float = 0.02
|
| 348 |
+
"""
|
| 349 |
+
The standard deviation to use when initializing weights with a "fixed distribution" ``init_fn``, such
|
| 350 |
+
as "normal".
|
| 351 |
+
"""
|
| 352 |
+
|
| 353 |
+
init_cutoff_factor: Optional[float] = None
|
| 354 |
+
"""
|
| 355 |
+
A positive factor used to scale the cutoff values when initializing weights with a "fixed distribution" ``init_fn``, such
|
| 356 |
+
as "normal". Setting this to None means values are not cutoff.
|
| 357 |
+
"""
|
| 358 |
+
|
| 359 |
+
precision: Optional[str] = None
|
| 360 |
+
"""
|
| 361 |
+
Precision used to train/evaluate with. You shouldn't set this directly.
|
| 362 |
+
See :data:`TrainConfig.precision` instead.
|
| 363 |
+
"""
|
| 364 |
+
|
| 365 |
+
@property
|
| 366 |
+
def effective_n_kv_heads(self) -> int:
|
| 367 |
+
if self.n_kv_heads is None:
|
| 368 |
+
if self.multi_query_attention is True:
|
| 369 |
+
return 1
|
| 370 |
+
else:
|
| 371 |
+
return self.n_heads
|
| 372 |
+
else:
|
| 373 |
+
if self.multi_query_attention is None:
|
| 374 |
+
return self.n_kv_heads
|
| 375 |
+
if self.multi_query_attention:
|
| 376 |
+
n_kv_heads_should_be = 1
|
| 377 |
+
else:
|
| 378 |
+
n_kv_heads_should_be = self.n_heads
|
| 379 |
+
if self.n_kv_heads == n_kv_heads_should_be:
|
| 380 |
+
return n_kv_heads_should_be
|
| 381 |
+
else:
|
| 382 |
+
raise Exception(
|
| 383 |
+
"You can't set `multi_query_attention` and `n_kv_heads` at the same time."
|
| 384 |
+
)
|
| 385 |
+
|
| 386 |
+
class ActivationCheckpointingStrategy(StrEnum):
|
| 387 |
+
whole_layer = "whole_layer"
|
| 388 |
+
"""
|
| 389 |
+
Checkpoint every transformer layer.
|
| 390 |
+
"""
|
| 391 |
+
|
| 392 |
+
one_in_two = "one_in_two"
|
| 393 |
+
"""
|
| 394 |
+
Checkpoint one in two transformer layers.
|
| 395 |
+
"""
|
| 396 |
+
|
| 397 |
+
one_in_three = "one_in_three"
|
| 398 |
+
"""
|
| 399 |
+
Checkpoint one in three transformer layers.
|
| 400 |
+
"""
|
| 401 |
+
|
| 402 |
+
one_in_four = "one_in_four"
|
| 403 |
+
"""
|
| 404 |
+
Checkpoint one in four transformer layers.
|
| 405 |
+
"""
|
| 406 |
+
|
| 407 |
+
two_in_three = "two_in_three"
|
| 408 |
+
"""
|
| 409 |
+
Checkpoint two out of every three transformer layers.
|
| 410 |
+
"""
|
| 411 |
+
|
| 412 |
+
three_in_four = "three_in_four"
|
| 413 |
+
"""
|
| 414 |
+
Checkpoint three out of four of every transformer layers.
|
| 415 |
+
"""
|
| 416 |
+
|
| 417 |
+
four_in_five = "four_in_five"
|
| 418 |
+
"""
|
| 419 |
+
Checkpoint four out of five of every transformer layers.
|
| 420 |
+
"""
|
| 421 |
+
|
| 422 |
+
nine_in_ten = "nine_in_ten"
|
| 423 |
+
"""
|
| 424 |
+
Checkpoint nine out of ten of every transformer layers.
|
| 425 |
+
"""
|
| 426 |
+
|
| 427 |
+
fine_grained = "fine_grained"
|
| 428 |
+
"""
|
| 429 |
+
Focus checkpointing on where it is cheap to recompute and saves most memory.
|
| 430 |
+
"""
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
class LLaDAConfig(PretrainedConfig):
|
| 434 |
+
model_type = "llada"
|
| 435 |
+
keys_to_ignore_at_inference = ["past_key_values"] # TODO: confirm
|
| 436 |
+
|
| 437 |
+
def __init__(self, use_cache: bool = False, **kwargs):
|
| 438 |
+
model_config = ModelConfig()
|
| 439 |
+
all_kwargs = model_config.__dict__
|
| 440 |
+
all_kwargs.update(kwargs)
|
| 441 |
+
all_kwargs.update({"use_cache": use_cache})
|
| 442 |
+
all_kwargs.update(
|
| 443 |
+
{
|
| 444 |
+
"architectures": all_kwargs.get("architectures", ["LLaDAModelLM"])
|
| 445 |
+
}
|
| 446 |
+
)
|
| 447 |
+
super().__init__(**all_kwargs)
|
| 448 |
+
|
| 449 |
+
@property
|
| 450 |
+
def num_attention_heads(self):
|
| 451 |
+
return self.n_heads
|
| 452 |
+
|
| 453 |
+
@property
|
| 454 |
+
def num_hidden_layers(self):
|
| 455 |
+
return self.n_layers
|
| 456 |
+
|
| 457 |
+
@property
|
| 458 |
+
def hidden_size(self):
|
| 459 |
+
return self.d_model
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
# Register the config class so that it is available for transformer pipelines, auto-loading etc.
|
| 463 |
+
AutoConfig.register("llada", LLaDAConfig)
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 126080,
|
| 4 |
+
"eos_token_id": 126081,
|
| 5 |
+
"transformers_version": "4.50.3"
|
| 6 |
+
}
|
model-00001-of-00005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e6065a51ca625b72c2e9737880831fe089d048c5a351970dc11ca412d546db5a
|
| 3 |
+
size 4902434136
|
model-00002-of-00005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e82a3d09a77a044c3f74e4df640a88ebe9230057adaf7cc838c6f54b442cf810
|
| 3 |
+
size 4983055840
|
model-00003-of-00005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:897b6186718a7e630c7208ee16398bb614151e00af51663a5aee107c2c3383d6
|
| 3 |
+
size 4999840880
|
model-00004-of-00005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2f3e00fafac0766d50906a2e36aed06052bd8351c43706ae87017ed13f89a636
|
| 3 |
+
size 4949501344
|
model-00005-of-00005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bd5eea07fd296b73eb2a2293e5f96f8d77f9c87ab2328be4019be81b00ce7cd2
|
| 3 |
+
size 2354041750
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
special_tokens_map.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:933f2aea7d59600ea0f07d1ff3b265ce1325367dd5973f7a0c2b6558a1de89c8
|
| 3 |
+
size 9528
|
vqvae/config.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "VQModel",
|
| 3 |
+
"_diffusers_version": "0.30.2",
|
| 4 |
+
"act_fn": "silu",
|
| 5 |
+
"block_out_channels": [
|
| 6 |
+
128,
|
| 7 |
+
256,
|
| 8 |
+
256,
|
| 9 |
+
512,
|
| 10 |
+
768
|
| 11 |
+
],
|
| 12 |
+
"down_block_types": [
|
| 13 |
+
"DownEncoderBlock2D",
|
| 14 |
+
"DownEncoderBlock2D",
|
| 15 |
+
"DownEncoderBlock2D",
|
| 16 |
+
"DownEncoderBlock2D",
|
| 17 |
+
"DownEncoderBlock2D"
|
| 18 |
+
],
|
| 19 |
+
"in_channels": 3,
|
| 20 |
+
"latent_channels": 64,
|
| 21 |
+
"layers_per_block": 2,
|
| 22 |
+
"lookup_from_codebook": true,
|
| 23 |
+
"mid_block_add_attention": false,
|
| 24 |
+
"norm_num_groups": 32,
|
| 25 |
+
"norm_type": "group",
|
| 26 |
+
"num_vq_embeddings": 8192,
|
| 27 |
+
"out_channels": 3,
|
| 28 |
+
"sample_size": 32,
|
| 29 |
+
"scaling_factor": 0.18215,
|
| 30 |
+
"up_block_types": [
|
| 31 |
+
"UpDecoderBlock2D",
|
| 32 |
+
"UpDecoderBlock2D",
|
| 33 |
+
"UpDecoderBlock2D",
|
| 34 |
+
"UpDecoderBlock2D",
|
| 35 |
+
"UpDecoderBlock2D"
|
| 36 |
+
],
|
| 37 |
+
"vq_embed_dim": null,
|
| 38 |
+
"force_upcast": true
|
| 39 |
+
}
|
vqvae/diffusion_pytorch_model.fp16.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:62ac839c4caebd5221d3c69a26ae76c057a2bb5b34ac59acec2e48ce4b9ae0a8
|
| 3 |
+
size 292520582
|
vqvae/diffusion_pytorch_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1241a5c88b635af4f8cfb268e388ccaa70f55a458a473d68943e5c28d7b7f762
|
| 3 |
+
size 585009980
|