Skip to content

feat: add post_training RuntimeConfig #2036

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
11 changes: 11 additions & 0 deletions docs/_static/llama-stack-spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -10170,6 +10170,11 @@
],
"title": "OptimizerType"
},
"RuntimeConfig": {
"type": "object",
"title": "RuntimeConfig",
"description": "Provider-specific runtime configuration. Providers should document and parse their own expected fields. This model allows arbitrary extra fields for maximum flexibility."
},
"TrainingConfig": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -10274,6 +10279,9 @@
}
]
}
},
"runtime_config": {
"$ref": "#/components/schemas/RuntimeConfig"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -11375,6 +11383,9 @@
},
"algorithm_config": {
"$ref": "#/components/schemas/AlgorithmConfig"
},
"runtime_config": {
"$ref": "#/components/schemas/RuntimeConfig"
}
},
"additionalProperties": false,
Expand Down
11 changes: 11 additions & 0 deletions docs/_static/llama-stack-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7000,6 +7000,13 @@ components:
- adamw
- sgd
title: OptimizerType
RuntimeConfig:
type: object
title: RuntimeConfig
description: >-
Provider-specific runtime configuration. Providers should document and parse
their own expected fields. This model allows arbitrary extra fields for maximum
flexibility.
TrainingConfig:
type: object
properties:
Expand Down Expand Up @@ -7060,6 +7067,8 @@ components:
- type: string
- type: array
- type: object
runtime_config:
$ref: '#/components/schemas/RuntimeConfig'
additionalProperties: false
required:
- job_uuid
Expand Down Expand Up @@ -7755,6 +7764,8 @@ components:
type: string
algorithm_config:
$ref: '#/components/schemas/AlgorithmConfig'
runtime_config:
$ref: '#/components/schemas/RuntimeConfig'
additionalProperties: false
required:
- job_uuid
Expand Down
13 changes: 13 additions & 0 deletions llama_stack/apis/post_training/post_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ class PostTrainingJobArtifactsResponse(BaseModel):
# TODO(ashwin): metrics, evals


@json_schema_type
class RuntimeConfig(BaseModel):
"""
Provider-specific runtime configuration. Providers should document and parse their own expected fields.
This model allows arbitrary extra fields for maximum flexibility.
"""

class Config:
extra = "allow"


class PostTraining(Protocol):
@webmethod(route="/post-training/supervised-fine-tune", method="POST")
async def supervised_fine_tune(
Expand All @@ -183,6 +194,7 @@ async def supervised_fine_tune(
),
checkpoint_dir: Optional[str] = None,
algorithm_config: Optional[AlgorithmConfig] = None,
runtime_config: Optional[RuntimeConfig] = None,
) -> PostTrainingJob: ...

@webmethod(route="/post-training/preference-optimize", method="POST")
Expand All @@ -194,6 +206,7 @@ async def preference_optimize(
training_config: TrainingConfig,
hyperparam_search_config: Dict[str, Any],
logger_config: Dict[str, Any],
runtime_config: Optional[RuntimeConfig] = None,
) -> PostTrainingJob: ...

@webmethod(route="/post-training/jobs", method="GET")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
PostTrainingJob,
PostTrainingJobArtifactsResponse,
PostTrainingJobStatusResponse,
RuntimeConfig,
TrainingConfig,
)
from llama_stack.providers.inline.post_training.torchtune.config import (
Expand Down Expand Up @@ -80,6 +81,7 @@ async def supervised_fine_tune(
model: str,
checkpoint_dir: Optional[str],
algorithm_config: Optional[AlgorithmConfig],
runtime_config: Optional[RuntimeConfig] = None,
) -> PostTrainingJob:
if isinstance(algorithm_config, LoraFinetuningConfig):

Expand Down