Checkpoints
Functions:
-
get_auto_model_class
–Get the AutoModel class corresponding to the model class.
-
get_temporary_folder_and_move
–Context manager safe checkpointing.
-
load_training_checkpoint
–Load checkpoint created by save_training_checkpoint() in-place:
-
save_model_only
–Save model weights and config.
-
save_tokenizer_only
–Save only tokenizer to output_dir
get_auto_model_class(model_class)
Get the AutoModel class corresponding to the model class.
Source code in tapeagents/finetune/checkpoints.py
24 25 26 27 28 29 30 31 32 33 34 |
|
get_temporary_folder_and_move(output_dir)
Context manager safe checkpointing.
Creates temporary folder ~output_dir
, then rename to final destination
Source code in tapeagents/finetune/checkpoints.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
load_training_checkpoint(training_state_dir, model, optimizer, lr_scheduler)
Load checkpoint created by save_training_checkpoint() in-place:
- With deepspeed, this will load model, optimizer, lr_scheduler states in-place.
- Without deepspeed, this will only load optimizer, lr_scheduler states in-place, but not model states!
Source code in tapeagents/finetune/checkpoints.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
save_model_only(output_dir, model, unwrap=True, lora=False, safe_serialization=False)
Save model weights and config.
Creates the following files in output_dir/ : - config.json and either: - pytorch_model.bin (single-file model), OR - pytorch_model-XXXXX-of-XXXXX.bin (multi-file model) and pytorch_model.bin.index.json
Note that this does not save optimizer, lr_scheduler, scaler, etc. Use only for later JGA evaluation, not for resuming training
Must be called on all accelerate processes because all of them must save their shards.
Source code in tapeagents/finetune/checkpoints.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
save_tokenizer_only(output_dir, tokenizer)
Save only tokenizer to output_dir
Can be called on all processes.
Source code in tapeagents/finetune/checkpoints.py
345 346 347 348 349 350 351 352 353 354 355 356 357 |
|