Skip to content

Commit 691e2a3

Browse files
mryabtimofeev1995
authored andcommitted
WIP extend continued FT
1 parent a0fadd3 commit 691e2a3

3 files changed

Lines changed: 41 additions & 1 deletion

File tree

src/together/cli/api/finetune.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,20 @@ def fine_tuning(ctx: click.Context) -> None:
200200
"The format: {$JOB_ID/$OUTPUT_MODEL_NAME}:{$STEP}. "
201201
"The step value is optional, without it the final checkpoint will be used.",
202202
)
203+
@click.option(
204+
"--from-hf-model",
205+
type=str,
206+
default=None,
207+
help="Model name from the Hugging Face Hub that will be used to initialize the trained model. "
208+
"The model config is not validated; any model supported by Transformers should work, but the batch size "
209+
"limits are not checked.",
210+
)
211+
@click.option(
212+
"--hf-api-token",
213+
type=str,
214+
default=None,
215+
help="HF API token to use to download a checkpoint from a private repo",
216+
)
203217
def create(
204218
ctx: click.Context,
205219
training_file: str,
@@ -234,6 +248,8 @@ def create(
234248
rpo_alpha: float | None,
235249
simpo_gamma: float | None,
236250
from_checkpoint: str,
251+
from_hf_model: str,
252+
hf_api_token: str,
237253
) -> None:
238254
"""Start fine-tuning"""
239255
client: Together = ctx.obj
@@ -270,6 +286,8 @@ def create(
270286
rpo_alpha=rpo_alpha,
271287
simpo_gamma=simpo_gamma,
272288
from_checkpoint=from_checkpoint,
289+
from_hf_model=from_hf_model,
290+
hf_api_token=hf_api_token,
273291
)
274292

275293
if model is None and from_checkpoint is None:
@@ -280,7 +298,7 @@ def create(
280298
model_name = from_checkpoint.split(":")[0]
281299

282300
model_limits: FinetuneTrainingLimits = client.fine_tuning.get_model_limits(
283-
model=model_name
301+
model=model_name,
284302
)
285303

286304
if lora:

src/together/resources/finetune.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ def create_finetune_request(
7676
rpo_alpha: float | None = None,
7777
simpo_gamma: float | None = None,
7878
from_checkpoint: str | None = None,
79+
from_hf_model: str | None = None,
80+
hf_api_token: str | None = None,
7981
) -> FinetuneRequest:
8082
if model is not None and from_checkpoint is not None:
8183
raise ValueError(
@@ -262,6 +264,8 @@ def create_finetune_request(
262264
wandb_name=wandb_name,
263265
training_method=training_method_cls,
264266
from_checkpoint=from_checkpoint,
267+
from_hf_model=from_hf_model,
268+
hf_api_token=hf_api_token,
265269
)
266270

267271
return finetune_request
@@ -341,6 +345,8 @@ def create(
341345
rpo_alpha: float | None = None,
342346
simpo_gamma: float | None = None,
343347
from_checkpoint: str | None = None,
348+
from_hf_model: str | None = None,
349+
hf_api_token: str | None = None,
344350
) -> FinetuneResponse:
345351
"""
346352
Method to initiate a fine-tuning job
@@ -397,6 +403,10 @@ def create(
397403
from_checkpoint (str, optional): The checkpoint identifier to continue training from a previous fine-tuning job.
398404
The format: {$JOB_ID/$OUTPUT_MODEL_NAME}:{$STEP}.
399405
The step value is optional, without it the final checkpoint will be used.
406+
from_hf_model (str, optional): Model name from the Hugging Face Hub that will be used to initialize the trained model.
407+
The model config is not validated; any model supported by Transformers should work, but the batch size
408+
limits are not checked. Defaults to None.
409+
hf_api_token (str, optional): API key for the Hugging Face Hub. Defaults to None.
400410
401411
Returns:
402412
FinetuneResponse: Object containing information about fine-tuning job.
@@ -450,6 +460,8 @@ def create(
450460
rpo_alpha=rpo_alpha,
451461
simpo_gamma=simpo_gamma,
452462
from_checkpoint=from_checkpoint,
463+
from_hf_model=from_hf_model,
464+
hf_api_token=hf_api_token,
453465
)
454466

455467
if verbose:
@@ -762,6 +774,8 @@ async def create(
762774
rpo_alpha: float | None = None,
763775
simpo_gamma: float | None = None,
764776
from_checkpoint: str | None = None,
777+
from_hf_model: str | None = None,
778+
hf_api_token: str | None = None,
765779
) -> FinetuneResponse:
766780
"""
767781
Async method to initiate a fine-tuning job
@@ -818,6 +832,10 @@ async def create(
818832
from_checkpoint (str, optional): The checkpoint identifier to continue training from a previous fine-tuning job.
819833
The format: {$JOB_ID/$OUTPUT_MODEL_NAME}:{$STEP}.
820834
The step value is optional, without it the final checkpoint will be used.
835+
from_hf_model (str, optional): Model name from the Hugging Face Hub that will be used to initialize the trained model.
836+
The model config is not validated; any model supported by Transformers should work, but the batch size
837+
limits are not checked. Defaults to None.
838+
hf_api_token (str, optional): API key for the Huggging Face Hub. Defaults to None.
821839
822840
Returns:
823841
FinetuneResponse: Object containing information about fine-tuning job.
@@ -871,6 +889,8 @@ async def create(
871889
rpo_alpha=rpo_alpha,
872890
simpo_gamma=simpo_gamma,
873891
from_checkpoint=from_checkpoint,
892+
from_hf_model=from_hf_model,
893+
hf_api_token=hf_api_token,
874894
)
875895

876896
if verbose:

src/together/types/finetune.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ class FinetuneRequest(BaseModel):
212212
)
213213
# from step
214214
from_checkpoint: str | None = None
215+
from_hf_model: str | None = None
216+
hf_api_token: str | None = None
215217

216218

217219
class FinetuneResponse(BaseModel):

0 commit comments

Comments
 (0)