Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: validate sample packing requires flash_attention #1465

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/axolotl/utils/config/models/input/v0_4_1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module for pydantic models for configuration
"""

# pylint: disable=too-many-lines

import logging
Expand Down Expand Up @@ -655,6 +656,20 @@ def check_sample_packing_w_xformers(cls, data):

return data

@model_validator(mode="before")
@classmethod
def check_sample_packing_wo_flash(cls, data):
if (
data.get("sample_packing")
and not data.get("flash_attention")
and not data.get("sdp_attention")
):
raise ValueError(
"sample_packing requires flash_attention or sdp_attention to be set to true"
)

return data

@model_validator(mode="before")
@classmethod
def check_sample_packing_w_rl(cls, data):
Expand Down
5 changes: 5 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ def test_packing(self, minimal_cfg):
{
"sample_packing": True,
"pad_to_sequence_len": None,
"flash_attention": True,
}
)
| minimal_cfg
Expand Down Expand Up @@ -901,6 +902,7 @@ def test_eval_table_size_conflict_eval_packing(self, minimal_cfg):
{
"sample_packing": True,
"eval_table_size": 100,
"flash_attention": True,
}
)
| minimal_cfg
Expand All @@ -916,6 +918,7 @@ def test_eval_table_size_conflict_eval_packing(self, minimal_cfg):
{
"sample_packing": True,
"eval_sample_packing": False,
"flash_attention": True,
}
)
| minimal_cfg
Expand All @@ -928,6 +931,7 @@ def test_eval_table_size_conflict_eval_packing(self, minimal_cfg):
{
"sample_packing": False,
"eval_table_size": 100,
"flash_attention": True,
}
)
| minimal_cfg
Expand All @@ -941,6 +945,7 @@ def test_eval_table_size_conflict_eval_packing(self, minimal_cfg):
"sample_packing": True,
"eval_table_size": 100,
"eval_sample_packing": False,
"flash_attention": True,
}
)
| minimal_cfg
Expand Down
Loading