dsikka commited on
Commit
3fda59f
·
verified ·
1 Parent(s): 67bd9e7

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +69 -0
  2. config.json +68 -0
  3. config.py +95 -0
  4. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: speculators
3
+ base_model:
4
+ - poolside/Laguna-XS.2
5
+ license: apache-2.0
6
+ tags:
7
+ - speculative-decoding
8
+ - dflash
9
+ - speculators
10
+ ---
11
+
12
+ # RedHatAI/Laguna-XS.2-speculator.dflash
13
+
14
+ This is a DFlash speculator model for [poolside/Laguna-XS.2](https://huggingface.co/poolside/Laguna-XS.2).
15
+
16
+ ## Training Details
17
+
18
+ This model was trained using the [Speculators](https://github.com/vllm-project/speculators) library on a combination of [Magpie-Align/Magpie-Llama-3.1-Pro-300K-Filtered](https://huggingface.co/datasets/Magpie-Align/Magpie-Llama-3.1-Pro-300K-Filtered) and the `train_sft` split of [HuggingFaceH4/ultrachat_200k](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k). Responses were regenerated by Laguna-XS.2 (with reasoning).
19
+
20
+ ## Model Specifications
21
+
22
+ | | |
23
+ |---|---|
24
+ | **Base Model** | poolside/Laguna-XS.2 |
25
+ | **Chat Template** | poolside/Laguna-XS.2 (use `/chat/completions` endpoint) |
26
+ | **Format** | Safetensors |
27
+ | **License** | Apache 2.0 |
28
+ | **Validation Hardware** | Nvidia A100 |
29
+
30
+ ## Deployment
31
+
32
+ ```bash
33
+ # Install vLLM from the required PR
34
+ pip install git+https://github.com/vllm-project/vllm.git@refs/pull/41880/head
35
+
36
+ # Deploy with speculative decoding
37
+ VLLM_USE_DEEP_GEMM=0 vllm serve poolside/Laguna-XS.2 \
38
+ --tensor-parallel-size 1 \
39
+ --max-model-len 16384 \
40
+ --tool-call-parser poolside_v1 \
41
+ --reasoning-parser poolside_v1 \
42
+ --enable-auto-tool-choice \
43
+ --default-chat-template-kwargs '{"enable_thinking": true}' \
44
+ --speculative-config '{
45
+ "model": "poolside/Laguna-XS.2-speculator.dflash",
46
+ "num_speculative_tokens": 7,
47
+ "method": "dflash"
48
+ }'
49
+ ```
50
+
51
+ ## Preliminary Evaluations
52
+
53
+ Per-position token acceptance rates across datasets:
54
+ (with reasoning enabled)
55
+
56
+ | Dataset | Pos 1 | Pos 2 | Pos 3 | Pos 4 | Pos 5 | Pos 6 | Pos 7 | Avg Length |
57
+ |---------|-------|-------|-------|-------|-------|-------|-------|------------|
58
+ | HumanEval | 74.0% | 48.6% | 29.9% | 17.7% | 9.9% | 5.1% | 2.4% | 2.876 |
59
+ | math_reasoning | 76.9% | 53.2% | 34.6% | 21.2% | 12.1% | 6.0% | 2.6% | 3.066 |
60
+ | qa | 68.5% | 41.8% | 24.8% | 14.7% | 8.4% | 4.6% | 2.2% | 2.650 |
61
+ | question | 70.6% | 44.1% | 26.2% | 15.0% | 8.4% | 4.5% | 2.3% | 2.711 |
62
+ | rag | 71.7% | 45.7% | 27.6% | 16.0% | 8.9% | 4.8% | 2.3% | 2.770 |
63
+ | summarization | 68.8% | 40.8% | 22.7% | 12.3% | 6.5% | 3.3% | 1.5% | 2.559 |
64
+ | translation | 70.8% | 44.3% | 25.0% | 13.0% | 6.5% | 3.1% | 1.2% | 2.639 |
65
+ | writing | 70.9% | 44.6% | 26.8% | 15.8% | 9.4% | 5.4% | 2.3% | 2.752 |
66
+
67
+ ## References
68
+
69
+ **Paper**: [DFlash: Block Diffusion for Flash Speculative Decoding](https://arxiv.org/abs/2602.06036)
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
+ 9,
11
+ 17,
12
+ 36,
13
+ 39
14
+ ],
15
+ "block_size": 8,
16
+ "draft_vocab_size": 32000,
17
+ "dtype": "bfloat16",
18
+ "mask_token_id": 12,
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": 7,
28
+ "verifier_accept_k": 1
29
+ }
30
+ ],
31
+ "verifier": {
32
+ "architectures": [],
33
+ "name_or_path": "poolside/Laguna-XS.2"
34
+ }
35
+ },
36
+ "speculators_model_type": "dflash",
37
+ "speculators_version": "0.5.0.dev97",
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": 128,
46
+ "hidden_act": "silu",
47
+ "hidden_size": 2048,
48
+ "initializer_range": 0.02,
49
+ "intermediate_size": 8192,
50
+ "max_position_embeddings": 131072,
51
+ "mlp_bias": false,
52
+ "model_type": "llama",
53
+ "num_attention_heads": 16,
54
+ "num_hidden_layers": 5,
55
+ "num_key_value_heads": 8,
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": 100352
66
+ },
67
+ "transformers_version": "5.6.2"
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:e08bf72a99f27d92af25595422baf5421a58d8d5634ddfec7a60f7cb21d964a7
3
+ size 1213617016