From d187f1f8e205bef2a12d2d5392e6368abe5cdc86 Mon Sep 17 00:00:00 2001 From: Dan Saunders Date: Mon, 17 Mar 2025 00:28:45 +0000 Subject: [PATCH] using field validator instead of model validator --- src/axolotl/utils/schemas/config.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/axolotl/utils/schemas/config.py b/src/axolotl/utils/schemas/config.py index 611fc4453..7f0c3c58c 100644 --- a/src/axolotl/utils/schemas/config.py +++ b/src/axolotl/utils/schemas/config.py @@ -1104,16 +1104,19 @@ class AxolotlInputConfig( return data - @model_validator(mode="before") + @field_validator("sequence_parallel_degree", mode="before") @classmethod - def check_sequence_parallel_config(cls, data): - if data.get("sequence_parallel_degree", 1) > 1: - if not data.get("flash_attention"): + def check_sequence_parallel_config(cls, value, info): + if not value: + value = 1 + + if value > 1: + if not info.data.get("flash_attention"): raise ValueError( "flash_attention: true must be set with sequence_parallel_degree > 1" ) - return data + return value class AxolotlConfigWCapabilities(AxolotlInputConfig):