ezpz.utils
ยถ
ezpz/utils/init.py
DistributedPdb
ยถ
Bases: Pdb
Supports using PDB from inside a multiprocessing child process.
Usage: DistributedPdb().set_trace()
Source code in src/ezpz/utils/__init__.py
breakpoint(rank=0)
ยถ
Set a breakpoint, but only on a single rank. All other ranks will wait for you to be done with the breakpoint before continuing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rank
|
int
|
Which rank to break on. Default: |
0
|
Source code in src/ezpz/utils/__init__.py
get_bf16_config_json(enabled=True)
ยถ
Get the deepspeed bf16 config json.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enabled
|
bool
|
Whether to use bf16. Default: |
True
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Deepspeed bf16 config. |
Source code in src/ezpz/utils/__init__.py
get_deepspeed_adamw_optimizer_config_json(auto_config=True)
ยถ
Get the deepspeed adamw optimizer config json.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
auto_config
|
bool
|
Whether to use the auto config. Default: |
True
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Deepspeed adamw optimizer config. |
Source code in src/ezpz/utils/__init__.py
get_deepspeed_config_json(auto_config=True, gradient_accumulation_steps=1, gradient_clipping='auto', steps_per_print=10, train_batch_size='auto', train_micro_batch_size_per_gpu='auto', wall_clock_breakdown=False, wandb=True, bf16=True, fp16=None, flops_profiler=None, optimizer=None, scheduler=None, zero_optimization=None, stage=0, allgather_partitions=None, allgather_bucket_size=int(500000000.0), overlap_comm=None, reduce_scatter=True, reduce_bucket_size=int(500000000.0), contiguous_gradients=None, offload_param=None, offload_optimizer=None, stage3_max_live_parameters=int(1000000000.0), stage3_max_reuse_distance=int(1000000000.0), stage3_prefetch_bucket_size=int(500000000.0), stage3_param_persistence_threshold=int(1000000.0), sub_group_size=None, elastic_checkpoint=None, stage3_gather_16bit_weights_on_model_save=None, ignore_unused_parameters=None, round_robin_gradients=None, zero_hpz_partition_size=None, zero_quantized_weights=None, zero_quantized_gradients=None, log_trace_cache_warnings=None, save_config=True, output_file=None, output_dir=None)
ยถ
Write a deepspeed config to the output directory.
Source code in src/ezpz/utils/__init__.py
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 |
|
get_deepspeed_warmup_decay_scheduler_config_json(auto_config=True)
ยถ
Get the deepspeed warmup decay scheduler config json.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
auto_config
|
bool
|
Whether to use the auto config. Default: |
True
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Deepspeed warmup decay scheduler config. |
Source code in src/ezpz/utils/__init__.py
get_deepspeed_zero_config_json(zero_config)
ยถ
get_flops_profiler_config_json(enabled=True, profile_step=1, module_depth=-1, top_modules=1, detailed=True)
ยถ
Get the deepspeed flops profiler config json.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enabled
|
bool
|
Whether to use the flops profiler. Default: |
True
|
profile_step
|
int
|
The step to profile. Default: |
1
|
module_depth
|
int
|
The depth of the module. Default: |
-1
|
top_modules
|
int
|
The number of top modules to show. Default: |
1
|
detailed
|
bool
|
Whether to show detailed profiling. Default: |
True
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Deepspeed flops profiler config. |
Source code in src/ezpz/utils/__init__.py
get_fp16_config_json(enabled=True)
ยถ
Get the deepspeed fp16 config json.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enabled
|
bool
|
Whether to use fp16. Default: |
True
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Deepspeed fp16 config. |
Source code in src/ezpz/utils/__init__.py
get_max_memory_allocated(device)
ยถ
Get the maximum memory allocated on the specified device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device
|
device
|
The device to check memory allocation for. |
required |
Source code in src/ezpz/utils/__init__.py
get_timestamp(fstr=None)
ยถ
Get formatted timestamp.
model_summary(model, verbose=False, depth=1, input_size=None)
ยถ
Print a summary of the model using torchinfo.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
The model to summarize. |
required | |
verbose
|
bool
|
Whether to print the summary. Default: |
False
|
depth
|
int
|
The depth of the summary. Default: |
1
|
input_size
|
Optional[Sequence[int]]
|
The input size for the model. Default: |
None
|
Returns:
Type | Description |
---|---|
ModelStatistics | None
|
ModelStatistics | None: The model summary if torchinfo is available, otherwise None. |
Source code in src/ezpz/utils/__init__.py
summarize_dict(d, precision=6)
ยถ
Summarize a dictionary into a string with formatted key-value pairs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d
|
dict
|
The dictionary to summarize. |
required |
precision
|
int
|
The precision for floating point values. Default: |
6
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A string representation of the dictionary with formatted key-value pairs. |
Source code in src/ezpz/utils/__init__.py
write_deepspeed_zero12_auto_config(zero_stage=1, output_dir=None)
ยถ
Write a deepspeed zero1 auto config to the output directory.
Source code in src/ezpz/utils/__init__.py
write_deepspeed_zero3_auto_config(zero_stage=3, output_dir=None)
ยถ
Write a deepspeed zero1 auto config to the output directory.
Source code in src/ezpz/utils/__init__.py
write_generic_deepspeed_config(gradient_accumulation_steps=1, gradient_clipping='auto', steps_per_print=10, train_batch_size='auto', train_micro_batch_size_per_gpu='auto', wall_clock_breakdown=False, wandb=None, bf16=None, fp16=None, flops_profiler=None, optimizer=None, scheduler=None, zero_optimization=None)
ยถ
Write a generic deepspeed config to the output directory.