Update config.json

#160
by jana0010 - opened
Files changed (1) hide show
  1. config.json +52 -70
config.json CHANGED
@@ -1,70 +1,52 @@
1
- {
2
- "architectures": [
3
- "DeepseekV3ForCausalLM"
4
- ],
5
- "attention_bias": false,
6
- "attention_dropout": 0.0,
7
- "auto_map": {
8
- "AutoConfig": "configuration_deepseek.DeepseekV3Config",
9
- "AutoModel": "modeling_deepseek.DeepseekV3Model",
10
- "AutoModelForCausalLM": "modeling_deepseek.DeepseekV3ForCausalLM"
11
- },
12
- "aux_loss_alpha": 0.001,
13
- "bos_token_id": 0,
14
- "eos_token_id": 1,
15
- "ep_size": 1,
16
- "first_k_dense_replace": 3,
17
- "hidden_act": "silu",
18
- "hidden_size": 7168,
19
- "initializer_range": 0.02,
20
- "intermediate_size": 18432,
21
- "kv_lora_rank": 512,
22
- "max_position_embeddings": 163840,
23
- "model_type": "deepseek_v3",
24
- "moe_intermediate_size": 2048,
25
- "moe_layer_freq": 1,
26
- "n_group": 8,
27
- "n_routed_experts": 256,
28
- "n_shared_experts": 1,
29
- "norm_topk_prob": true,
30
- "num_attention_heads": 128,
31
- "num_experts_per_tok": 8,
32
- "num_hidden_layers": 61,
33
- "num_key_value_heads": 128,
34
- "num_nextn_predict_layers": 1,
35
- "pretraining_tp": 1,
36
- "q_lora_rank": 1536,
37
- "qk_nope_head_dim": 128,
38
- "qk_rope_head_dim": 64,
39
- "quantization_config": {
40
- "activation_scheme": "dynamic",
41
- "fmt": "e4m3",
42
- "quant_method": "fp8",
43
- "weight_block_size": [
44
- 128,
45
- 128
46
- ]
47
- },
48
- "rms_norm_eps": 1e-06,
49
- "rope_scaling": {
50
- "beta_fast": 32,
51
- "beta_slow": 1,
52
- "factor": 40,
53
- "mscale": 1.0,
54
- "mscale_all_dim": 1.0,
55
- "original_max_position_embeddings": 4096,
56
- "type": "yarn"
57
- },
58
- "rope_theta": 10000,
59
- "routed_scaling_factor": 2.5,
60
- "scoring_func": "sigmoid",
61
- "seq_aux": true,
62
- "tie_word_embeddings": false,
63
- "topk_group": 4,
64
- "topk_method": "noaux_tc",
65
- "torch_dtype": "bfloat16",
66
- "transformers_version": "4.46.3",
67
- "use_cache": true,
68
- "v_head_dim": 128,
69
- "vocab_size": 129280
70
- }
 
1
+ def load_model_with_quantization_fallback(
2
+ model_name: str = "deepseek-ai/DeepSeek-R1",
3
+ trust_remote_code: bool = True,
4
+ device_map: Optional[Union[str, Dict[str, Any]]] = "auto",
5
+ **kwargs
6
+ ) -> Tuple[PreTrainedModel, PreTrainedTokenizer]:
7
+
8
+ try:
9
+ model = AutoModel.from_pretrained(
10
+ model_name,
11
+ trust_remote_code=trust_remote_code,
12
+ device_map=device_map,
13
+ **kwargs
14
+ )
15
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
16
+ logger.info("Model loaded successfully with original configuration")
17
+ return model, tokenizer
18
+ except ValueError as e:
19
+ if "Unknown quantization type" in str(e):
20
+ logger.warning(
21
+ "Quantization type not supported directly. "
22
+ "Attempting to load without quantization..."
23
+ )
24
+
25
+ config = AutoConfig.from_pretrained(
26
+ model_name,
27
+ trust_remote_code=trust_remote_code
28
+ )
29
+ if hasattr(config, "quantization_config"):
30
+ delattr(config, "quantization_config")
31
+
32
+ try:
33
+ model = AutoModel.from_pretrained(
34
+ model_name,
35
+ config=config,
36
+ trust_remote_code=trust_remote_code,
37
+ device_map=device_map,
38
+ **kwargs
39
+ )
40
+ tokenizer = AutoTokenizer.from_pretrained(
41
+ model_name,
42
+ trust_remote_code=trust_remote_code
43
+ )
44
+ logger.info("Model loaded successfully without quantization")
45
+ return model, tokenizer
46
+
47
+ except Exception as inner_e:
48
+ logger.error(f"Failed to load model without quantization: {str(inner_e)}")
49
+ raise
50
+ else:
51
+ logger.error(f"Unexpected error during model loading: {str(e)}")
52
+ raise