ezpz.examples.deepspeed.tp.trainΒΆ
DeepSpeed TP training script for instruction tuning (Hugging Face Trainer).
Launch with:
1 | |
Argparse help is available once optional dependencies (transformers/deepspeed/openai) are installed:
1 | |
DataCollatorForSupervisedDataset
dataclass
ΒΆ
Bases: object
Collate examples for supervised fine-tuning.
Source code in src/ezpz/examples/deepspeed/tp/train.py
__call__(instances)
ΒΆ
Pad and batch token/label tensors.
Source code in src/ezpz/examples/deepspeed/tp/train.py
HfTrainingArguments
dataclass
ΒΆ
Bases: TrainingArguments
Training arguments with model max length and optimizer choice.
Source code in src/ezpz/examples/deepspeed/tp/train.py
SupervisedDataset
ΒΆ
Bases: Dataset
Dataset for supervised fine-tuning.
Source code in src/ezpz/examples/deepspeed/tp/train.py
__getitem__(i)
ΒΆ
__init__(data_path, tokenizer)
ΒΆ
Load JSON data and tokenize prompts/targets.
Source code in src/ezpz/examples/deepspeed/tp/train.py
make_supervised_data_module(tokenizer, data_args)
ΒΆ
Make dataset and collator for supervised fine-tuning.
Source code in src/ezpz/examples/deepspeed/tp/train.py
preprocess(sources, targets, tokenizer)
ΒΆ
Preprocess the data by tokenizing.
Source code in src/ezpz/examples/deepspeed/tp/train.py
smart_tokenizer_and_embedding_resize(special_tokens_dict, tokenizer, model)
ΒΆ
Resize tokenizer and embedding.
Note: This is the unoptimized version that may make your embedding size not be divisible by 64.
Source code in src/ezpz/examples/deepspeed/tp/train.py
train()
ΒΆ
Run supervised HF Trainer fine-tuning with DeepSpeed tensor parallel.
Source code in src/ezpz/examples/deepspeed/tp/train.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 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 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |