Skip to content

Commit

Permalink
fix None-type not iterable error when deepspeed is left blank w/ use_… (
Browse files Browse the repository at this point in the history
#2087)

* fix None-type not iterable error when deepspeed is left blank w/ use_reentrant: false and qlora

* added unit test[skip e2e]

* corrected test case[skip e2e]

* assert warning message [skip e2e]

* assert warning message [skip e2e]

* corrected test cases [skip e2e]

* lint
  • Loading branch information
bursteratom authored Nov 21, 2024
1 parent bf416bd commit 151abb7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/axolotl/utils/config/models/input/v0_4_1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@ def warn_qlora_zero3_w_use_reentrant(cls, data):
and data.get("gradient_checkpointing_kwargs", {})
and data.get("gradient_checkpointing_kwargs", {}).get("use_reentrant")
is False
and data.get("deepspeed", "") is not None
and "zero3" in data.get("deepspeed", "")
):
# may result in:
Expand Down
47 changes: 47 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,53 @@ def test_defaults(self, minimal_cfg):
assert cfg.train_on_inputs is False
assert cfg.weight_decay is None

def test_zero3_qlora_use_reentrant_false(self, minimal_cfg):
test_cfg = DictDefault(
{
"deepspeed": "deepspeed_configs/zero3_bf16.json",
"gradient_checkpointing": True,
"gradient_checkpointing_kwargs": {"use_reentrant": False},
"load_in_4bit": True,
"adapter": "qlora",
}
| minimal_cfg
)

with self._caplog.at_level(logging.WARNING):
validate_config(test_cfg)
assert (
"qlora + zero3 with use_reentrant: false may result in a CheckpointError about recomputed values"
in self._caplog.records[0].message
)

def test_deepspeed_empty(self, minimal_cfg):
test_cfg = DictDefault(
{
"deepspeed": "",
"gradient_checkpointing": True,
"gradient_checkpointing_kwargs": {"use_reentrant": False},
"load_in_4bit": True,
"adapter": "qlora",
}
| minimal_cfg
)

_ = validate_config(test_cfg)

def test_deepspeed_not_set(self, minimal_cfg):
test_cfg = DictDefault(
{
"deepspeed": None,
"gradient_checkpointing": True,
"gradient_checkpointing_kwargs": {"use_reentrant": False},
"load_in_4bit": True,
"adapter": "qlora",
}
| minimal_cfg
)

_ = validate_config(test_cfg)

def test_datasets_min_length(self):
cfg = DictDefault(
{
Expand Down

0 comments on commit 151abb7

Please sign in to comment.