#!/usr/bin/env python3
“”“Offline engine-initialization reproducer. Run twice with one cache mount.”“”
import json
from pathlib import Path
def write_synthetic_configs(root: Path) → tuple[str, str]:
target = {
“architectures”: [“LagunaForCausalLM”],
“model_type”: “laguna”,
“hidden_size”: 3072,
“intermediate_size”: 12288,
“num_hidden_layers”: 48,
“max_position_embeddings”: 262144,
“num_experts”: 256,
“num_experts_per_tok”: 10,
“moe_intermediate_size”: 1024,
“shared_expert_intermediate_size”: 1024,
“torch_dtype”: “bfloat16”,
“gating”: “per-head”,
“sliding_window”: 512,
“layer_types”: [“full_attention”, *[“sliding_attention”] * 3] * 12,
“num_attention_heads_per_layer”: [48, 72, 72, 72] * 12,
“moe_routed_scaling_factor”: 2.5,
“rope_parameters”: {
“full_attention”: {
“rope_theta”: 500000.0,
“rope_type”: “yarn”,
“factor”: 32.0,
“original_max_position_embeddings”: 8192,
“beta_slow”: 1.0,
“beta_fast”: 32.0,
“attention_factor”: 1.3465735902799727,
“partial_rotary_factor”: 0.5,
},
“sliding_attention”: {
“rope_type”: “default”,
“rope_theta”: 10000.0,
“partial_rotary_factor”: 1.0,
},
},
“quantization_config”: {
“config_groups”: {
“group_0”: {
“format”: “nvfp4-pack-quantized”,
“input_activations”: {
“actorder”: None,
“block_structure”: None,
“dynamic”: “local”,
“group_size”: 16,
“num_bits”: 4,
“observer”: “minmax”,
“observer_kwargs”: {},
“scale_dtype”: “torch.float8_e4m3fn”,
“strategy”: “tensor_group”,
“symmetric”: True,
“type”: “float”,
“zp_dtype”: None,
},
“output_activations”: None,
“targets”: [
r"re:.*experts\.[0-9]+\.(gate_proj|up_proj|down_proj)$"
],
“weights”: {
“actorder”: None,
“block_structure”: None,
“dynamic”: False,
“group_size”: 16,
“num_bits”: 4,
“observer”: “memoryless_minmax”,
“observer_kwargs”: {},
“scale_dtype”: “torch.float8_e4m3fn”,
“strategy”: “tensor_group”,
“symmetric”: True,
“type”: “float”,
“zp_dtype”: None,
},
}
},
“format”: “nvfp4-pack-quantized”,
“ignore”: [
“lm_head”,
“model.layers.0.mlp.gate_proj”,
“model.layers.0.mlp.up_proj”,
“model.layers.0.mlp.down_proj”,
r"re:.*\.self_attn\.(q_proj|k_proj|v_proj|o_proj|g_proj)$“,
r"re:.*\.mlp\.gate$”,
r"re:.*\.mlp\.shared_expert\.(gate_proj|up_proj|down_proj)$",
],
“kv_cache_scheme”: {
“actorder”: None,
“block_structure”: None,
“dynamic”: False,
“group_size”: None,
“num_bits”: 8,
“observer”: “minmax”,
“observer_kwargs”: {},
“scale_dtype”: None,
“strategy”: “tensor”,
“symmetric”: True,
“type”: “float”,
“zp_dtype”: None,
},
“quant_method”: “compressed-tensors”,
“quantization_status”: “compressed”,
},
}
drafter = {
“architectures”: [“DFlashLagunaForCausalLM”],
“model_type”: “laguna”,
“draft_vocab_size”: 100352,
“hidden_size”: 3072,
“intermediate_size”: 12288,
“num_hidden_layers”: 6,
“num_attention_heads”: 72,
“max_position_embeddings”: 262144,
“sliding_window”: 512,
“layer_types”: [“sliding_attention”] * 6,
“rope_theta”: 10000.0,
“gating”: “per-head”,
“num_experts”: 0,
“torch_dtype”: “bfloat16”,
“eagle_aux_hidden_state_layer_ids”: [2, 11, 20, 30, 39, 48],
“dflash_config”: {
“block_size”: 16,
“mask_token_id”: 12,
“num_target_layers”: 48,
“target_layer_ids”: [1, 10, 19, 29, 38, 47],
“causal”: True,
},
}
target_dir, drafter_dir = root / “target”, root / “drafter”
target_dir.mkdir(parents=True, exist_ok=True)
drafter_dir.mkdir(parents=True, exist_ok=True)
(target_dir / “config.json”).write_text(json.dumps(target))
(drafter_dir / “config.json”).write_text(json.dumps(drafter))
return str(target_dir), str(drafter_dir)
if _name_ == “_main_”:
from vllm import LLM
target, drafter = write_synthetic_configs(Path(“/tmp/sm120-wedge-poc”))
LLM(model=target, spec_method=“dflash”, spec_model=drafter, spec_tokens=9,
max_num_batched_tokens=8192, max_num_seqs=32, max_model_len=262144,
gpu_memory_utilization=0.87, enable_prefix_caching=True, load_format=“dummy”,
skip_tokenizer_init=True)