|
67 | 67 | logging, |
68 | 68 | numpy_to_pil, |
69 | 69 | ) |
| 70 | +from ..utils.distributed_utils import is_torch_dist_rank_zero |
70 | 71 | from ..utils.hub_utils import _check_legacy_sharding_variant_format, load_or_create_model_card, populate_model_card |
71 | 72 | from ..utils.torch_utils import empty_device_cache, get_device, is_compiled_module |
72 | 73 |
|
@@ -982,7 +983,11 @@ def load_module(name, value): |
982 | 983 | # 7. Load each module in the pipeline |
983 | 984 | current_device_map = None |
984 | 985 | _maybe_warn_for_wrong_component_in_quant_config(init_dict, quantization_config) |
985 | | - for name, (library_name, class_name) in logging.tqdm(init_dict.items(), desc="Loading pipeline components..."): |
| 986 | + logging_tqdm_kwargs = {"desc": "Loading pipeline components..."} |
| 987 | + if not is_torch_dist_rank_zero(): |
| 988 | + logging_tqdm_kwargs["disable"] = True |
| 989 | + |
| 990 | + for name, (library_name, class_name) in logging.tqdm(init_dict.items(), **logging_tqdm_kwargs): |
986 | 991 | # 7.1 device_map shenanigans |
987 | 992 | if final_device_map is not None: |
988 | 993 | if isinstance(final_device_map, dict) and len(final_device_map) > 0: |
@@ -1908,10 +1913,14 @@ def progress_bar(self, iterable=None, total=None): |
1908 | 1913 | f"`self._progress_bar_config` should be of type `dict`, but is {type(self._progress_bar_config)}." |
1909 | 1914 | ) |
1910 | 1915 |
|
| 1916 | + progress_bar_config = dict(self._progress_bar_config) |
| 1917 | + if "disable" not in progress_bar_config: |
| 1918 | + progress_bar_config["disable"] = not is_torch_dist_rank_zero() |
| 1919 | + |
1911 | 1920 | if iterable is not None: |
1912 | | - return tqdm(iterable, **self._progress_bar_config) |
| 1921 | + return tqdm(iterable, **progress_bar_config) |
1913 | 1922 | elif total is not None: |
1914 | | - return tqdm(total=total, **self._progress_bar_config) |
| 1923 | + return tqdm(total=total, **progress_bar_config) |
1915 | 1924 | else: |
1916 | 1925 | raise ValueError("Either `total` or `iterable` has to be defined.") |
1917 | 1926 |
|
|
0 commit comments