From b86082d8774cab09dd43220c075f62865fa89cd5 Mon Sep 17 00:00:00 2001 From: Lev Kurilenko Date: Tue, 19 Nov 2024 21:31:01 +0000 Subject: [PATCH 1/3] Perform transformers version check for BLOOM before container initialization --- deepspeed/module_inject/containers/bloom.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deepspeed/module_inject/containers/bloom.py b/deepspeed/module_inject/containers/bloom.py index a78ac8120346..b9acd6c39b6a 100644 --- a/deepspeed/module_inject/containers/bloom.py +++ b/deepspeed/module_inject/containers/bloom.py @@ -21,6 +21,16 @@ class DS_BloomContainer(MetaTensorContainer, HybridEngineContainer, BaseTransfor def __init__(self, **kwargs): super().__init__(**kwargs) + # Check transformers version, error if > 4.43.4 (breaks at 4.44.0) + from importlib.metadata import version + v_transformers = version('transformers') + vers = v_transformers.split('.') + major = int(vers[0]) + minor = int(vers[1]) + if major > 4 or (major == 4 and minor > 43): + import sys + sys.exit(f"Transformers version {v_transformers} exceeds version 4.43.4! After transformers version 4.43.4, BLOOM inference with DeepSpeed is no longer supported.") + # All model specific things should be defined here instead of the base class. self.bigscience_bloom = True self.triangular_masking = False From 051751a8128c432c82965af5c3eac4a04b8e3f8d Mon Sep 17 00:00:00 2001 From: Lev Kurilenko Date: Tue, 19 Nov 2024 21:35:07 +0000 Subject: [PATCH 2/3] Put super after version check --- deepspeed/module_inject/containers/bloom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deepspeed/module_inject/containers/bloom.py b/deepspeed/module_inject/containers/bloom.py index b9acd6c39b6a..aec43716f7c1 100644 --- a/deepspeed/module_inject/containers/bloom.py +++ b/deepspeed/module_inject/containers/bloom.py @@ -19,8 +19,6 @@ class DS_BloomContainer(MetaTensorContainer, HybridEngineContainer, BaseTransformerContainer): def __init__(self, **kwargs): - super().__init__(**kwargs) - # Check transformers version, error if > 4.43.4 (breaks at 4.44.0) from importlib.metadata import version v_transformers = version('transformers') @@ -31,6 +29,8 @@ def __init__(self, **kwargs): import sys sys.exit(f"Transformers version {v_transformers} exceeds version 4.43.4! After transformers version 4.43.4, BLOOM inference with DeepSpeed is no longer supported.") + super().__init__(**kwargs) + # All model specific things should be defined here instead of the base class. self.bigscience_bloom = True self.triangular_masking = False From fbb01facd07aff5404ee23515e30df094f556d20 Mon Sep 17 00:00:00 2001 From: Lev Kurilenko Date: Tue, 19 Nov 2024 21:41:09 +0000 Subject: [PATCH 3/3] Formatting fix --- deepspeed/module_inject/containers/bloom.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deepspeed/module_inject/containers/bloom.py b/deepspeed/module_inject/containers/bloom.py index aec43716f7c1..7a9b9ca2065b 100644 --- a/deepspeed/module_inject/containers/bloom.py +++ b/deepspeed/module_inject/containers/bloom.py @@ -27,7 +27,9 @@ def __init__(self, **kwargs): minor = int(vers[1]) if major > 4 or (major == 4 and minor > 43): import sys - sys.exit(f"Transformers version {v_transformers} exceeds version 4.43.4! After transformers version 4.43.4, BLOOM inference with DeepSpeed is no longer supported.") + sys.exit( + f"Transformers version {v_transformers} exceeds version 4.43.4! After transformers version 4.43.4, BLOOM inference with DeepSpeed is no longer supported." + ) super().__init__(**kwargs)