Upload folder using huggingface_hub

#3
config.json CHANGED
@@ -1,12 +1,12 @@
1
  {
2
- "_name_or_path": "yentinglin/Llama-3-Taiwan-70B-Instruct-rc3",
3
  "architectures": [
4
  "LlamaForCausalLM"
5
  ],
6
  "attention_bias": false,
7
  "attention_dropout": 0.0,
8
  "bos_token_id": 128000,
9
- "eos_token_id": 128009,
10
  "hidden_act": "silu",
11
  "hidden_size": 8192,
12
  "initializer_range": 0.02,
@@ -24,5 +24,5 @@
24
  "torch_dtype": "bfloat16",
25
  "transformers_version": "4.40.2",
26
  "use_cache": false,
27
- "vocab_size": 128256
28
  }
 
1
  {
2
+ "_name_or_path": "yentinglin/Llama-3-Taiwan-70B-Instruct",
3
  "architectures": [
4
  "LlamaForCausalLM"
5
  ],
6
  "attention_bias": false,
7
  "attention_dropout": 0.0,
8
  "bos_token_id": 128000,
9
+ "eos_token_id": 128256,
10
  "hidden_act": "silu",
11
  "hidden_size": 8192,
12
  "initializer_range": 0.02,
 
24
  "torch_dtype": "bfloat16",
25
  "transformers_version": "4.40.2",
26
  "use_cache": false,
27
+ "vocab_size": 128258
28
  }
latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step160
model-00001-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ceca59bf2672782b5d8dd32950298c93f8bbebff65e5114d59f184e8591dadc0
3
- size 4584408808
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3456c422f211ac69b2a0846a5bdf723b2d3776f16defc6a814ef9d2087685199
3
+ size 4584441576
model-00002-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:65311a1ae88a28f97756374bdfd3ac04819702e41b4e98a4ea3dc1e3f38da895
3
  size 4664167376
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c827cb32ca8351713bd296bf0ddbeb994df2d604fbf662391be1d6407d63cc5f
3
  size 4664167376
model-00003-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4fbbc92dd73a156be3e55bd4cad4c70c80f085f0a28119a356243ed99a6849a6
3
  size 4999711704
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1519c49a9afd51bc61f0f522986a9fb551a062097206b8b61147903e7c6c6496
3
  size 4999711704
model-00004-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:21c12dbeba70e7520750904f4bdc8a5a5aa8d3ba711fdf05b40387c6a2112503
3
  size 4966157032
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97c0cdafd98d33a5308402961f181dee3fe7ed6204a2558440395b5a411d19bd
3
  size 4966157032
model-00005-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2049aa167f285c85dd9f57eb9dfabbd42939acf785572a549ee419935ed0c3f0
3
  size 4664134408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e879a6c47b37235fd975da6f9896976760d21ecf28ad70f771f9faf71713e3e
3
  size 4664134408
model-00006-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fd2f73719934583118b06c53e8fe44b5697e9f38e4e07d57d5865a31d957ad3f
3
  size 4664167408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4cc1b1e8b14a38c2f21085a0f55caf0f65d612227d6c169efa7735e9f81357f6
3
  size 4664167408
model-00007-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e626d86fb2893ac35ad28eb105601b1722b721f1c75db5f1516acd76f94d7c6b
3
  size 4664167408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0d47426adceabc7a4ebcfe5bc24b5830fc4af5c748d64e56f0cdd240ea6cbac
3
  size 4664167408
model-00008-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:827ddd50f669cab713cf36273822fab2ae87db5585c241a62ccdd880d16dc54f
3
  size 4999711728
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ca3891ceaf01cd52f7d79ea8694378d5d0c53131cf0359e107ff0f03b45eeaa
3
  size 4999711728
model-00009-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:213b007783a739166d2be97c09573719695e98c70232a420a886965caad2d1cb
3
  size 4966157056
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c06eaa3666a65b4c64831ec4233270d56966e898f600cdba6cba07af0e8a559c
3
  size 4966157056
model-00010-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f7f661f78dee33ad714f6bd6d19efdd243a49dad2f998def7c54feffde54e6e2
3
  size 4664134408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c272793f8a90198705124b3bca6e36e605df5bd55c8fe6fa6ab21115d76e0ab1
3
  size 4664134408
model-00011-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:72cb2d2ffea069ecdc2ea459edaf835b4a4b03cb6a7478e5dfa9b0a4fda8bbfd
3
  size 4664167408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fde6dcdcc375f2f80e6edb57fc3c03493522b4d274209712ca2e1c1ff68eb868
3
  size 4664167408
model-00012-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1ae342da72dabfd5dd05220feb33a03d8c307a492d025970e7ba7158ee20eda2
3
  size 4664167408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c31ffd3a2aa84fd522be76c3b71a756bcc05993d5336f8123cebe04248cd9b0
3
  size 4664167408
model-00013-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7abe91954470c523fca6880cf6344688f82f6be8456462aea18d14cca5d31d91
3
  size 4999711728
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3c790db09692101d47da5261b8b9f363b5d94640a355a2e68ea6b8c1cc6ee80
3
  size 4999711728
model-00014-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fb51329664948e7104e8061e3ae626c00bde9642d4639b4c1421d7690d06a1da
3
  size 4966157056
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7f62731dc23f1a8f8024aed62228ff5f2733b54e85584b500c459d4ed2b919fd
3
  size 4966157056
model-00015-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c66ad06b76130524832ece52e77d0b04d36689f4ad54ef3955bf29bddbd32264
3
  size 4664134408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74b88be19757ab65ac11fe088852cf153d6299b1ee4ac8a04e8b94932b2ec6b8
3
  size 4664134408
model-00016-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:535a817159e772d8043eca0b5d4ac4249daf5e1ff263b00a35c5b0f5f80d1729
3
  size 4664167408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a39fa49652b72921656f86a2bbb3774d46d4e3769d46d102942cb47687d0a63
3
  size 4664167408
model-00017-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:17f4484bce1cdb220889b175eeb3f5461318baffa1a9f611b175e741c08218af
3
  size 4664167408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b53a2743088a1f168096db90806c903fa29bf0fb54bf348b6cd098c1842d0f0b
3
  size 4664167408
model-00018-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:16497bd28ed92f99721a6bec89d1ce3048479b9f40744840da04480723b3e7f2
3
  size 4999711728
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70fef9f2a3914cdd3f685e0a6e04f83e9aeea249f65008d6750088c34ec25167
3
  size 4999711728
model-00019-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4649da440ca0a5ecf2db42bc13e5755e096df75b113bd6353a16885dc00419d4
3
  size 4966157056
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f4610d20ada34f28002de4eaa8e3785b77d3df37e1cb612144e9bf9af8fe141
3
  size 4966157056
model-00020-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:593b4d531dd16d4e5d8c716d3b4ad7cbbd747163cca44e61e5ca995d5f9e93f9
3
  size 4664134408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:32b21b7f898f17d54d4796ab37c97bb09dd4bcea2d427ce6a3609fb70a331786
3
  size 4664134408
model-00021-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:53c245da6fa1e9d64130ec768d57cc8ea82be2a0af2e244a7d8cef590df5a1d7
3
  size 4664167408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b527974170cc2d8a21595dd33d3c38292eb261b6630283539aae5b62c6b2498a
3
  size 4664167408
model-00022-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5c2b685bfae0ce5cecd5956011cc0266b47c559328e312a0b5a63b052786fc6a
3
  size 4664167408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a59c96d221558078d5c4540e727e843500711df3e6ba33acb7d9067807907056
3
  size 4664167408
model-00023-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a8c40cc207fb69f5b7e20ac3dcd62b582bbcbe4cb725d610092c9f1317c7a3de
3
  size 4999711728
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f1e1ac772c05ccfad15bd3788ccb68cfbcc500026caed1593ca81ca5fcc12b5
3
  size 4999711728
model-00024-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1ae3bf132dc1baa14d02efa0710c7abf4ce03ae27d18b4a305103608e7d2c795
3
  size 4966157056
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4dd2c2517501e87be7b5cc77f9e00a3e5bd2e5482a5f86890b97dbf8f7a58999
3
  size 4966157056
model-00025-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:04226e40c4aadb6943a4b99263ef81b162c553023a272839afb394c561717bbf
3
  size 4664134408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc25480728d569497f3a8acaf6d9e1124fa215058a07d346a8794c74f3ec61ce
3
  size 4664134408
model-00026-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d1ff1f40b6c163f26b8df9eafd78d5350d9c9c5cfcce7bb89f0ef367edb80daa
3
  size 4664167408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4cf05dacab18c581ce789a0d55da092e3c655067adb330a1cb99699140d71aa1
3
  size 4664167408
model-00027-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8aff3ca5f4f9353d572d58ae20f9b60faa136ef9780d4195dca65597984905c8
3
  size 4664167408
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f055d1be72dd2da7ac8714b05a2a071578f68a219c48e15fcfc499e5708a76c
3
  size 4664167408
model-00028-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3becbdc3e697907b0de01be570f7a9c8643d5dee888af6571413347f99db8a18
3
  size 4999711728
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d4ddfa6156f632d291255b7f687cc9f82be9bd62f6216d9ca6b8d15e6da4d14
3
  size 4999711728
model-00029-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a5a70e32356fb2d34e72dc2227bac53c6a7bb3f9c9fe914ef4749282f05752e7
3
  size 4966173536
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:558dcd4052a8f80a09e6a201385783f73ffbb413b612c5f57177ee2489172abd
3
  size 4966173536
model-00030-of-00030.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:19b1cef6d8979e225b57007f438d89807df98bec7a6623a384ae5ff0c5d05340
3
- size 2101346432
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe325f3f5568f99a0bbf54bba1b1a7eada4262fa0ea2fe0b40f916bd4f5e24b1
3
+ size 2101379200
model.safetensors.index.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "metadata": {
3
- "total_size": 141107412992
4
  },
5
  "weight_map": {
6
  "lm_head.weight": "model-00030-of-00030.safetensors",
 
1
  {
2
  "metadata": {
3
+ "total_size": 141107478528
4
  },
5
  "weight_map": {
6
  "lm_head.weight": "model-00030-of-00030.safetensors",
special_tokens_map.json CHANGED
@@ -7,14 +7,14 @@
7
  "single_word": false
8
  },
9
  "eos_token": {
10
- "content": "<|eot_id|>",
11
  "lstrip": false,
12
  "normalized": false,
13
  "rstrip": false,
14
  "single_word": false
15
  },
16
  "pad_token": {
17
- "content": "<|end_of_text|>",
18
  "lstrip": false,
19
  "normalized": false,
20
  "rstrip": false,
 
7
  "single_word": false
8
  },
9
  "eos_token": {
10
+ "content": "<|im_end|>",
11
  "lstrip": false,
12
  "normalized": false,
13
  "rstrip": false,
14
  "single_word": false
15
  },
16
  "pad_token": {
17
+ "content": "<|endoftext|>",
18
  "lstrip": false,
19
  "normalized": false,
20
  "rstrip": false,
tokenizer.json CHANGED
@@ -2306,6 +2306,24 @@
2306
  "rstrip": false,
2307
  "normalized": false,
2308
  "special": true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2309
  }
2310
  ],
2311
  "normalizer": null,
 
2306
  "rstrip": false,
2307
  "normalized": false,
2308
  "special": true
2309
+ },
2310
+ {
2311
+ "id": 128256,
2312
+ "content": "<|im_end|>",
2313
+ "single_word": false,
2314
+ "lstrip": false,
2315
+ "rstrip": false,
2316
+ "normalized": false,
2317
+ "special": true
2318
+ },
2319
+ {
2320
+ "id": 128257,
2321
+ "content": "<|endoftext|>",
2322
+ "single_word": false,
2323
+ "lstrip": false,
2324
+ "rstrip": false,
2325
+ "normalized": false,
2326
+ "special": true
2327
  }
2328
  ],
2329
  "normalizer": null,
tokenizer_config.json CHANGED
@@ -2047,17 +2047,33 @@
2047
  "rstrip": false,
2048
  "single_word": false,
2049
  "special": true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2050
  }
2051
  },
2052
  "bos_token": "<|begin_of_text|>",
2053
  "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}{% else %}{{ eos_token }}{% endif %}",
2054
  "clean_up_tokenization_spaces": true,
2055
- "eos_token": "<|eot_id|>",
2056
  "model_input_names": [
2057
  "input_ids",
2058
  "attention_mask"
2059
  ],
2060
  "model_max_length": 1000000000000000019884624838656,
2061
- "pad_token": "<|end_of_text|>",
2062
  "tokenizer_class": "PreTrainedTokenizerFast"
2063
  }
 
2047
  "rstrip": false,
2048
  "single_word": false,
2049
  "special": true
2050
+ },
2051
+ "128256": {
2052
+ "content": "<|im_end|>",
2053
+ "lstrip": false,
2054
+ "normalized": false,
2055
+ "rstrip": false,
2056
+ "single_word": false,
2057
+ "special": true
2058
+ },
2059
+ "128257": {
2060
+ "content": "<|endoftext|>",
2061
+ "lstrip": false,
2062
+ "normalized": false,
2063
+ "rstrip": false,
2064
+ "single_word": false,
2065
+ "special": true
2066
  }
2067
  },
2068
  "bos_token": "<|begin_of_text|>",
2069
  "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}{% else %}{{ eos_token }}{% endif %}",
2070
  "clean_up_tokenization_spaces": true,
2071
+ "eos_token": "<|im_end|>",
2072
  "model_input_names": [
2073
  "input_ids",
2074
  "attention_mask"
2075
  ],
2076
  "model_max_length": 1000000000000000019884624838656,
2077
+ "pad_token": "<|endoftext|>",
2078
  "tokenizer_class": "PreTrainedTokenizerFast"
2079
  }
trainer_state.json ADDED
@@ -0,0 +1,1141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 1.001564945226917,
5
+ "eval_steps": 500,
6
+ "global_step": 160,
7
+ "is_hyper_param_search": false,
8
+ "is_local_process_zero": true,
9
+ "is_world_process_zero": true,
10
+ "log_history": [
11
+ {
12
+ "epoch": 0.006259780907668232,
13
+ "grad_norm": 1.98288817639941,
14
+ "learning_rate": 5.000000000000001e-07,
15
+ "loss": 0.6599,
16
+ "step": 1
17
+ },
18
+ {
19
+ "epoch": 0.012519561815336464,
20
+ "grad_norm": 2.008513351833145,
21
+ "learning_rate": 1.0000000000000002e-06,
22
+ "loss": 0.6744,
23
+ "step": 2
24
+ },
25
+ {
26
+ "epoch": 0.018779342723004695,
27
+ "grad_norm": 2.03144664277006,
28
+ "learning_rate": 1.5e-06,
29
+ "loss": 0.6721,
30
+ "step": 3
31
+ },
32
+ {
33
+ "epoch": 0.025039123630672927,
34
+ "grad_norm": 1.9480725202469245,
35
+ "learning_rate": 2.0000000000000003e-06,
36
+ "loss": 0.6577,
37
+ "step": 4
38
+ },
39
+ {
40
+ "epoch": 0.03129890453834116,
41
+ "grad_norm": 1.8678118004054254,
42
+ "learning_rate": 2.5e-06,
43
+ "loss": 0.6484,
44
+ "step": 5
45
+ },
46
+ {
47
+ "epoch": 0.03755868544600939,
48
+ "grad_norm": 1.6583787538868422,
49
+ "learning_rate": 3e-06,
50
+ "loss": 0.6174,
51
+ "step": 6
52
+ },
53
+ {
54
+ "epoch": 0.04381846635367762,
55
+ "grad_norm": 1.5614405714896737,
56
+ "learning_rate": 3.5000000000000004e-06,
57
+ "loss": 0.5896,
58
+ "step": 7
59
+ },
60
+ {
61
+ "epoch": 0.050078247261345854,
62
+ "grad_norm": 0.5773143053283745,
63
+ "learning_rate": 4.000000000000001e-06,
64
+ "loss": 0.5557,
65
+ "step": 8
66
+ },
67
+ {
68
+ "epoch": 0.056338028169014086,
69
+ "grad_norm": 0.3043811484340276,
70
+ "learning_rate": 4.5e-06,
71
+ "loss": 0.541,
72
+ "step": 9
73
+ },
74
+ {
75
+ "epoch": 0.06259780907668232,
76
+ "grad_norm": 0.8131531353366078,
77
+ "learning_rate": 5e-06,
78
+ "loss": 0.5595,
79
+ "step": 10
80
+ },
81
+ {
82
+ "epoch": 0.06885758998435054,
83
+ "grad_norm": 0.424180567084822,
84
+ "learning_rate": 5.500000000000001e-06,
85
+ "loss": 0.5427,
86
+ "step": 11
87
+ },
88
+ {
89
+ "epoch": 0.07511737089201878,
90
+ "grad_norm": 0.2913041969769501,
91
+ "learning_rate": 6e-06,
92
+ "loss": 0.5274,
93
+ "step": 12
94
+ },
95
+ {
96
+ "epoch": 0.081377151799687,
97
+ "grad_norm": 0.34524917385772347,
98
+ "learning_rate": 6.5000000000000004e-06,
99
+ "loss": 0.5337,
100
+ "step": 13
101
+ },
102
+ {
103
+ "epoch": 0.08763693270735524,
104
+ "grad_norm": 0.36469195568794854,
105
+ "learning_rate": 7.000000000000001e-06,
106
+ "loss": 0.5279,
107
+ "step": 14
108
+ },
109
+ {
110
+ "epoch": 0.09389671361502347,
111
+ "grad_norm": 0.35209082489157323,
112
+ "learning_rate": 7.5e-06,
113
+ "loss": 0.5296,
114
+ "step": 15
115
+ },
116
+ {
117
+ "epoch": 0.10015649452269171,
118
+ "grad_norm": 0.28086156745404856,
119
+ "learning_rate": 8.000000000000001e-06,
120
+ "loss": 0.5319,
121
+ "step": 16
122
+ },
123
+ {
124
+ "epoch": 0.10641627543035993,
125
+ "grad_norm": 0.5457849868763605,
126
+ "learning_rate": 8.500000000000002e-06,
127
+ "loss": 0.5199,
128
+ "step": 17
129
+ },
130
+ {
131
+ "epoch": 0.11267605633802817,
132
+ "grad_norm": 0.264594169690208,
133
+ "learning_rate": 9e-06,
134
+ "loss": 0.5234,
135
+ "step": 18
136
+ },
137
+ {
138
+ "epoch": 0.1189358372456964,
139
+ "grad_norm": 0.2472097021778676,
140
+ "learning_rate": 9.5e-06,
141
+ "loss": 0.5248,
142
+ "step": 19
143
+ },
144
+ {
145
+ "epoch": 0.12519561815336464,
146
+ "grad_norm": 0.2560549908847749,
147
+ "learning_rate": 1e-05,
148
+ "loss": 0.5159,
149
+ "step": 20
150
+ },
151
+ {
152
+ "epoch": 0.13145539906103287,
153
+ "grad_norm": 0.4101523009554862,
154
+ "learning_rate": 1.05e-05,
155
+ "loss": 0.5058,
156
+ "step": 21
157
+ },
158
+ {
159
+ "epoch": 0.13771517996870108,
160
+ "grad_norm": 0.22290433425318873,
161
+ "learning_rate": 1.1000000000000001e-05,
162
+ "loss": 0.5099,
163
+ "step": 22
164
+ },
165
+ {
166
+ "epoch": 0.14397496087636932,
167
+ "grad_norm": 0.2600145857043661,
168
+ "learning_rate": 1.1500000000000002e-05,
169
+ "loss": 0.5076,
170
+ "step": 23
171
+ },
172
+ {
173
+ "epoch": 0.15023474178403756,
174
+ "grad_norm": 1.1584269063197106,
175
+ "learning_rate": 1.2e-05,
176
+ "loss": 0.5133,
177
+ "step": 24
178
+ },
179
+ {
180
+ "epoch": 0.1564945226917058,
181
+ "grad_norm": 0.21303015786105067,
182
+ "learning_rate": 1.25e-05,
183
+ "loss": 0.5009,
184
+ "step": 25
185
+ },
186
+ {
187
+ "epoch": 0.162754303599374,
188
+ "grad_norm": 2.5709430754104345,
189
+ "learning_rate": 1.3000000000000001e-05,
190
+ "loss": 0.5067,
191
+ "step": 26
192
+ },
193
+ {
194
+ "epoch": 0.16901408450704225,
195
+ "grad_norm": 0.42260631876680255,
196
+ "learning_rate": 1.3500000000000001e-05,
197
+ "loss": 0.4951,
198
+ "step": 27
199
+ },
200
+ {
201
+ "epoch": 0.1752738654147105,
202
+ "grad_norm": 0.2122989372030049,
203
+ "learning_rate": 1.4000000000000001e-05,
204
+ "loss": 0.4968,
205
+ "step": 28
206
+ },
207
+ {
208
+ "epoch": 0.18153364632237873,
209
+ "grad_norm": 0.36382001881720555,
210
+ "learning_rate": 1.45e-05,
211
+ "loss": 0.5035,
212
+ "step": 29
213
+ },
214
+ {
215
+ "epoch": 0.18779342723004694,
216
+ "grad_norm": 0.22094603076455596,
217
+ "learning_rate": 1.5e-05,
218
+ "loss": 0.5049,
219
+ "step": 30
220
+ },
221
+ {
222
+ "epoch": 0.19405320813771518,
223
+ "grad_norm": 0.17188920546056902,
224
+ "learning_rate": 1.55e-05,
225
+ "loss": 0.4979,
226
+ "step": 31
227
+ },
228
+ {
229
+ "epoch": 0.20031298904538342,
230
+ "grad_norm": 0.18515458685485783,
231
+ "learning_rate": 1.6000000000000003e-05,
232
+ "loss": 0.4916,
233
+ "step": 32
234
+ },
235
+ {
236
+ "epoch": 0.20657276995305165,
237
+ "grad_norm": 0.783356101762532,
238
+ "learning_rate": 1.65e-05,
239
+ "loss": 0.4929,
240
+ "step": 33
241
+ },
242
+ {
243
+ "epoch": 0.21283255086071987,
244
+ "grad_norm": 0.19059224326067628,
245
+ "learning_rate": 1.7000000000000003e-05,
246
+ "loss": 0.4945,
247
+ "step": 34
248
+ },
249
+ {
250
+ "epoch": 0.2190923317683881,
251
+ "grad_norm": 0.2275442577977743,
252
+ "learning_rate": 1.75e-05,
253
+ "loss": 0.4936,
254
+ "step": 35
255
+ },
256
+ {
257
+ "epoch": 0.22535211267605634,
258
+ "grad_norm": 0.24798149507141237,
259
+ "learning_rate": 1.8e-05,
260
+ "loss": 0.4898,
261
+ "step": 36
262
+ },
263
+ {
264
+ "epoch": 0.23161189358372458,
265
+ "grad_norm": 0.20682357544778035,
266
+ "learning_rate": 1.85e-05,
267
+ "loss": 0.4888,
268
+ "step": 37
269
+ },
270
+ {
271
+ "epoch": 0.2378716744913928,
272
+ "grad_norm": 0.19518819682961547,
273
+ "learning_rate": 1.9e-05,
274
+ "loss": 0.4899,
275
+ "step": 38
276
+ },
277
+ {
278
+ "epoch": 0.24413145539906103,
279
+ "grad_norm": 0.18423871547579748,
280
+ "learning_rate": 1.9500000000000003e-05,
281
+ "loss": 0.4868,
282
+ "step": 39
283
+ },
284
+ {
285
+ "epoch": 0.25039123630672927,
286
+ "grad_norm": 0.1714820355275791,
287
+ "learning_rate": 2e-05,
288
+ "loss": 0.4795,
289
+ "step": 40
290
+ },
291
+ {
292
+ "epoch": 0.2566510172143975,
293
+ "grad_norm": 0.19187618384155788,
294
+ "learning_rate": 2.05e-05,
295
+ "loss": 0.4821,
296
+ "step": 41
297
+ },
298
+ {
299
+ "epoch": 0.26291079812206575,
300
+ "grad_norm": 0.1422378326228944,
301
+ "learning_rate": 2.1e-05,
302
+ "loss": 0.4829,
303
+ "step": 42
304
+ },
305
+ {
306
+ "epoch": 0.26917057902973396,
307
+ "grad_norm": 0.14724977757162294,
308
+ "learning_rate": 2.15e-05,
309
+ "loss": 0.4811,
310
+ "step": 43
311
+ },
312
+ {
313
+ "epoch": 0.27543035993740217,
314
+ "grad_norm": 0.16077227738580077,
315
+ "learning_rate": 2.2000000000000003e-05,
316
+ "loss": 0.477,
317
+ "step": 44
318
+ },
319
+ {
320
+ "epoch": 0.28169014084507044,
321
+ "grad_norm": 0.15993679259901028,
322
+ "learning_rate": 2.25e-05,
323
+ "loss": 0.4789,
324
+ "step": 45
325
+ },
326
+ {
327
+ "epoch": 0.28794992175273865,
328
+ "grad_norm": 0.14385134377084383,
329
+ "learning_rate": 2.3000000000000003e-05,
330
+ "loss": 0.4641,
331
+ "step": 46
332
+ },
333
+ {
334
+ "epoch": 0.2942097026604069,
335
+ "grad_norm": 0.14244559356804792,
336
+ "learning_rate": 2.35e-05,
337
+ "loss": 0.4767,
338
+ "step": 47
339
+ },
340
+ {
341
+ "epoch": 0.3004694835680751,
342
+ "grad_norm": 0.1481660114240819,
343
+ "learning_rate": 2.4e-05,
344
+ "loss": 0.4759,
345
+ "step": 48
346
+ },
347
+ {
348
+ "epoch": 0.30672926447574334,
349
+ "grad_norm": 0.14195363156015162,
350
+ "learning_rate": 2.45e-05,
351
+ "loss": 0.471,
352
+ "step": 49
353
+ },
354
+ {
355
+ "epoch": 0.3129890453834116,
356
+ "grad_norm": 0.15220552720898642,
357
+ "learning_rate": 2.5e-05,
358
+ "loss": 0.4715,
359
+ "step": 50
360
+ },
361
+ {
362
+ "epoch": 0.3192488262910798,
363
+ "grad_norm": 0.13409784658365015,
364
+ "learning_rate": 2.5500000000000003e-05,
365
+ "loss": 0.4692,
366
+ "step": 51
367
+ },
368
+ {
369
+ "epoch": 0.325508607198748,
370
+ "grad_norm": 0.13766694658848178,
371
+ "learning_rate": 2.6000000000000002e-05,
372
+ "loss": 0.47,
373
+ "step": 52
374
+ },
375
+ {
376
+ "epoch": 0.3317683881064163,
377
+ "grad_norm": 0.13097864679643595,
378
+ "learning_rate": 2.6500000000000004e-05,
379
+ "loss": 0.4651,
380
+ "step": 53
381
+ },
382
+ {
383
+ "epoch": 0.3380281690140845,
384
+ "grad_norm": 0.13207003285729219,
385
+ "learning_rate": 2.7000000000000002e-05,
386
+ "loss": 0.4714,
387
+ "step": 54
388
+ },
389
+ {
390
+ "epoch": 0.3442879499217527,
391
+ "grad_norm": 0.14128427173382038,
392
+ "learning_rate": 2.7500000000000004e-05,
393
+ "loss": 0.4719,
394
+ "step": 55
395
+ },
396
+ {
397
+ "epoch": 0.350547730829421,
398
+ "grad_norm": 0.13599048333974484,
399
+ "learning_rate": 2.8000000000000003e-05,
400
+ "loss": 0.4657,
401
+ "step": 56
402
+ },
403
+ {
404
+ "epoch": 0.3568075117370892,
405
+ "grad_norm": 0.1547358977814178,
406
+ "learning_rate": 2.8499999999999998e-05,
407
+ "loss": 0.4599,
408
+ "step": 57
409
+ },
410
+ {
411
+ "epoch": 0.36306729264475746,
412
+ "grad_norm": 0.1357320992255676,
413
+ "learning_rate": 2.9e-05,
414
+ "loss": 0.4615,
415
+ "step": 58
416
+ },
417
+ {
418
+ "epoch": 0.36932707355242567,
419
+ "grad_norm": 0.14465717873045295,
420
+ "learning_rate": 2.95e-05,
421
+ "loss": 0.4738,
422
+ "step": 59
423
+ },
424
+ {
425
+ "epoch": 0.3755868544600939,
426
+ "grad_norm": 0.5900603203611421,
427
+ "learning_rate": 3e-05,
428
+ "loss": 0.4702,
429
+ "step": 60
430
+ },
431
+ {
432
+ "epoch": 0.38184663536776214,
433
+ "grad_norm": 0.17729474902277623,
434
+ "learning_rate": 3.05e-05,
435
+ "loss": 0.4592,
436
+ "step": 61
437
+ },
438
+ {
439
+ "epoch": 0.38810641627543035,
440
+ "grad_norm": 0.22055664690525556,
441
+ "learning_rate": 3.1e-05,
442
+ "loss": 0.47,
443
+ "step": 62
444
+ },
445
+ {
446
+ "epoch": 0.39436619718309857,
447
+ "grad_norm": 0.22917133262033845,
448
+ "learning_rate": 3.15e-05,
449
+ "loss": 0.4668,
450
+ "step": 63
451
+ },
452
+ {
453
+ "epoch": 0.40062597809076683,
454
+ "grad_norm": 0.23278911760289017,
455
+ "learning_rate": 3.2000000000000005e-05,
456
+ "loss": 0.4691,
457
+ "step": 64
458
+ },
459
+ {
460
+ "epoch": 0.40688575899843504,
461
+ "grad_norm": 0.23911939507472177,
462
+ "learning_rate": 3.2500000000000004e-05,
463
+ "loss": 0.4662,
464
+ "step": 65
465
+ },
466
+ {
467
+ "epoch": 0.4131455399061033,
468
+ "grad_norm": 0.19447041878105836,
469
+ "learning_rate": 3.3e-05,
470
+ "loss": 0.4633,
471
+ "step": 66
472
+ },
473
+ {
474
+ "epoch": 0.4194053208137715,
475
+ "grad_norm": 0.17498726962496755,
476
+ "learning_rate": 3.35e-05,
477
+ "loss": 0.4654,
478
+ "step": 67
479
+ },
480
+ {
481
+ "epoch": 0.42566510172143973,
482
+ "grad_norm": 0.24918375228266929,
483
+ "learning_rate": 3.4000000000000007e-05,
484
+ "loss": 0.477,
485
+ "step": 68
486
+ },
487
+ {
488
+ "epoch": 0.431924882629108,
489
+ "grad_norm": 0.2850664865678729,
490
+ "learning_rate": 3.45e-05,
491
+ "loss": 0.4648,
492
+ "step": 69
493
+ },
494
+ {
495
+ "epoch": 0.4381846635367762,
496
+ "grad_norm": 0.27562629972396513,
497
+ "learning_rate": 3.5e-05,
498
+ "loss": 0.4667,
499
+ "step": 70
500
+ },
501
+ {
502
+ "epoch": 0.4444444444444444,
503
+ "grad_norm": 0.22637202856522412,
504
+ "learning_rate": 3.55e-05,
505
+ "loss": 0.4653,
506
+ "step": 71
507
+ },
508
+ {
509
+ "epoch": 0.4507042253521127,
510
+ "grad_norm": 0.2295442026728235,
511
+ "learning_rate": 3.6e-05,
512
+ "loss": 0.4622,
513
+ "step": 72
514
+ },
515
+ {
516
+ "epoch": 0.4569640062597809,
517
+ "grad_norm": 0.26572612655057165,
518
+ "learning_rate": 3.65e-05,
519
+ "loss": 0.4673,
520
+ "step": 73
521
+ },
522
+ {
523
+ "epoch": 0.46322378716744916,
524
+ "grad_norm": 0.2496817546620412,
525
+ "learning_rate": 3.7e-05,
526
+ "loss": 0.4611,
527
+ "step": 74
528
+ },
529
+ {
530
+ "epoch": 0.4694835680751174,
531
+ "grad_norm": 0.21430723659191686,
532
+ "learning_rate": 3.7500000000000003e-05,
533
+ "loss": 0.4637,
534
+ "step": 75
535
+ },
536
+ {
537
+ "epoch": 0.4757433489827856,
538
+ "grad_norm": 0.1799606207168491,
539
+ "learning_rate": 3.8e-05,
540
+ "loss": 0.4612,
541
+ "step": 76
542
+ },
543
+ {
544
+ "epoch": 0.48200312989045385,
545
+ "grad_norm": 0.2329269891744439,
546
+ "learning_rate": 3.85e-05,
547
+ "loss": 0.4569,
548
+ "step": 77
549
+ },
550
+ {
551
+ "epoch": 0.48826291079812206,
552
+ "grad_norm": 0.2859704851548014,
553
+ "learning_rate": 3.9000000000000006e-05,
554
+ "loss": 0.4677,
555
+ "step": 78
556
+ },
557
+ {
558
+ "epoch": 0.4945226917057903,
559
+ "grad_norm": 0.3153100598444141,
560
+ "learning_rate": 3.9500000000000005e-05,
561
+ "loss": 0.465,
562
+ "step": 79
563
+ },
564
+ {
565
+ "epoch": 0.5007824726134585,
566
+ "grad_norm": 0.3165950932566608,
567
+ "learning_rate": 4e-05,
568
+ "loss": 0.4755,
569
+ "step": 80
570
+ },
571
+ {
572
+ "epoch": 0.5070422535211268,
573
+ "grad_norm": 0.3018577292754275,
574
+ "learning_rate": 4.05e-05,
575
+ "loss": 0.464,
576
+ "step": 81
577
+ },
578
+ {
579
+ "epoch": 0.513302034428795,
580
+ "grad_norm": 0.39363558044861696,
581
+ "learning_rate": 4.1e-05,
582
+ "loss": 0.4701,
583
+ "step": 82
584
+ },
585
+ {
586
+ "epoch": 0.5195618153364632,
587
+ "grad_norm": 0.44171413078007776,
588
+ "learning_rate": 4.15e-05,
589
+ "loss": 0.4697,
590
+ "step": 83
591
+ },
592
+ {
593
+ "epoch": 0.5258215962441315,
594
+ "grad_norm": 0.4086449510625894,
595
+ "learning_rate": 4.2e-05,
596
+ "loss": 0.4611,
597
+ "step": 84
598
+ },
599
+ {
600
+ "epoch": 0.5320813771517997,
601
+ "grad_norm": 0.3156689305434587,
602
+ "learning_rate": 4.25e-05,
603
+ "loss": 0.4633,
604
+ "step": 85
605
+ },
606
+ {
607
+ "epoch": 0.5383411580594679,
608
+ "grad_norm": 0.37582415992669976,
609
+ "learning_rate": 4.3e-05,
610
+ "loss": 0.4689,
611
+ "step": 86
612
+ },
613
+ {
614
+ "epoch": 0.5446009389671361,
615
+ "grad_norm": 0.3751728997948819,
616
+ "learning_rate": 4.35e-05,
617
+ "loss": 0.4658,
618
+ "step": 87
619
+ },
620
+ {
621
+ "epoch": 0.5508607198748043,
622
+ "grad_norm": 0.2622604607003995,
623
+ "learning_rate": 4.4000000000000006e-05,
624
+ "loss": 0.4641,
625
+ "step": 88
626
+ },
627
+ {
628
+ "epoch": 0.5571205007824727,
629
+ "grad_norm": 0.27806769516567914,
630
+ "learning_rate": 4.4500000000000004e-05,
631
+ "loss": 0.4689,
632
+ "step": 89
633
+ },
634
+ {
635
+ "epoch": 0.5633802816901409,
636
+ "grad_norm": 0.37193892514568727,
637
+ "learning_rate": 4.5e-05,
638
+ "loss": 0.4645,
639
+ "step": 90
640
+ },
641
+ {
642
+ "epoch": 0.5696400625978091,
643
+ "grad_norm": 0.319234610988282,
644
+ "learning_rate": 4.55e-05,
645
+ "loss": 0.4697,
646
+ "step": 91
647
+ },
648
+ {
649
+ "epoch": 0.5758998435054773,
650
+ "grad_norm": 0.24391835650924631,
651
+ "learning_rate": 4.600000000000001e-05,
652
+ "loss": 0.4605,
653
+ "step": 92
654
+ },
655
+ {
656
+ "epoch": 0.5821596244131455,
657
+ "grad_norm": 0.3860119064167233,
658
+ "learning_rate": 4.6500000000000005e-05,
659
+ "loss": 0.4721,
660
+ "step": 93
661
+ },
662
+ {
663
+ "epoch": 0.5884194053208138,
664
+ "grad_norm": 0.43978262147491526,
665
+ "learning_rate": 4.7e-05,
666
+ "loss": 0.4692,
667
+ "step": 94
668
+ },
669
+ {
670
+ "epoch": 0.594679186228482,
671
+ "grad_norm": 0.2869109051387356,
672
+ "learning_rate": 4.75e-05,
673
+ "loss": 0.4644,
674
+ "step": 95
675
+ },
676
+ {
677
+ "epoch": 0.6009389671361502,
678
+ "grad_norm": 0.33046074741721215,
679
+ "learning_rate": 4.8e-05,
680
+ "loss": 0.4711,
681
+ "step": 96
682
+ },
683
+ {
684
+ "epoch": 0.6071987480438185,
685
+ "grad_norm": 0.3874189152162858,
686
+ "learning_rate": 4.85e-05,
687
+ "loss": 0.4694,
688
+ "step": 97
689
+ },
690
+ {
691
+ "epoch": 0.6134585289514867,
692
+ "grad_norm": 0.46318630797414556,
693
+ "learning_rate": 4.9e-05,
694
+ "loss": 0.4741,
695
+ "step": 98
696
+ },
697
+ {
698
+ "epoch": 0.6197183098591549,
699
+ "grad_norm": 0.6037444606802089,
700
+ "learning_rate": 4.9500000000000004e-05,
701
+ "loss": 0.4754,
702
+ "step": 99
703
+ },
704
+ {
705
+ "epoch": 0.6259780907668232,
706
+ "grad_norm": 0.5037059436389102,
707
+ "learning_rate": 5e-05,
708
+ "loss": 0.4739,
709
+ "step": 100
710
+ },
711
+ {
712
+ "epoch": 0.6322378716744914,
713
+ "grad_norm": 0.5631190436137139,
714
+ "learning_rate": 4.9997404092249336e-05,
715
+ "loss": 0.4699,
716
+ "step": 101
717
+ },
718
+ {
719
+ "epoch": 0.6384976525821596,
720
+ "grad_norm": 0.39119483297638863,
721
+ "learning_rate": 4.998961690809628e-05,
722
+ "loss": 0.4703,
723
+ "step": 102
724
+ },
725
+ {
726
+ "epoch": 0.6447574334898278,
727
+ "grad_norm": 0.40196303529424704,
728
+ "learning_rate": 4.997664006472579e-05,
729
+ "loss": 0.4749,
730
+ "step": 103
731
+ },
732
+ {
733
+ "epoch": 0.651017214397496,
734
+ "grad_norm": 0.3397733110278162,
735
+ "learning_rate": 4.9958476257072914e-05,
736
+ "loss": 0.4654,
737
+ "step": 104
738
+ },
739
+ {
740
+ "epoch": 0.6572769953051644,
741
+ "grad_norm": 0.2670846226151608,
742
+ "learning_rate": 4.993512925726319e-05,
743
+ "loss": 0.4716,
744
+ "step": 105
745
+ },
746
+ {
747
+ "epoch": 0.6635367762128326,
748
+ "grad_norm": 0.36681659702689784,
749
+ "learning_rate": 4.990660391382923e-05,
750
+ "loss": 0.4704,
751
+ "step": 106
752
+ },
753
+ {
754
+ "epoch": 0.6697965571205008,
755
+ "grad_norm": 0.26058292855009557,
756
+ "learning_rate": 4.987290615070385e-05,
757
+ "loss": 0.4647,
758
+ "step": 107
759
+ },
760
+ {
761
+ "epoch": 0.676056338028169,
762
+ "grad_norm": 0.25205128219384887,
763
+ "learning_rate": 4.983404296598979e-05,
764
+ "loss": 0.4725,
765
+ "step": 108
766
+ },
767
+ {
768
+ "epoch": 0.6823161189358372,
769
+ "grad_norm": 0.3208687051782515,
770
+ "learning_rate": 4.9790022430506463e-05,
771
+ "loss": 0.471,
772
+ "step": 109
773
+ },
774
+ {
775
+ "epoch": 0.6885758998435054,
776
+ "grad_norm": 0.2306209439140453,
777
+ "learning_rate": 4.974085368611381e-05,
778
+ "loss": 0.473,
779
+ "step": 110
780
+ },
781
+ {
782
+ "epoch": 0.6948356807511737,
783
+ "grad_norm": 0.21458192536569118,
784
+ "learning_rate": 4.968654694381379e-05,
785
+ "loss": 0.4692,
786
+ "step": 111
787
+ },
788
+ {
789
+ "epoch": 0.701095461658842,
790
+ "grad_norm": 0.24400329234341836,
791
+ "learning_rate": 4.962711348162987e-05,
792
+ "loss": 0.4742,
793
+ "step": 112
794
+ },
795
+ {
796
+ "epoch": 0.7073552425665102,
797
+ "grad_norm": 0.5445701250609367,
798
+ "learning_rate": 4.956256564226487e-05,
799
+ "loss": 0.4677,
800
+ "step": 113
801
+ },
802
+ {
803
+ "epoch": 0.7136150234741784,
804
+ "grad_norm": 0.2485591152431222,
805
+ "learning_rate": 4.949291683053769e-05,
806
+ "loss": 0.478,
807
+ "step": 114
808
+ },
809
+ {
810
+ "epoch": 0.7198748043818466,
811
+ "grad_norm": 0.2683190648451619,
812
+ "learning_rate": 4.941818151059956e-05,
813
+ "loss": 0.468,
814
+ "step": 115
815
+ },
816
+ {
817
+ "epoch": 0.7261345852895149,
818
+ "grad_norm": 0.17377296116604452,
819
+ "learning_rate": 4.933837520293017e-05,
820
+ "loss": 0.4682,
821
+ "step": 116
822
+ },
823
+ {
824
+ "epoch": 0.7323943661971831,
825
+ "grad_norm": 0.19892874090328266,
826
+ "learning_rate": 4.9253514481114535e-05,
827
+ "loss": 0.4716,
828
+ "step": 117
829
+ },
830
+ {
831
+ "epoch": 0.7386541471048513,
832
+ "grad_norm": 0.22470516800088272,
833
+ "learning_rate": 4.91636169684011e-05,
834
+ "loss": 0.4807,
835
+ "step": 118
836
+ },
837
+ {
838
+ "epoch": 0.7449139280125195,
839
+ "grad_norm": 0.23033947133081567,
840
+ "learning_rate": 4.906870133404187e-05,
841
+ "loss": 0.4721,
842
+ "step": 119
843
+ },
844
+ {
845
+ "epoch": 0.7511737089201878,
846
+ "grad_norm": 0.2764527709442302,
847
+ "learning_rate": 4.896878728941531e-05,
848
+ "loss": 0.4693,
849
+ "step": 120
850
+ },
851
+ {
852
+ "epoch": 0.7574334898278561,
853
+ "grad_norm": 0.28746556965081915,
854
+ "learning_rate": 4.8863895583932836e-05,
855
+ "loss": 0.4767,
856
+ "step": 121
857
+ },
858
+ {
859
+ "epoch": 0.7636932707355243,
860
+ "grad_norm": 0.32061574884194566,
861
+ "learning_rate": 4.875404800072977e-05,
862
+ "loss": 0.4643,
863
+ "step": 122
864
+ },
865
+ {
866
+ "epoch": 0.7699530516431925,
867
+ "grad_norm": 0.34181281337669966,
868
+ "learning_rate": 4.86392673521415e-05,
869
+ "loss": 0.4602,
870
+ "step": 123
871
+ },
872
+ {
873
+ "epoch": 0.7762128325508607,
874
+ "grad_norm": 0.30941984507586506,
875
+ "learning_rate": 4.8519577474966074e-05,
876
+ "loss": 0.4711,
877
+ "step": 124
878
+ },
879
+ {
880
+ "epoch": 0.7824726134585289,
881
+ "grad_norm": 0.23600978038755785,
882
+ "learning_rate": 4.839500322551386e-05,
883
+ "loss": 0.4696,
884
+ "step": 125
885
+ },
886
+ {
887
+ "epoch": 0.7887323943661971,
888
+ "grad_norm": 0.2577164285099203,
889
+ "learning_rate": 4.8265570474445636e-05,
890
+ "loss": 0.4644,
891
+ "step": 126
892
+ },
893
+ {
894
+ "epoch": 0.7949921752738655,
895
+ "grad_norm": 0.27823451721774306,
896
+ "learning_rate": 4.813130610139994e-05,
897
+ "loss": 0.479,
898
+ "step": 127
899
+ },
900
+ {
901
+ "epoch": 0.8012519561815337,
902
+ "grad_norm": 0.22061524932206344,
903
+ "learning_rate": 4.7992237989410904e-05,
904
+ "loss": 0.4711,
905
+ "step": 128
906
+ },
907
+ {
908
+ "epoch": 0.8075117370892019,
909
+ "grad_norm": 0.20216340578684158,
910
+ "learning_rate": 4.784839501911771e-05,
911
+ "loss": 0.468,
912
+ "step": 129
913
+ },
914
+ {
915
+ "epoch": 0.8137715179968701,
916
+ "grad_norm": 0.27542745611047786,
917
+ "learning_rate": 4.7699807062766876e-05,
918
+ "loss": 0.4754,
919
+ "step": 130
920
+ },
921
+ {
922
+ "epoch": 0.8200312989045383,
923
+ "grad_norm": 0.21954180738847087,
924
+ "learning_rate": 4.75465049780086e-05,
925
+ "loss": 0.4595,
926
+ "step": 131
927
+ },
928
+ {
929
+ "epoch": 0.8262910798122066,
930
+ "grad_norm": 0.19430624161738624,
931
+ "learning_rate": 4.738852060148849e-05,
932
+ "loss": 0.4747,
933
+ "step": 132
934
+ },
935
+ {
936
+ "epoch": 0.8325508607198748,
937
+ "grad_norm": 0.1884671644058954,
938
+ "learning_rate": 4.722588674223594e-05,
939
+ "loss": 0.4748,
940
+ "step": 133
941
+ },
942
+ {
943
+ "epoch": 0.838810641627543,
944
+ "grad_norm": 0.20913369047927102,
945
+ "learning_rate": 4.7058637174850604e-05,
946
+ "loss": 0.4653,
947
+ "step": 134
948
+ },
949
+ {
950
+ "epoch": 0.8450704225352113,
951
+ "grad_norm": 0.19564021089464265,
952
+ "learning_rate": 4.688680663248837e-05,
953
+ "loss": 0.4644,
954
+ "step": 135
955
+ },
956
+ {
957
+ "epoch": 0.8513302034428795,
958
+ "grad_norm": 0.17437877798570775,
959
+ "learning_rate": 4.671043079964815e-05,
960
+ "loss": 0.4666,
961
+ "step": 136
962
+ },
963
+ {
964
+ "epoch": 0.8575899843505478,
965
+ "grad_norm": 0.18658537333186465,
966
+ "learning_rate": 4.652954630476127e-05,
967
+ "loss": 0.463,
968
+ "step": 137
969
+ },
970
+ {
971
+ "epoch": 0.863849765258216,
972
+ "grad_norm": 0.1916983418252378,
973
+ "learning_rate": 4.634419071258472e-05,
974
+ "loss": 0.4801,
975
+ "step": 138
976
+ },
977
+ {
978
+ "epoch": 0.8701095461658842,
979
+ "grad_norm": 0.18269150591223743,
980
+ "learning_rate": 4.615440251639995e-05,
981
+ "loss": 0.465,
982
+ "step": 139
983
+ },
984
+ {
985
+ "epoch": 0.8763693270735524,
986
+ "grad_norm": 0.19124021712384207,
987
+ "learning_rate": 4.5960221130018946e-05,
988
+ "loss": 0.4624,
989
+ "step": 140
990
+ },
991
+ {
992
+ "epoch": 0.8826291079812206,
993
+ "grad_norm": 0.17751289300487907,
994
+ "learning_rate": 4.576168687959895e-05,
995
+ "loss": 0.4667,
996
+ "step": 141
997
+ },
998
+ {
999
+ "epoch": 0.8888888888888888,
1000
+ "grad_norm": 0.16256598664527863,
1001
+ "learning_rate": 4.555884099526794e-05,
1002
+ "loss": 0.4724,
1003
+ "step": 142
1004
+ },
1005
+ {
1006
+ "epoch": 0.8951486697965572,
1007
+ "grad_norm": 0.17306660659668968,
1008
+ "learning_rate": 4.535172560256218e-05,
1009
+ "loss": 0.4764,
1010
+ "step": 143
1011
+ },
1012
+ {
1013
+ "epoch": 0.9014084507042254,
1014
+ "grad_norm": 0.15311694878287935,
1015
+ "learning_rate": 4.5140383713677916e-05,
1016
+ "loss": 0.4633,
1017
+ "step": 144
1018
+ },
1019
+ {
1020
+ "epoch": 0.9076682316118936,
1021
+ "grad_norm": 0.16327033693685952,
1022
+ "learning_rate": 4.492485921853894e-05,
1023
+ "loss": 0.4626,
1024
+ "step": 145
1025
+ },
1026
+ {
1027
+ "epoch": 0.9139280125195618,
1028
+ "grad_norm": 0.1577015015575217,
1029
+ "learning_rate": 4.4705196875681854e-05,
1030
+ "loss": 0.465,
1031
+ "step": 146
1032
+ },
1033
+ {
1034
+ "epoch": 0.92018779342723,
1035
+ "grad_norm": 0.14976303947345634,
1036
+ "learning_rate": 4.448144230296093e-05,
1037
+ "loss": 0.4732,
1038
+ "step": 147
1039
+ },
1040
+ {
1041
+ "epoch": 0.9264475743348983,
1042
+ "grad_norm": 0.1799041852337434,
1043
+ "learning_rate": 4.425364196807451e-05,
1044
+ "loss": 0.4638,
1045
+ "step": 148
1046
+ },
1047
+ {
1048
+ "epoch": 0.9327073552425665,
1049
+ "grad_norm": 0.25582934784311545,
1050
+ "learning_rate": 4.402184317891501e-05,
1051
+ "loss": 0.4687,
1052
+ "step": 149
1053
+ },
1054
+ {
1055
+ "epoch": 0.9389671361502347,
1056
+ "grad_norm": 0.14767269207211267,
1057
+ "learning_rate": 4.37860940737443e-05,
1058
+ "loss": 0.4622,
1059
+ "step": 150
1060
+ },
1061
+ {
1062
+ "epoch": 0.945226917057903,
1063
+ "grad_norm": 0.18510146862998086,
1064
+ "learning_rate": 4.354644361119672e-05,
1065
+ "loss": 0.4714,
1066
+ "step": 151
1067
+ },
1068
+ {
1069
+ "epoch": 0.9514866979655712,
1070
+ "grad_norm": 0.1834113544053396,
1071
+ "learning_rate": 4.330294156011172e-05,
1072
+ "loss": 0.4665,
1073
+ "step": 152
1074
+ },
1075
+ {
1076
+ "epoch": 0.9577464788732394,
1077
+ "grad_norm": 0.16106024098596552,
1078
+ "learning_rate": 4.305563848919824e-05,
1079
+ "loss": 0.4612,
1080
+ "step": 153
1081
+ },
1082
+ {
1083
+ "epoch": 0.9640062597809077,
1084
+ "grad_norm": 0.1582714001537092,
1085
+ "learning_rate": 4.2804585756532965e-05,
1086
+ "loss": 0.4656,
1087
+ "step": 154
1088
+ },
1089
+ {
1090
+ "epoch": 0.9702660406885759,
1091
+ "grad_norm": 0.1838011411088347,
1092
+ "learning_rate": 4.254983549889467e-05,
1093
+ "loss": 0.4585,
1094
+ "step": 155
1095
+ },
1096
+ {
1097
+ "epoch": 0.9765258215962441,
1098
+ "grad_norm": 0.22256207898681857,
1099
+ "learning_rate": 4.2291440620936796e-05,
1100
+ "loss": 0.4712,
1101
+ "step": 156
1102
+ },
1103
+ {
1104
+ "epoch": 0.9827856025039123,
1105
+ "grad_norm": 0.16842112143070276,
1106
+ "learning_rate": 4.2029454784200676e-05,
1107
+ "loss": 0.4691,
1108
+ "step": 157
1109
+ },
1110
+ {
1111
+ "epoch": 0.9890453834115805,
1112
+ "grad_norm": 0.15122887832488566,
1113
+ "learning_rate": 4.176393239597144e-05,
1114
+ "loss": 0.4778,
1115
+ "step": 158
1116
+ },
1117
+ {
1118
+ "epoch": 0.9953051643192489,
1119
+ "grad_norm": 0.1902639072378955,
1120
+ "learning_rate": 4.149492859797912e-05,
1121
+ "loss": 0.4688,
1122
+ "step": 159
1123
+ },
1124
+ {
1125
+ "epoch": 1.001564945226917,
1126
+ "grad_norm": 0.17200971150006397,
1127
+ "learning_rate": 4.122249925494726e-05,
1128
+ "loss": 0.464,
1129
+ "step": 160
1130
+ }
1131
+ ],
1132
+ "logging_steps": 1,
1133
+ "max_steps": 318,
1134
+ "num_input_tokens_seen": 0,
1135
+ "num_train_epochs": 2,
1136
+ "save_steps": 16,
1137
+ "total_flos": 1.0356139229184e+16,
1138
+ "train_batch_size": 2,
1139
+ "trial_name": null,
1140
+ "trial_params": null
1141
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6838be8a1bc22ac23837c7b4fd5b41797dd1b59a6f54d379a9faeeae90388906
3
+ size 7800
zero_to_fp32.py ADDED
@@ -0,0 +1,592 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) Microsoft Corporation.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ # DeepSpeed Team
7
+
8
+ # This script extracts fp32 consolidated weights from a zero 1, 2 and 3 DeepSpeed checkpoints. It gets
9
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
10
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
11
+ # application.
12
+ #
13
+ # example: python zero_to_fp32.py . pytorch_model.bin
14
+
15
+ import argparse
16
+ import torch
17
+ import glob
18
+ import math
19
+ import os
20
+ import re
21
+ from collections import OrderedDict
22
+ from dataclasses import dataclass
23
+
24
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
25
+ # DeepSpeed data structures it has to be available in the current python environment.
26
+ from deepspeed.utils import logger
27
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
28
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
29
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
30
+
31
+
32
+ @dataclass
33
+ class zero_model_state:
34
+ buffers: dict()
35
+ param_shapes: dict()
36
+ shared_params: list
37
+ ds_version: int
38
+ frozen_param_shapes: dict()
39
+ frozen_param_fragments: dict()
40
+
41
+
42
+ debug = 0
43
+
44
+ # load to cpu
45
+ device = torch.device('cpu')
46
+
47
+
48
+ def atoi(text):
49
+ return int(text) if text.isdigit() else text
50
+
51
+
52
+ def natural_keys(text):
53
+ '''
54
+ alist.sort(key=natural_keys) sorts in human order
55
+ http://nedbatchelder.com/blog/200712/human_sorting.html
56
+ (See Toothy's implementation in the comments)
57
+ '''
58
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
59
+
60
+
61
+ def get_model_state_file(checkpoint_dir, zero_stage):
62
+ if not os.path.isdir(checkpoint_dir):
63
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
64
+
65
+ # there should be only one file
66
+ if zero_stage <= 2:
67
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
68
+ elif zero_stage == 3:
69
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
70
+
71
+ if not os.path.exists(file):
72
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
73
+
74
+ return file
75
+
76
+
77
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
78
+ # XXX: need to test that this simple glob rule works for multi-node setup too
79
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
80
+
81
+ if len(ckpt_files) == 0:
82
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
83
+
84
+ return ckpt_files
85
+
86
+
87
+ def get_optim_files(checkpoint_dir):
88
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
89
+
90
+
91
+ def get_model_state_files(checkpoint_dir):
92
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
93
+
94
+
95
+ def parse_model_states(files):
96
+ zero_model_states = []
97
+ for file in files:
98
+ state_dict = torch.load(file, map_location=device)
99
+
100
+ if BUFFER_NAMES not in state_dict:
101
+ raise ValueError(f"{file} is not a model state checkpoint")
102
+ buffer_names = state_dict[BUFFER_NAMES]
103
+ if debug:
104
+ print("Found buffers:", buffer_names)
105
+
106
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
107
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
108
+ param_shapes = state_dict[PARAM_SHAPES]
109
+
110
+ # collect parameters that are included in param_shapes
111
+ param_names = []
112
+ for s in param_shapes:
113
+ for name in s.keys():
114
+ param_names.append(name)
115
+
116
+ # update with frozen parameters
117
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
118
+ if frozen_param_shapes is not None:
119
+ if debug:
120
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
121
+ param_names += list(frozen_param_shapes.keys())
122
+
123
+ # handle shared params
124
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
125
+
126
+ ds_version = state_dict.get(DS_VERSION, None)
127
+
128
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
129
+
130
+ z_model_state = zero_model_state(buffers=buffers,
131
+ param_shapes=param_shapes,
132
+ shared_params=shared_params,
133
+ ds_version=ds_version,
134
+ frozen_param_shapes=frozen_param_shapes,
135
+ frozen_param_fragments=frozen_param_fragments)
136
+ zero_model_states.append(z_model_state)
137
+
138
+ return zero_model_states
139
+
140
+
141
+ def parse_optim_states(files, ds_checkpoint_dir):
142
+
143
+ total_files = len(files)
144
+ state_dicts = []
145
+ for f in files:
146
+ state_dict = torch.load(f, map_location=device)
147
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
148
+ # and also handle the case where it was already removed by another helper script
149
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
150
+ state_dicts.append(state_dict)
151
+
152
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
153
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
154
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
155
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
156
+
157
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
158
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
159
+ # use the max of the partition_count to get the dp world_size.
160
+
161
+ if type(world_size) is list:
162
+ world_size = max(world_size)
163
+
164
+ if world_size != total_files:
165
+ raise ValueError(
166
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
167
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
168
+ )
169
+
170
+ # the groups are named differently in each stage
171
+ if zero_stage <= 2:
172
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
173
+ elif zero_stage == 3:
174
+ fp32_groups_key = FP32_FLAT_GROUPS
175
+ else:
176
+ raise ValueError(f"unknown zero stage {zero_stage}")
177
+
178
+ if zero_stage <= 2:
179
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
180
+ elif zero_stage == 3:
181
+ # if there is more than one param group, there will be multiple flattened tensors - one
182
+ # flattened tensor per group - for simplicity merge them into a single tensor
183
+ #
184
+ # XXX: could make the script more memory efficient for when there are multiple groups - it
185
+ # will require matching the sub-lists of param_shapes for each param group flattened tensor
186
+
187
+ fp32_flat_groups = [
188
+ torch.cat(state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key], 0) for i in range(len(state_dicts))
189
+ ]
190
+
191
+ return zero_stage, world_size, fp32_flat_groups
192
+
193
+
194
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir):
195
+ """
196
+ Returns fp32 state_dict reconstructed from ds checkpoint
197
+
198
+ Args:
199
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
200
+
201
+ """
202
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
203
+
204
+ optim_files = get_optim_files(ds_checkpoint_dir)
205
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
206
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
207
+
208
+ model_files = get_model_state_files(ds_checkpoint_dir)
209
+
210
+ zero_model_states = parse_model_states(model_files)
211
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
212
+
213
+ if zero_stage <= 2:
214
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states)
215
+ elif zero_stage == 3:
216
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states)
217
+
218
+
219
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
220
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
221
+ return
222
+
223
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
224
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
225
+
226
+ if debug:
227
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
228
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
229
+
230
+ wanted_params = len(frozen_param_shapes)
231
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
232
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
233
+ print(f'Frozen params: Have {avail_numel} numels to process.')
234
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
235
+
236
+ total_params = 0
237
+ total_numel = 0
238
+ for name, shape in frozen_param_shapes.items():
239
+ total_params += 1
240
+ unpartitioned_numel = shape.numel()
241
+ total_numel += unpartitioned_numel
242
+
243
+ state_dict[name] = frozen_param_fragments[name]
244
+
245
+ if debug:
246
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
247
+
248
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
249
+
250
+
251
+ def _has_callable(obj, fn):
252
+ attr = getattr(obj, fn, None)
253
+ return callable(attr)
254
+
255
+
256
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
257
+ param_shapes = zero_model_states[0].param_shapes
258
+
259
+ # Reconstruction protocol:
260
+ #
261
+ # XXX: document this
262
+
263
+ if debug:
264
+ for i in range(world_size):
265
+ for j in range(len(fp32_flat_groups[0])):
266
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
267
+
268
+ # XXX: memory usage doubles here (zero2)
269
+ num_param_groups = len(fp32_flat_groups[0])
270
+ merged_single_partition_of_fp32_groups = []
271
+ for i in range(num_param_groups):
272
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
273
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
274
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
275
+ avail_numel = sum(
276
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
277
+
278
+ if debug:
279
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
280
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
281
+ # not asserting if there is a mismatch due to possible padding
282
+ print(f"Have {avail_numel} numels to process.")
283
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
284
+
285
+ # params
286
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
287
+ # out-of-core computing solution
288
+ total_numel = 0
289
+ total_params = 0
290
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
291
+ offset = 0
292
+ avail_numel = full_single_fp32_vector.numel()
293
+ for name, shape in shapes.items():
294
+
295
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
296
+ total_numel += unpartitioned_numel
297
+ total_params += 1
298
+
299
+ if debug:
300
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
301
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
302
+ offset += unpartitioned_numel
303
+
304
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
305
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
306
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
307
+ # live optimizer object, so we are checking that the numbers are within the right range
308
+ align_to = 2 * world_size
309
+
310
+ def zero2_align(x):
311
+ return align_to * math.ceil(x / align_to)
312
+
313
+ if debug:
314
+ print(f"original offset={offset}, avail_numel={avail_numel}")
315
+
316
+ offset = zero2_align(offset)
317
+ avail_numel = zero2_align(avail_numel)
318
+
319
+ if debug:
320
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
321
+
322
+ # Sanity check
323
+ if offset != avail_numel:
324
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
325
+
326
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
327
+
328
+
329
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states):
330
+ state_dict = OrderedDict()
331
+
332
+ # buffers
333
+ buffers = zero_model_states[0].buffers
334
+ state_dict.update(buffers)
335
+ if debug:
336
+ print(f"added {len(buffers)} buffers")
337
+
338
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
339
+
340
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
341
+
342
+ # recover shared parameters
343
+ for pair in zero_model_states[0].shared_params:
344
+ if pair[1] in state_dict:
345
+ state_dict[pair[0]] = state_dict[pair[1]]
346
+
347
+ return state_dict
348
+
349
+
350
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
351
+ remainder = unpartitioned_numel % world_size
352
+ padding_numel = (world_size - remainder) if remainder else 0
353
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
354
+ return partitioned_numel, padding_numel
355
+
356
+
357
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
358
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
359
+ return
360
+
361
+ if debug:
362
+ for i in range(world_size):
363
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
364
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
365
+
366
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
367
+ wanted_params = len(frozen_param_shapes)
368
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
369
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
370
+ print(f'Frozen params: Have {avail_numel} numels to process.')
371
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
372
+
373
+ total_params = 0
374
+ total_numel = 0
375
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
376
+ total_params += 1
377
+ unpartitioned_numel = shape.numel()
378
+ total_numel += unpartitioned_numel
379
+
380
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
381
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
382
+
383
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
384
+
385
+ if debug:
386
+ print(
387
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
388
+ )
389
+
390
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
391
+
392
+
393
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
394
+ param_shapes = zero_model_states[0].param_shapes
395
+ avail_numel = fp32_flat_groups[0].numel() * world_size
396
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
397
+ # param, re-consolidating each param, while dealing with padding if any
398
+
399
+ # merge list of dicts, preserving order
400
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
401
+
402
+ if debug:
403
+ for i in range(world_size):
404
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
405
+
406
+ wanted_params = len(param_shapes)
407
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
408
+ # not asserting if there is a mismatch due to possible padding
409
+ avail_numel = fp32_flat_groups[0].numel() * world_size
410
+ print(f"Trainable params: Have {avail_numel} numels to process.")
411
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
412
+
413
+ # params
414
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
415
+ # out-of-core computing solution
416
+ offset = 0
417
+ total_numel = 0
418
+ total_params = 0
419
+ for name, shape in param_shapes.items():
420
+
421
+ unpartitioned_numel = shape.numel()
422
+ total_numel += unpartitioned_numel
423
+ total_params += 1
424
+
425
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
426
+
427
+ if debug:
428
+ print(
429
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
430
+ )
431
+
432
+ # XXX: memory usage doubles here
433
+ state_dict[name] = torch.cat(
434
+ tuple(fp32_flat_groups[i].narrow(0, offset, partitioned_numel) for i in range(world_size)),
435
+ 0).narrow(0, 0, unpartitioned_numel).view(shape)
436
+ offset += partitioned_numel
437
+
438
+ offset *= world_size
439
+
440
+ # Sanity check
441
+ if offset != avail_numel:
442
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
443
+
444
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
445
+
446
+
447
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states):
448
+ state_dict = OrderedDict()
449
+
450
+ # buffers
451
+ buffers = zero_model_states[0].buffers
452
+ state_dict.update(buffers)
453
+ if debug:
454
+ print(f"added {len(buffers)} buffers")
455
+
456
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
457
+
458
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
459
+
460
+ # recover shared parameters
461
+ for pair in zero_model_states[0].shared_params:
462
+ if pair[1] in state_dict:
463
+ state_dict[pair[0]] = state_dict[pair[1]]
464
+
465
+ return state_dict
466
+
467
+
468
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag=None):
469
+ """
470
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
471
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
472
+ via a model hub.
473
+
474
+ Args:
475
+ - ``checkpoint_dir``: path to the desired checkpoint folder
476
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
477
+
478
+ Returns:
479
+ - pytorch ``state_dict``
480
+
481
+ Note: this approach may not work if your application doesn't have sufficient free CPU memory and
482
+ you may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
483
+ the checkpoint.
484
+
485
+ A typical usage might be ::
486
+
487
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
488
+ # do the training and checkpoint saving
489
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
490
+ model = model.cpu() # move to cpu
491
+ model.load_state_dict(state_dict)
492
+ # submit to model hub or save the model to share with others
493
+
494
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
495
+ application. i.e. you will need to re-initialize the deepspeed engine, since
496
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
497
+
498
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
499
+
500
+ """
501
+ if tag is None:
502
+ latest_path = os.path.join(checkpoint_dir, 'latest')
503
+ if os.path.isfile(latest_path):
504
+ with open(latest_path, 'r') as fd:
505
+ tag = fd.read().strip()
506
+ else:
507
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
508
+
509
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
510
+
511
+ if not os.path.isdir(ds_checkpoint_dir):
512
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
513
+
514
+ return _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir)
515
+
516
+
517
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir, output_file, tag=None):
518
+ """
519
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
520
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
521
+
522
+ Args:
523
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
524
+ - ``output_file``: path to the pytorch fp32 state_dict output file (e.g. path/pytorch_model.bin)
525
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
526
+ """
527
+
528
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
529
+ print(f"Saving fp32 state dict to {output_file}")
530
+ torch.save(state_dict, output_file)
531
+
532
+
533
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
534
+ """
535
+ 1. Put the provided model to cpu
536
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
537
+ 3. Load it into the provided model
538
+
539
+ Args:
540
+ - ``model``: the model object to update
541
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
542
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
543
+
544
+ Returns:
545
+ - ``model`: modified model
546
+
547
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
548
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
549
+ conveniently placed for you in the checkpoint folder.
550
+
551
+ A typical usage might be ::
552
+
553
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
554
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
555
+ # submit to model hub or save the model to share with others
556
+
557
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
558
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
559
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
560
+
561
+ """
562
+ logger.info(f"Extracting fp32 weights")
563
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
564
+
565
+ logger.info(f"Overwriting model with fp32 weights")
566
+ model = model.cpu()
567
+ model.load_state_dict(state_dict, strict=False)
568
+
569
+ return model
570
+
571
+
572
+ if __name__ == "__main__":
573
+
574
+ parser = argparse.ArgumentParser()
575
+ parser.add_argument("checkpoint_dir",
576
+ type=str,
577
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
578
+ parser.add_argument(
579
+ "output_file",
580
+ type=str,
581
+ help="path to the pytorch fp32 state_dict output file (e.g. path/checkpoint-12/pytorch_model.bin)")
582
+ parser.add_argument("-t",
583
+ "--tag",
584
+ type=str,
585
+ default=None,
586
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
587
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
588
+ args = parser.parse_args()
589
+
590
+ debug = args.debug
591
+
592
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir, args.output_file, tag=args.tag)