Skip to content

Commit

Permalink
Remove mutable default parameter in init_inference() (microsoft#2540)
Browse files Browse the repository at this point in the history
A mutable default value is dangerous because editing it will change the
value for all future calls to the function. The value is itself edited
later in the function, so this problem will likely be encountered sooner
or later.

Co-authored-by: Michael Wyatt <[email protected]>
  • Loading branch information
aphedges and mrwyattii authored Nov 23, 2022
1 parent c5ee27f commit 4abf637
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion deepspeed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def default_inference_config():
return DeepSpeedInferenceConfig().dict()


def init_inference(model, config={}, **kwargs):
def init_inference(model, config=None, **kwargs):
"""Initialize the DeepSpeed InferenceEngine.
Description: all four cases are valid and supported in DS init_inference() API.
Expand Down Expand Up @@ -285,6 +285,8 @@ def init_inference(model, config={}, **kwargs):
ranks=[0])

# Load config_dict from config first
if config is None:
config = {}
if isinstance(config, str):
with open(config, "r") as f:
config_dict = json.load(f)
Expand Down

0 comments on commit 4abf637

Please sign in to comment.