MeganEFlynn commited on
Commit
5481e8c
·
verified ·
1 Parent(s): 941f600

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. config.json +68 -0
  2. config.py +95 -0
  3. model.safetensors +3 -0
config.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DFlashDraftModel"
4
+ ],
5
+ "auto_map": {
6
+ "": "config.DFlashSpeculatorConfig"
7
+ },
8
+ "aux_hidden_state_layer_ids": [
9
+ 1,
10
+ 17,
11
+ 29,
12
+ 47,
13
+ 58
14
+ ],
15
+ "block_size": 8,
16
+ "draft_vocab_size": 32000,
17
+ "dtype": "bfloat16",
18
+ "mask_token_id": 4,
19
+ "max_anchors": 3072,
20
+ "speculators_config": {
21
+ "algorithm": "dflash",
22
+ "default_proposal_method": "greedy",
23
+ "proposal_methods": [
24
+ {
25
+ "accept_tolerance": 0.0,
26
+ "proposal_type": "greedy",
27
+ "speculative_tokens": 8,
28
+ "verifier_accept_k": 1
29
+ }
30
+ ],
31
+ "verifier": {
32
+ "architectures": [],
33
+ "name_or_path": "google/gemma-4-31B-it"
34
+ }
35
+ },
36
+ "speculators_model_type": "dflash",
37
+ "speculators_version": "0.5.0.dev53",
38
+ "target_hidden_size": null,
39
+ "tie_word_embeddings": false,
40
+ "transformer_layer_config": {
41
+ "attention_bias": false,
42
+ "attention_dropout": 0.0,
43
+ "bos_token_id": 1,
44
+ "eos_token_id": 2,
45
+ "head_dim": 256,
46
+ "hidden_act": "silu",
47
+ "hidden_size": 5376,
48
+ "initializer_range": 0.02,
49
+ "intermediate_size": 21504,
50
+ "max_position_embeddings": 262144,
51
+ "mlp_bias": false,
52
+ "model_type": "llama",
53
+ "num_attention_heads": 32,
54
+ "num_hidden_layers": 5,
55
+ "num_key_value_heads": 16,
56
+ "pad_token_id": null,
57
+ "pretraining_tp": 1,
58
+ "rms_norm_eps": 1e-06,
59
+ "rope_parameters": {
60
+ "rope_theta": 10000.0,
61
+ "rope_type": "default"
62
+ },
63
+ "tie_word_embeddings": false,
64
+ "use_cache": true,
65
+ "vocab_size": 262144
66
+ },
67
+ "transformers_version": "5.5.4"
68
+ }
config.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any, Literal
2
+
3
+ from pydantic import Field, field_serializer, field_validator
4
+ from transformers import AutoConfig, PretrainedConfig
5
+ from transformers.models.qwen3.modeling_qwen3 import (
6
+ Qwen3Config,
7
+ )
8
+
9
+ from speculators import SpeculatorModelConfig
10
+
11
+ __all__ = [
12
+ "DFlashSpeculatorConfig",
13
+ ]
14
+
15
+
16
+ @SpeculatorModelConfig.register("dflash")
17
+ class DFlashSpeculatorConfig(SpeculatorModelConfig):
18
+ """
19
+ Configuration for DFlash speculator with vocabulary mapping.
20
+
21
+ DFlash features vocabulary mapping between draft (64K) and target (128K)
22
+ vocabularies, enabling cross-tokenizer speculation.
23
+
24
+ :param transformer_layer_config: Configuration for the transformer decoder layer
25
+ :param draft_vocab_size: Size of draft model vocabulary for speculation
26
+ """
27
+
28
+ speculators_model_type: Literal["dflash"] = "dflash"
29
+ architectures: list[str] = Field(
30
+ default_factory=lambda: ["DFlashSpeculator"],
31
+ description="Model architectures that can load these weights",
32
+ )
33
+
34
+ transformer_layer_config: PretrainedConfig = Field(
35
+ default_factory=Qwen3Config,
36
+ description="Configuration for the transformer decoder layer",
37
+ )
38
+
39
+ draft_vocab_size: int = Field(
40
+ default=32000,
41
+ description="Size of draft model vocabulary for speculation",
42
+ )
43
+
44
+ block_size: int = Field(
45
+ default=8,
46
+ description=(
47
+ "Default size of the draft block predicted with a forward pass of the model"
48
+ ),
49
+ )
50
+
51
+ max_anchors: int = Field(
52
+ default=256,
53
+ description=(
54
+ "Maximum number of anchor positions to sample during training "
55
+ "(controls memory usage and training efficiency)"
56
+ ),
57
+ )
58
+
59
+ target_hidden_size: int | None = Field(
60
+ default=None,
61
+ description="Hidden size of the target model (if different from draft model)",
62
+ )
63
+
64
+ aux_hidden_state_layer_ids: list[int] | None = Field(
65
+ default=None,
66
+ description="Layer IDs of the DFlash auxiliary hidden state layers",
67
+ )
68
+
69
+ mask_token_id: int | None = Field(
70
+ default=None,
71
+ description="Token ID used for masking",
72
+ )
73
+
74
+ @field_serializer("transformer_layer_config")
75
+ def serialize_transformer_config(self, value: PretrainedConfig) -> dict:
76
+ """Serialize transformer config to dict."""
77
+ return value.to_diff_dict()
78
+
79
+ @field_validator("transformer_layer_config", mode="before")
80
+ @classmethod
81
+ def validate_transformer_config(cls, value: Any) -> PretrainedConfig:
82
+ """Validate and convert transformer config."""
83
+ if isinstance(value, dict):
84
+ config_class: type[PretrainedConfig] = Qwen3Config
85
+ if "model_type" in value:
86
+ config_class = AutoConfig.for_model(
87
+ model_type=value["model_type"]
88
+ ).__class__
89
+ return config_class(**value)
90
+ return value
91
+
92
+ @property
93
+ def target_vocab_size(self) -> int:
94
+ """Get target vocabulary size from transformer config."""
95
+ return self.transformer_layer_config.vocab_size
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50a1fcab8e6ce28c1693098b321769eab16667786ef9133e8822ad944e6356c1
3
+ size 8241679848