yujiepan commited on
Commit
cfdcfbb
·
verified ·
1 Parent(s): 5554360

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +10 -3
  2. config.json +6 -1
  3. model.safetensors +2 -2
README.md CHANGED
@@ -57,7 +57,7 @@ model = AutoModelForCausalLM.from_pretrained(
57
  dtype=torch.bfloat16,
58
  device_map=device,
59
  )
60
- generated_ids = model.generate(input_ids, max_new_tokens=8)
61
  output_text = tokenizer.decode(generated_ids[0][input_ids.shape[1]:])
62
  print(output_text)
63
  ```
@@ -85,7 +85,7 @@ from transformers import (
85
  )
86
 
87
  source_model_id = "zai-org/GLM-5.2"
88
- save_folder = "/tmp/tiny-random/glm-52"
89
 
90
  processor = AutoProcessor.from_pretrained(
91
  source_model_id, trust_remote_code=True)
@@ -100,6 +100,7 @@ config_json.update({
100
  "hidden_size": 8,
101
  "index_n_heads": 4,
102
  "indexer_types": ['full'] + ['shared'] * 3,
 
103
  "intermediate_size": 32,
104
  "moe_intermediate_size": 32,
105
  "num_hidden_layers": 4,
@@ -149,7 +150,7 @@ model.model.layers.append(nn.ModuleDict(dict(
149
  hnorm=nn.RMSNorm(config.hidden_size),
150
  input_layernorm=nn.RMSNorm(config.hidden_size),
151
  post_attention_layernorm=nn.RMSNorm(config.hidden_size),
152
- self_attn=deepcopy(model.model.layers[1].self_attn),
153
  mlp=deepcopy(model.model.layers[1].mlp),
154
  )))
155
  for i in range(1, len(model.model.layers)):
@@ -237,6 +238,12 @@ GlmMoeDsaForCausalLM(
237
  (kv_a_layernorm): GlmMoeDsaRMSNorm((512,), eps=1e-06)
238
  (kv_b_proj): Linear(in_features=512, out_features=3584, bias=False)
239
  (o_proj): Linear(in_features=2048, out_features=8, bias=False)
 
 
 
 
 
 
240
  )
241
  (mlp): GlmMoeDsaMoE(
242
  (experts): GlmMoeDsaExperts(
 
57
  dtype=torch.bfloat16,
58
  device_map=device,
59
  )
60
+ generated_ids = model.generate(input_ids, max_new_tokens=8) # pyright: ignore[reportAttributeAccessIssue]
61
  output_text = tokenizer.decode(generated_ids[0][input_ids.shape[1]:])
62
  print(output_text)
63
  ```
 
85
  )
86
 
87
  source_model_id = "zai-org/GLM-5.2"
88
+ save_folder = "/tmp/tiny-random/glm-52" # pyright: ignore[reportUnusedExpression]
89
 
90
  processor = AutoProcessor.from_pretrained(
91
  source_model_id, trust_remote_code=True)
 
100
  "hidden_size": 8,
101
  "index_n_heads": 4,
102
  "indexer_types": ['full'] + ['shared'] * 3,
103
+ "index_topk_pattern": ['F'] + ['S'] * 3,
104
  "intermediate_size": 32,
105
  "moe_intermediate_size": 32,
106
  "num_hidden_layers": 4,
 
150
  hnorm=nn.RMSNorm(config.hidden_size),
151
  input_layernorm=nn.RMSNorm(config.hidden_size),
152
  post_attention_layernorm=nn.RMSNorm(config.hidden_size),
153
+ self_attn=deepcopy(model.model.layers[0].self_attn),
154
  mlp=deepcopy(model.model.layers[1].mlp),
155
  )))
156
  for i in range(1, len(model.model.layers)):
 
238
  (kv_a_layernorm): GlmMoeDsaRMSNorm((512,), eps=1e-06)
239
  (kv_b_proj): Linear(in_features=512, out_features=3584, bias=False)
240
  (o_proj): Linear(in_features=2048, out_features=8, bias=False)
241
+ (indexer): GlmMoeDsaIndexer(
242
+ (wq_b): Linear(in_features=32, out_features=512, bias=False)
243
+ (wk): Linear(in_features=8, out_features=128, bias=False)
244
+ (k_norm): LayerNorm((128,), eps=1e-06, elementwise_affine=True)
245
+ (weights_proj): Linear(in_features=8, out_features=4, bias=False)
246
+ )
247
  )
248
  (mlp): GlmMoeDsaMoE(
249
  (experts): GlmMoeDsaExperts(
config.json CHANGED
@@ -22,7 +22,12 @@
22
  "index_skip_topk_offset": 3,
23
  "index_topk": 2048,
24
  "index_topk_freq": 4,
25
- "index_topk_pattern": null,
 
 
 
 
 
26
  "indexer_rope_interleave": true,
27
  "indexer_types": [
28
  "full",
 
22
  "index_skip_topk_offset": 3,
23
  "index_topk": 2048,
24
  "index_topk_freq": 4,
25
+ "index_topk_pattern": [
26
+ "F",
27
+ "S",
28
+ "S",
29
+ "S"
30
+ ],
31
  "indexer_rope_interleave": true,
32
  "indexer_types": [
33
  "full",
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:18db746dbdfb49ec5e6a211a7fa2223b7bc0011e33cd8916f43a5f1435cd9f24
3
- size 26180088
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:151d405ef695562d64c615d24d4f0cbf0aec60d7b563c545ceb41484959a0744
3
+ size 26216056