JingzeShi commited on
Commit
686c37b
·
verified ·
1 Parent(s): fe2283c

Upload DogeForCausalLM

Browse files
Files changed (2) hide show
  1. config.json +43 -43
  2. modeling_doge.py +1 -18
config.json CHANGED
@@ -1,43 +1,43 @@
1
- {
2
- "_name_or_path": "SmallDoge/Doge-60M",
3
- "architectures": [
4
- "DogeForCausalLM"
5
- ],
6
- "attention_dropout": 0.0,
7
- "auto_map": {
8
- "AutoConfig": "configuration_doge.DogeConfig",
9
- "AutoModelForCausalLM": "modeling_doge.DogeForCausalLM"
10
- },
11
- "bos_token_id": 0,
12
- "dynamic_mask_ratio": 0.0,
13
- "eos_token_id": 1,
14
- "expert_retrieval_size": 256,
15
- "hidden_act": "silu",
16
- "hidden_bias": false,
17
- "hidden_dropout": 0.0,
18
- "hidden_size": 512,
19
- "initializer_range": 0.02,
20
- "intermediate_size": 1024,
21
- "is_moe": false,
22
- "max_position_embeddings": 2048,
23
- "model_type": "doge",
24
- "num_attention_heads": 4,
25
- "num_cdmoe_experts": 16348,
26
- "num_cdmoe_experts_per_head": 8,
27
- "num_cdmoe_heads": 4,
28
- "num_hidden_layers": 16,
29
- "num_key_value_heads": 2,
30
- "pad_token_id": 2,
31
- "rms_norm_eps": 1e-06,
32
- "rope_scaling": {
33
- "factor": 4.0,
34
- "original_max_position_embeddings": 2048,
35
- "rope_type": "dynamic"
36
- },
37
- "rope_theta": 10000.0,
38
- "tie_word_embeddings": true,
39
- "torch_dtype": "float32",
40
- "transformers_version": "4.48.3",
41
- "use_cache": true,
42
- "vocab_size": 32768
43
- }
 
1
+ {
2
+ "_name_or_path": "SmallDoge/Doge-60M",
3
+ "architectures": [
4
+ "DogeForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_doge.DogeConfig",
9
+ "AutoModelForCausalLM": "modeling_doge.DogeForCausalLM"
10
+ },
11
+ "bos_token_id": 0,
12
+ "dynamic_mask_ratio": 0.0,
13
+ "eos_token_id": 1,
14
+ "expert_retrieval_size": 256,
15
+ "hidden_act": "silu",
16
+ "hidden_bias": false,
17
+ "hidden_dropout": 0.0,
18
+ "hidden_size": 512,
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 1024,
21
+ "is_moe": false,
22
+ "max_position_embeddings": 2048,
23
+ "model_type": "doge",
24
+ "num_attention_heads": 4,
25
+ "num_cdmoe_experts": 16348,
26
+ "num_cdmoe_experts_per_head": 8,
27
+ "num_cdmoe_heads": 4,
28
+ "num_hidden_layers": 16,
29
+ "num_key_value_heads": 2,
30
+ "pad_token_id": 2,
31
+ "rms_norm_eps": 1e-06,
32
+ "rope_scaling": {
33
+ "factor": 4.0,
34
+ "original_max_position_embeddings": 2048,
35
+ "rope_type": "dynamic"
36
+ },
37
+ "rope_theta": 10000.0,
38
+ "tie_word_embeddings": true,
39
+ "torch_dtype": "float32",
40
+ "transformers_version": "4.48.3",
41
+ "use_cache": true,
42
+ "vocab_size": 32768
43
+ }
modeling_doge.py CHANGED
@@ -864,27 +864,10 @@ class DogeModel(DogePreTrainedModel):
864
  past_key_values: Cache,
865
  output_attentions: bool,
866
  ):
867
- if self.config._attn_implementation == "flash_attention_2":
868
- if attention_mask is not None and (attention_mask == 0.0).any():
869
- return attention_mask
870
- return None
871
-
872
- # For SDPA, when possible, we will rely on its `is_causal` argument instead of its `attn_mask` argument, in
873
- # order to dispatch on Flash Attention 2. This feature is not compatible with static cache, as SDPA will fail
874
- # to infer the attention mask.
875
  past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
876
  using_static_cache = isinstance(past_key_values, StaticCache)
877
 
878
- # When output attentions is True, sdpa implementation's forward method calls the eager implementation's forward
879
- if self.config._attn_implementation == "sdpa" and not using_static_cache and not output_attentions:
880
- if AttentionMaskConverter._ignore_causal_mask_sdpa(
881
- attention_mask,
882
- inputs_embeds=input_tensor,
883
- past_key_values_length=past_seen_tokens,
884
- is_training=self.training,
885
- ):
886
- return None
887
-
888
  dtype, device = input_tensor.dtype, input_tensor.device
889
  sequence_length = input_tensor.shape[1]
890
  if using_static_cache:
 
864
  past_key_values: Cache,
865
  output_attentions: bool,
866
  ):
867
+ # We have to provide attention_mask for dynamic mask computation
 
 
 
 
 
 
 
868
  past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
869
  using_static_cache = isinstance(past_key_values, StaticCache)
870
 
 
 
 
 
 
 
 
 
 
 
871
  dtype, device = input_tensor.dtype, input_tensor.device
872
  sequence_length = input_tensor.shape[1]
873
  if using_static_cache: