ChibuUkachi commited on
Commit
9fe7a7d
·
verified ·
1 Parent(s): 7658a05

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. config.json +77 -0
  2. config.py +102 -0
  3. model.safetensors +3 -0
  4. val_metrics.json +1 -0
config.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DFlashDraftModel"
4
+ ],
5
+ "auto_map": {
6
+ "": "config.DFlashSpeculatorConfig"
7
+ },
8
+ "aux_hidden_state_layer_ids": [
9
+ 1,
10
+ 12,
11
+ 23,
12
+ 34,
13
+ 45
14
+ ],
15
+ "block_size": 8,
16
+ "draft_vocab_size": 32000,
17
+ "dtype": "bfloat16",
18
+ "mask_token_id": 151669,
19
+ "max_anchors": 1024,
20
+ "sliding_window_non_causal": false,
21
+ "speculators_config": {
22
+ "algorithm": "dflash",
23
+ "default_proposal_method": "greedy",
24
+ "proposal_methods": [
25
+ {
26
+ "accept_tolerance": 0.0,
27
+ "proposal_type": "greedy",
28
+ "speculative_tokens": 7,
29
+ "verifier_accept_k": 1
30
+ }
31
+ ],
32
+ "verifier": {
33
+ "architectures": [],
34
+ "name_or_path": "Qwen/Qwen3-30B-A3B-Instruct-2507"
35
+ }
36
+ },
37
+ "speculators_model_type": "dflash",
38
+ "speculators_version": "0.5.0.dev160",
39
+ "target_hidden_size": null,
40
+ "tie_word_embeddings": false,
41
+ "transformer_layer_config": {
42
+ "attention_bias": false,
43
+ "attention_dropout": 0.0,
44
+ "bos_token_id": 1,
45
+ "eos_token_id": 2,
46
+ "head_dim": 128,
47
+ "hidden_act": "silu",
48
+ "hidden_size": 2048,
49
+ "initializer_range": 0.02,
50
+ "intermediate_size": 6144,
51
+ "layer_types": [
52
+ "sliding_attention",
53
+ "sliding_attention",
54
+ "sliding_attention",
55
+ "sliding_attention",
56
+ "sliding_attention"
57
+ ],
58
+ "max_position_embeddings": 262144,
59
+ "mlp_bias": false,
60
+ "model_type": "llama",
61
+ "num_attention_heads": 32,
62
+ "num_hidden_layers": 5,
63
+ "num_key_value_heads": 4,
64
+ "pad_token_id": null,
65
+ "pretraining_tp": 1,
66
+ "rms_norm_eps": 1e-06,
67
+ "rope_parameters": {
68
+ "rope_theta": 10000000,
69
+ "rope_type": "default"
70
+ },
71
+ "sliding_window": 2048,
72
+ "tie_word_embeddings": false,
73
+ "use_cache": true,
74
+ "vocab_size": 151936
75
+ },
76
+ "transformers_version": "5.10.2"
77
+ }
config.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ sliding_window_non_causal: bool = Field(
75
+ default=False,
76
+ description="Use non-causal (bidirectional) masking within draft blocks for "
77
+ "sliding window attention layers. Full attention layers are always "
78
+ "bidirectional.",
79
+ )
80
+
81
+ @field_serializer("transformer_layer_config")
82
+ def serialize_transformer_config(self, value: PretrainedConfig) -> dict:
83
+ """Serialize transformer config to dict."""
84
+ return value.to_diff_dict()
85
+
86
+ @field_validator("transformer_layer_config", mode="before")
87
+ @classmethod
88
+ def validate_transformer_config(cls, value: Any) -> PretrainedConfig:
89
+ """Validate and convert transformer config."""
90
+ if isinstance(value, dict):
91
+ config_class: type[PretrainedConfig] = Qwen3Config
92
+ if "model_type" in value:
93
+ config_class = AutoConfig.for_model(
94
+ model_type=value["model_type"]
95
+ ).__class__
96
+ return config_class(**value)
97
+ return value
98
+
99
+ @property
100
+ def target_vocab_size(self) -> int:
101
+ """Get target vocabulary size from transformer config."""
102
+ 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:22ef21bf72671069f80c4564d871f441e6b9535d8acbc82a6ef4a5ac4264a5b4
3
+ size 1362042120
val_metrics.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"loss_epoch": 1.4144842092175067, "full_acc_epoch": 0.34676152761132395, "position_1_acc_epoch": 0.6682026932842137, "position_2_acc_epoch": 0.4860215776577793, "position_3_acc_epoch": 0.3740923833465139, "position_4_acc_epoch": 0.2959340704922699, "position_5_acc_epoch": 0.23920370384832654, "position_6_acc_epoch": 0.19724874215872754, "position_7_acc_epoch": 0.16442117170899365}