Skip to content

Commit f0fad78

Browse files
committed
Use default valuat to support old API
1 parent 854abf2 commit f0fad78

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/together/types/finetune.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from enum import Enum
4-
from typing import List, Literal
4+
from typing import List, Literal, Any
55

66
from pydantic import StrictBool, Field, field_validator
77

@@ -329,9 +329,16 @@ class FinetuneDownloadResult(BaseModel):
329329

330330
class FinetuneFullTrainingLimits(BaseModel):
331331
max_batch_size: int
332-
max_batch_size_dpo: int
332+
max_batch_size_dpo: int = -1
333333
min_batch_size: int
334334

335+
def __init__(self, **data: Any) -> None:
336+
super().__init__(**data)
337+
if self.max_batch_size_dpo == -1:
338+
half_max = self.max_batch_size // 2
339+
rounded_half_max = (half_max // 8) * 8
340+
self.max_batch_size_dpo = max(self.min_batch_size, rounded_half_max)
341+
335342

336343
class FinetuneLoraTrainingLimits(FinetuneFullTrainingLimits):
337344
max_rank: int

0 commit comments

Comments
 (0)