This commit is contained in:
Sai Soundararaj 2025-07-01 16:46:20 -07:00
parent b1b93088c5
commit a9d8fdef90
4 changed files with 319 additions and 63 deletions

View file

@ -229,8 +229,8 @@ Before finalizing documentation, verify:
[x] 8. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/vector_dbs/vector_dbs.py` - Vector database management [x] 8. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/vector_dbs/vector_dbs.py` - Vector database management
[x] 9. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/files/files.py` - File management [x] 9. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/files/files.py` - File management
[x] 10. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/datasets/datasets.py` - Dataset management [x] 10. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/datasets/datasets.py` - Dataset management
11. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/datasetio/datasetio.py` - Dataset I/O operations [x] 11. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/datasetio/datasetio.py` - Dataset I/O operations
12. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/post_training/post_training.py` - Training and fine-tuning [x] 12. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/post_training/post_training.py` - Training and fine-tuning
13. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/eval/eval.py` - Evaluation framework 13. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/eval/eval.py` - Evaluation framework
14. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/scoring/scoring.py` - Scoring system 14. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/scoring/scoring.py` - Scoring system
15. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/scoring_functions/scoring_functions.py` - Scoring function definitions 15. `/Users/saip/Documents/GitHub/llama-stack/llama_stack/apis/scoring_functions/scoring_functions.py` - Scoring function definitions

View file

@ -11252,13 +11252,15 @@
"type": "object", "type": "object",
"properties": { "properties": {
"job_uuid": { "job_uuid": {
"type": "string" "type": "string",
"description": "Unique identifier for the training job"
}, },
"checkpoints": { "checkpoints": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/Checkpoint" "$ref": "#/components/schemas/Checkpoint"
} },
"description": "List of model checkpoints created during training"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -11273,7 +11275,8 @@
"type": "object", "type": "object",
"properties": { "properties": {
"job_uuid": { "job_uuid": {
"type": "string" "type": "string",
"description": "Unique identifier for the training job"
}, },
"status": { "status": {
"type": "string", "type": "string",
@ -11284,19 +11287,22 @@
"scheduled", "scheduled",
"cancelled" "cancelled"
], ],
"title": "JobStatus" "description": "Current status of the training job"
}, },
"scheduled_at": { "scheduled_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time",
"description": "(Optional) Timestamp when the job was scheduled"
}, },
"started_at": { "started_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time",
"description": "(Optional) Timestamp when the job execution began"
}, },
"completed_at": { "completed_at": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time",
"description": "(Optional) Timestamp when the job finished, if completed"
}, },
"resources_allocated": { "resources_allocated": {
"type": "object", "type": "object",
@ -11321,13 +11327,15 @@
"type": "object" "type": "object"
} }
] ]
} },
"description": "(Optional) Information about computational resources allocated to the job"
}, },
"checkpoints": { "checkpoints": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/Checkpoint" "$ref": "#/components/schemas/Checkpoint"
} },
"description": "List of model checkpoints created during training"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -14644,16 +14652,20 @@
"type": "object", "type": "object",
"properties": { "properties": {
"reward_scale": { "reward_scale": {
"type": "number" "type": "number",
"description": "Scaling factor for the reward signal"
}, },
"reward_clip": { "reward_clip": {
"type": "number" "type": "number",
"description": "Maximum absolute value for reward clipping"
}, },
"epsilon": { "epsilon": {
"type": "number" "type": "number",
"description": "Small value added for numerical stability"
}, },
"gamma": { "gamma": {
"type": "number" "type": "number",
"description": "Discount factor for future rewards"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -14663,33 +14675,41 @@
"epsilon", "epsilon",
"gamma" "gamma"
], ],
"title": "DPOAlignmentConfig" "title": "DPOAlignmentConfig",
"description": "Configuration for Direct Preference Optimization (DPO) alignment."
}, },
"DataConfig": { "DataConfig": {
"type": "object", "type": "object",
"properties": { "properties": {
"dataset_id": { "dataset_id": {
"type": "string" "type": "string",
"description": "Unique identifier for the training dataset"
}, },
"batch_size": { "batch_size": {
"type": "integer" "type": "integer",
"description": "Number of samples per training batch"
}, },
"shuffle": { "shuffle": {
"type": "boolean" "type": "boolean",
"description": "Whether to shuffle the dataset during training"
}, },
"data_format": { "data_format": {
"$ref": "#/components/schemas/DatasetFormat" "$ref": "#/components/schemas/DatasetFormat",
"description": "Format of the dataset (instruct or dialog)"
}, },
"validation_dataset_id": { "validation_dataset_id": {
"type": "string" "type": "string",
"description": "(Optional) Unique identifier for the validation dataset"
}, },
"packed": { "packed": {
"type": "boolean", "type": "boolean",
"default": false "default": false,
"description": "(Optional) Whether to pack multiple samples into a single sequence for efficiency"
}, },
"train_on_input": { "train_on_input": {
"type": "boolean", "type": "boolean",
"default": false "default": false,
"description": "(Optional) Whether to compute loss on input tokens as well as output tokens"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -14699,7 +14719,8 @@
"shuffle", "shuffle",
"data_format" "data_format"
], ],
"title": "DataConfig" "title": "DataConfig",
"description": "Configuration for training data and data loading."
}, },
"DatasetFormat": { "DatasetFormat": {
"type": "string", "type": "string",
@ -14707,45 +14728,55 @@
"instruct", "instruct",
"dialog" "dialog"
], ],
"title": "DatasetFormat" "title": "DatasetFormat",
"description": "Format of the training dataset."
}, },
"EfficiencyConfig": { "EfficiencyConfig": {
"type": "object", "type": "object",
"properties": { "properties": {
"enable_activation_checkpointing": { "enable_activation_checkpointing": {
"type": "boolean", "type": "boolean",
"default": false "default": false,
"description": "(Optional) Whether to use activation checkpointing to reduce memory usage"
}, },
"enable_activation_offloading": { "enable_activation_offloading": {
"type": "boolean", "type": "boolean",
"default": false "default": false,
"description": "(Optional) Whether to offload activations to CPU to save GPU memory"
}, },
"memory_efficient_fsdp_wrap": { "memory_efficient_fsdp_wrap": {
"type": "boolean", "type": "boolean",
"default": false "default": false,
"description": "(Optional) Whether to use memory-efficient FSDP wrapping"
}, },
"fsdp_cpu_offload": { "fsdp_cpu_offload": {
"type": "boolean", "type": "boolean",
"default": false "default": false,
"description": "(Optional) Whether to offload FSDP parameters to CPU"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"title": "EfficiencyConfig" "title": "EfficiencyConfig",
"description": "Configuration for memory and compute efficiency optimizations."
}, },
"OptimizerConfig": { "OptimizerConfig": {
"type": "object", "type": "object",
"properties": { "properties": {
"optimizer_type": { "optimizer_type": {
"$ref": "#/components/schemas/OptimizerType" "$ref": "#/components/schemas/OptimizerType",
"description": "Type of optimizer to use (adam, adamw, or sgd)"
}, },
"lr": { "lr": {
"type": "number" "type": "number",
"description": "Learning rate for the optimizer"
}, },
"weight_decay": { "weight_decay": {
"type": "number" "type": "number",
"description": "Weight decay coefficient for regularization"
}, },
"num_warmup_steps": { "num_warmup_steps": {
"type": "integer" "type": "integer",
"description": "Number of steps for learning rate warmup"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -14755,7 +14786,8 @@
"weight_decay", "weight_decay",
"num_warmup_steps" "num_warmup_steps"
], ],
"title": "OptimizerConfig" "title": "OptimizerConfig",
"description": "Configuration parameters for the optimization algorithm."
}, },
"OptimizerType": { "OptimizerType": {
"type": "string", "type": "string",
@ -14764,38 +14796,47 @@
"adamw", "adamw",
"sgd" "sgd"
], ],
"title": "OptimizerType" "title": "OptimizerType",
"description": "Available optimizer algorithms for training."
}, },
"TrainingConfig": { "TrainingConfig": {
"type": "object", "type": "object",
"properties": { "properties": {
"n_epochs": { "n_epochs": {
"type": "integer" "type": "integer",
"description": "Number of training epochs to run"
}, },
"max_steps_per_epoch": { "max_steps_per_epoch": {
"type": "integer", "type": "integer",
"default": 1 "default": 1,
"description": "Maximum number of steps to run per epoch"
}, },
"gradient_accumulation_steps": { "gradient_accumulation_steps": {
"type": "integer", "type": "integer",
"default": 1 "default": 1,
"description": "Number of steps to accumulate gradients before updating"
}, },
"max_validation_steps": { "max_validation_steps": {
"type": "integer", "type": "integer",
"default": 1 "default": 1,
"description": "(Optional) Maximum number of validation steps per epoch"
}, },
"data_config": { "data_config": {
"$ref": "#/components/schemas/DataConfig" "$ref": "#/components/schemas/DataConfig",
"description": "(Optional) Configuration for data loading and formatting"
}, },
"optimizer_config": { "optimizer_config": {
"$ref": "#/components/schemas/OptimizerConfig" "$ref": "#/components/schemas/OptimizerConfig",
"description": "(Optional) Configuration for the optimization algorithm"
}, },
"efficiency_config": { "efficiency_config": {
"$ref": "#/components/schemas/EfficiencyConfig" "$ref": "#/components/schemas/EfficiencyConfig",
"description": "(Optional) Configuration for memory and compute optimizations"
}, },
"dtype": { "dtype": {
"type": "string", "type": "string",
"default": "bf16" "default": "bf16",
"description": "(Optional) Data type for model parameters (bf16, fp16, fp32)"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -14804,7 +14845,8 @@
"max_steps_per_epoch", "max_steps_per_epoch",
"gradient_accumulation_steps" "gradient_accumulation_steps"
], ],
"title": "TrainingConfig" "title": "TrainingConfig",
"description": "Comprehensive configuration for the training process."
}, },
"PreferenceOptimizeRequest": { "PreferenceOptimizeRequest": {
"type": "object", "type": "object",
@ -16101,33 +16143,41 @@
"type": { "type": {
"type": "string", "type": "string",
"const": "LoRA", "const": "LoRA",
"default": "LoRA" "default": "LoRA",
"description": "Algorithm type identifier, always \"LoRA\""
}, },
"lora_attn_modules": { "lora_attn_modules": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string" "type": "string"
} },
"description": "List of attention module names to apply LoRA to"
}, },
"apply_lora_to_mlp": { "apply_lora_to_mlp": {
"type": "boolean" "type": "boolean",
"description": "Whether to apply LoRA to MLP layers"
}, },
"apply_lora_to_output": { "apply_lora_to_output": {
"type": "boolean" "type": "boolean",
"description": "Whether to apply LoRA to output projection layers"
}, },
"rank": { "rank": {
"type": "integer" "type": "integer",
"description": "Rank of the LoRA adaptation (lower rank = fewer parameters)"
}, },
"alpha": { "alpha": {
"type": "integer" "type": "integer",
"description": "LoRA scaling parameter that controls adaptation strength"
}, },
"use_dora": { "use_dora": {
"type": "boolean", "type": "boolean",
"default": false "default": false,
"description": "(Optional) Whether to use DoRA (Weight-Decomposed Low-Rank Adaptation)"
}, },
"quantize_base": { "quantize_base": {
"type": "boolean", "type": "boolean",
"default": false "default": false,
"description": "(Optional) Whether to quantize the base model weights"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -16139,7 +16189,8 @@
"rank", "rank",
"alpha" "alpha"
], ],
"title": "LoraFinetuningConfig" "title": "LoraFinetuningConfig",
"description": "Configuration for Low-Rank Adaptation (LoRA) fine-tuning."
}, },
"QATFinetuningConfig": { "QATFinetuningConfig": {
"type": "object", "type": "object",
@ -16147,13 +16198,16 @@
"type": { "type": {
"type": "string", "type": "string",
"const": "QAT", "const": "QAT",
"default": "QAT" "default": "QAT",
"description": "Algorithm type identifier, always \"QAT\""
}, },
"quantizer_name": { "quantizer_name": {
"type": "string" "type": "string",
"description": "Name of the quantization algorithm to use"
}, },
"group_size": { "group_size": {
"type": "integer" "type": "integer",
"description": "Size of groups for grouped quantization"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@ -16162,7 +16216,8 @@
"quantizer_name", "quantizer_name",
"group_size" "group_size"
], ],
"title": "QATFinetuningConfig" "title": "QATFinetuningConfig",
"description": "Configuration for Quantization-Aware Training (QAT) fine-tuning."
}, },
"SupervisedFineTuneRequest": { "SupervisedFineTuneRequest": {
"type": "object", "type": "object",

View file

@ -8064,10 +8064,13 @@ components:
properties: properties:
job_uuid: job_uuid:
type: string type: string
description: Unique identifier for the training job
checkpoints: checkpoints:
type: array type: array
items: items:
$ref: '#/components/schemas/Checkpoint' $ref: '#/components/schemas/Checkpoint'
description: >-
List of model checkpoints created during training
additionalProperties: false additionalProperties: false
required: required:
- job_uuid - job_uuid
@ -8079,6 +8082,7 @@ components:
properties: properties:
job_uuid: job_uuid:
type: string type: string
description: Unique identifier for the training job
status: status:
type: string type: string
enum: enum:
@ -8087,16 +8091,22 @@ components:
- failed - failed
- scheduled - scheduled
- cancelled - cancelled
title: JobStatus description: Current status of the training job
scheduled_at: scheduled_at:
type: string type: string
format: date-time format: date-time
description: >-
(Optional) Timestamp when the job was scheduled
started_at: started_at:
type: string type: string
format: date-time format: date-time
description: >-
(Optional) Timestamp when the job execution began
completed_at: completed_at:
type: string type: string
format: date-time format: date-time
description: >-
(Optional) Timestamp when the job finished, if completed
resources_allocated: resources_allocated:
type: object type: object
additionalProperties: additionalProperties:
@ -8107,10 +8117,15 @@ components:
- type: string - type: string
- type: array - type: array
- type: object - type: object
description: >-
(Optional) Information about computational resources allocated to the
job
checkpoints: checkpoints:
type: array type: array
items: items:
$ref: '#/components/schemas/Checkpoint' $ref: '#/components/schemas/Checkpoint'
description: >-
List of model checkpoints created during training
additionalProperties: false additionalProperties: false
required: required:
- job_uuid - job_uuid
@ -10491,12 +10506,18 @@ components:
properties: properties:
reward_scale: reward_scale:
type: number type: number
description: Scaling factor for the reward signal
reward_clip: reward_clip:
type: number type: number
description: >-
Maximum absolute value for reward clipping
epsilon: epsilon:
type: number type: number
description: >-
Small value added for numerical stability
gamma: gamma:
type: number type: number
description: Discount factor for future rewards
additionalProperties: false additionalProperties: false
required: required:
- reward_scale - reward_scale
@ -10504,25 +10525,41 @@ components:
- epsilon - epsilon
- gamma - gamma
title: DPOAlignmentConfig title: DPOAlignmentConfig
description: >-
Configuration for Direct Preference Optimization (DPO) alignment.
DataConfig: DataConfig:
type: object type: object
properties: properties:
dataset_id: dataset_id:
type: string type: string
description: >-
Unique identifier for the training dataset
batch_size: batch_size:
type: integer type: integer
description: Number of samples per training batch
shuffle: shuffle:
type: boolean type: boolean
description: >-
Whether to shuffle the dataset during training
data_format: data_format:
$ref: '#/components/schemas/DatasetFormat' $ref: '#/components/schemas/DatasetFormat'
description: >-
Format of the dataset (instruct or dialog)
validation_dataset_id: validation_dataset_id:
type: string type: string
description: >-
(Optional) Unique identifier for the validation dataset
packed: packed:
type: boolean type: boolean
default: false default: false
description: >-
(Optional) Whether to pack multiple samples into a single sequence for
efficiency
train_on_input: train_on_input:
type: boolean type: boolean
default: false default: false
description: >-
(Optional) Whether to compute loss on input tokens as well as output tokens
additionalProperties: false additionalProperties: false
required: required:
- dataset_id - dataset_id
@ -10530,40 +10567,59 @@ components:
- shuffle - shuffle
- data_format - data_format
title: DataConfig title: DataConfig
description: >-
Configuration for training data and data loading.
DatasetFormat: DatasetFormat:
type: string type: string
enum: enum:
- instruct - instruct
- dialog - dialog
title: DatasetFormat title: DatasetFormat
description: Format of the training dataset.
EfficiencyConfig: EfficiencyConfig:
type: object type: object
properties: properties:
enable_activation_checkpointing: enable_activation_checkpointing:
type: boolean type: boolean
default: false default: false
description: >-
(Optional) Whether to use activation checkpointing to reduce memory usage
enable_activation_offloading: enable_activation_offloading:
type: boolean type: boolean
default: false default: false
description: >-
(Optional) Whether to offload activations to CPU to save GPU memory
memory_efficient_fsdp_wrap: memory_efficient_fsdp_wrap:
type: boolean type: boolean
default: false default: false
description: >-
(Optional) Whether to use memory-efficient FSDP wrapping
fsdp_cpu_offload: fsdp_cpu_offload:
type: boolean type: boolean
default: false default: false
description: >-
(Optional) Whether to offload FSDP parameters to CPU
additionalProperties: false additionalProperties: false
title: EfficiencyConfig title: EfficiencyConfig
description: >-
Configuration for memory and compute efficiency optimizations.
OptimizerConfig: OptimizerConfig:
type: object type: object
properties: properties:
optimizer_type: optimizer_type:
$ref: '#/components/schemas/OptimizerType' $ref: '#/components/schemas/OptimizerType'
description: >-
Type of optimizer to use (adam, adamw, or sgd)
lr: lr:
type: number type: number
description: Learning rate for the optimizer
weight_decay: weight_decay:
type: number type: number
description: >-
Weight decay coefficient for regularization
num_warmup_steps: num_warmup_steps:
type: integer type: integer
description: Number of steps for learning rate warmup
additionalProperties: false additionalProperties: false
required: required:
- optimizer_type - optimizer_type
@ -10571,6 +10627,8 @@ components:
- weight_decay - weight_decay
- num_warmup_steps - num_warmup_steps
title: OptimizerConfig title: OptimizerConfig
description: >-
Configuration parameters for the optimization algorithm.
OptimizerType: OptimizerType:
type: string type: string
enum: enum:
@ -10578,35 +10636,53 @@ components:
- adamw - adamw
- sgd - sgd
title: OptimizerType title: OptimizerType
description: >-
Available optimizer algorithms for training.
TrainingConfig: TrainingConfig:
type: object type: object
properties: properties:
n_epochs: n_epochs:
type: integer type: integer
description: Number of training epochs to run
max_steps_per_epoch: max_steps_per_epoch:
type: integer type: integer
default: 1 default: 1
description: Maximum number of steps to run per epoch
gradient_accumulation_steps: gradient_accumulation_steps:
type: integer type: integer
default: 1 default: 1
description: >-
Number of steps to accumulate gradients before updating
max_validation_steps: max_validation_steps:
type: integer type: integer
default: 1 default: 1
description: >-
(Optional) Maximum number of validation steps per epoch
data_config: data_config:
$ref: '#/components/schemas/DataConfig' $ref: '#/components/schemas/DataConfig'
description: >-
(Optional) Configuration for data loading and formatting
optimizer_config: optimizer_config:
$ref: '#/components/schemas/OptimizerConfig' $ref: '#/components/schemas/OptimizerConfig'
description: >-
(Optional) Configuration for the optimization algorithm
efficiency_config: efficiency_config:
$ref: '#/components/schemas/EfficiencyConfig' $ref: '#/components/schemas/EfficiencyConfig'
description: >-
(Optional) Configuration for memory and compute optimizations
dtype: dtype:
type: string type: string
default: bf16 default: bf16
description: >-
(Optional) Data type for model parameters (bf16, fp16, fp32)
additionalProperties: false additionalProperties: false
required: required:
- n_epochs - n_epochs
- max_steps_per_epoch - max_steps_per_epoch
- gradient_accumulation_steps - gradient_accumulation_steps
title: TrainingConfig title: TrainingConfig
description: >-
Comprehensive configuration for the training process.
PreferenceOptimizeRequest: PreferenceOptimizeRequest:
type: object type: object
properties: properties:
@ -11535,24 +11611,38 @@ components:
type: string type: string
const: LoRA const: LoRA
default: LoRA default: LoRA
description: Algorithm type identifier, always "LoRA"
lora_attn_modules: lora_attn_modules:
type: array type: array
items: items:
type: string type: string
description: >-
List of attention module names to apply LoRA to
apply_lora_to_mlp: apply_lora_to_mlp:
type: boolean type: boolean
description: Whether to apply LoRA to MLP layers
apply_lora_to_output: apply_lora_to_output:
type: boolean type: boolean
description: >-
Whether to apply LoRA to output projection layers
rank: rank:
type: integer type: integer
description: >-
Rank of the LoRA adaptation (lower rank = fewer parameters)
alpha: alpha:
type: integer type: integer
description: >-
LoRA scaling parameter that controls adaptation strength
use_dora: use_dora:
type: boolean type: boolean
default: false default: false
description: >-
(Optional) Whether to use DoRA (Weight-Decomposed Low-Rank Adaptation)
quantize_base: quantize_base:
type: boolean type: boolean
default: false default: false
description: >-
(Optional) Whether to quantize the base model weights
additionalProperties: false additionalProperties: false
required: required:
- type - type
@ -11562,6 +11652,8 @@ components:
- rank - rank
- alpha - alpha
title: LoraFinetuningConfig title: LoraFinetuningConfig
description: >-
Configuration for Low-Rank Adaptation (LoRA) fine-tuning.
QATFinetuningConfig: QATFinetuningConfig:
type: object type: object
properties: properties:
@ -11569,16 +11661,22 @@ components:
type: string type: string
const: QAT const: QAT
default: QAT default: QAT
description: Algorithm type identifier, always "QAT"
quantizer_name: quantizer_name:
type: string type: string
description: >-
Name of the quantization algorithm to use
group_size: group_size:
type: integer type: integer
description: Size of groups for grouped quantization
additionalProperties: false additionalProperties: false
required: required:
- type - type
- quantizer_name - quantizer_name
- group_size - group_size
title: QATFinetuningConfig title: QATFinetuningConfig
description: >-
Configuration for Quantization-Aware Training (QAT) fine-tuning.
SupervisedFineTuneRequest: SupervisedFineTuneRequest:
type: object type: object
properties: properties:

View file

@ -18,6 +18,12 @@ from llama_stack.schema_utils import json_schema_type, register_schema, webmetho
@json_schema_type @json_schema_type
class OptimizerType(Enum): class OptimizerType(Enum):
"""Available optimizer algorithms for training.
:cvar adam: Adaptive Moment Estimation optimizer
:cvar adamw: AdamW optimizer with weight decay
:cvar sgd: Stochastic Gradient Descent optimizer
"""
adam = "adam" adam = "adam"
adamw = "adamw" adamw = "adamw"
sgd = "sgd" sgd = "sgd"
@ -25,12 +31,27 @@ class OptimizerType(Enum):
@json_schema_type @json_schema_type
class DatasetFormat(Enum): class DatasetFormat(Enum):
"""Format of the training dataset.
:cvar instruct: Instruction-following format with prompt and completion
:cvar dialog: Multi-turn conversation format with messages
"""
instruct = "instruct" instruct = "instruct"
dialog = "dialog" dialog = "dialog"
@json_schema_type @json_schema_type
class DataConfig(BaseModel): class DataConfig(BaseModel):
"""Configuration for training data and data loading.
:param dataset_id: Unique identifier for the training dataset
:param batch_size: Number of samples per training batch
:param shuffle: Whether to shuffle the dataset during training
:param data_format: Format of the dataset (instruct or dialog)
:param validation_dataset_id: (Optional) Unique identifier for the validation dataset
:param packed: (Optional) Whether to pack multiple samples into a single sequence for efficiency
:param train_on_input: (Optional) Whether to compute loss on input tokens as well as output tokens
"""
dataset_id: str dataset_id: str
batch_size: int batch_size: int
shuffle: bool shuffle: bool
@ -42,6 +63,13 @@ class DataConfig(BaseModel):
@json_schema_type @json_schema_type
class OptimizerConfig(BaseModel): class OptimizerConfig(BaseModel):
"""Configuration parameters for the optimization algorithm.
:param optimizer_type: Type of optimizer to use (adam, adamw, or sgd)
:param lr: Learning rate for the optimizer
:param weight_decay: Weight decay coefficient for regularization
:param num_warmup_steps: Number of steps for learning rate warmup
"""
optimizer_type: OptimizerType optimizer_type: OptimizerType
lr: float lr: float
weight_decay: float weight_decay: float
@ -50,6 +78,13 @@ class OptimizerConfig(BaseModel):
@json_schema_type @json_schema_type
class EfficiencyConfig(BaseModel): class EfficiencyConfig(BaseModel):
"""Configuration for memory and compute efficiency optimizations.
:param enable_activation_checkpointing: (Optional) Whether to use activation checkpointing to reduce memory usage
:param enable_activation_offloading: (Optional) Whether to offload activations to CPU to save GPU memory
:param memory_efficient_fsdp_wrap: (Optional) Whether to use memory-efficient FSDP wrapping
:param fsdp_cpu_offload: (Optional) Whether to offload FSDP parameters to CPU
"""
enable_activation_checkpointing: bool | None = False enable_activation_checkpointing: bool | None = False
enable_activation_offloading: bool | None = False enable_activation_offloading: bool | None = False
memory_efficient_fsdp_wrap: bool | None = False memory_efficient_fsdp_wrap: bool | None = False
@ -58,6 +93,17 @@ class EfficiencyConfig(BaseModel):
@json_schema_type @json_schema_type
class TrainingConfig(BaseModel): class TrainingConfig(BaseModel):
"""Comprehensive configuration for the training process.
:param n_epochs: Number of training epochs to run
:param max_steps_per_epoch: Maximum number of steps to run per epoch
:param gradient_accumulation_steps: Number of steps to accumulate gradients before updating
:param max_validation_steps: (Optional) Maximum number of validation steps per epoch
:param data_config: (Optional) Configuration for data loading and formatting
:param optimizer_config: (Optional) Configuration for the optimization algorithm
:param efficiency_config: (Optional) Configuration for memory and compute optimizations
:param dtype: (Optional) Data type for model parameters (bf16, fp16, fp32)
"""
n_epochs: int n_epochs: int
max_steps_per_epoch: int = 1 max_steps_per_epoch: int = 1
gradient_accumulation_steps: int = 1 gradient_accumulation_steps: int = 1
@ -70,6 +116,17 @@ class TrainingConfig(BaseModel):
@json_schema_type @json_schema_type
class LoraFinetuningConfig(BaseModel): class LoraFinetuningConfig(BaseModel):
"""Configuration for Low-Rank Adaptation (LoRA) fine-tuning.
:param type: Algorithm type identifier, always "LoRA"
:param lora_attn_modules: List of attention module names to apply LoRA to
:param apply_lora_to_mlp: Whether to apply LoRA to MLP layers
:param apply_lora_to_output: Whether to apply LoRA to output projection layers
:param rank: Rank of the LoRA adaptation (lower rank = fewer parameters)
:param alpha: LoRA scaling parameter that controls adaptation strength
:param use_dora: (Optional) Whether to use DoRA (Weight-Decomposed Low-Rank Adaptation)
:param quantize_base: (Optional) Whether to quantize the base model weights
"""
type: Literal["LoRA"] = "LoRA" type: Literal["LoRA"] = "LoRA"
lora_attn_modules: list[str] lora_attn_modules: list[str]
apply_lora_to_mlp: bool apply_lora_to_mlp: bool
@ -82,6 +139,12 @@ class LoraFinetuningConfig(BaseModel):
@json_schema_type @json_schema_type
class QATFinetuningConfig(BaseModel): class QATFinetuningConfig(BaseModel):
"""Configuration for Quantization-Aware Training (QAT) fine-tuning.
:param type: Algorithm type identifier, always "QAT"
:param quantizer_name: Name of the quantization algorithm to use
:param group_size: Size of groups for grouped quantization
"""
type: Literal["QAT"] = "QAT" type: Literal["QAT"] = "QAT"
quantizer_name: str quantizer_name: str
group_size: int group_size: int
@ -93,7 +156,11 @@ register_schema(AlgorithmConfig, name="AlgorithmConfig")
@json_schema_type @json_schema_type
class PostTrainingJobLogStream(BaseModel): class PostTrainingJobLogStream(BaseModel):
"""Stream of logs from a finetuning job.""" """Stream of logs from a finetuning job.
:param job_uuid: Unique identifier for the training job
:param log_lines: List of log message strings from the training process
"""
job_uuid: str job_uuid: str
log_lines: list[str] log_lines: list[str]
@ -101,11 +168,22 @@ class PostTrainingJobLogStream(BaseModel):
@json_schema_type @json_schema_type
class RLHFAlgorithm(Enum): class RLHFAlgorithm(Enum):
"""Available reinforcement learning from human feedback algorithms.
:cvar dpo: Direct Preference Optimization algorithm
"""
dpo = "dpo" dpo = "dpo"
@json_schema_type @json_schema_type
class DPOAlignmentConfig(BaseModel): class DPOAlignmentConfig(BaseModel):
"""Configuration for Direct Preference Optimization (DPO) alignment.
:param reward_scale: Scaling factor for the reward signal
:param reward_clip: Maximum absolute value for reward clipping
:param epsilon: Small value added for numerical stability
:param gamma: Discount factor for future rewards
"""
reward_scale: float reward_scale: float
reward_clip: float reward_clip: float
epsilon: float epsilon: float
@ -114,7 +192,19 @@ class DPOAlignmentConfig(BaseModel):
@json_schema_type @json_schema_type
class PostTrainingRLHFRequest(BaseModel): class PostTrainingRLHFRequest(BaseModel):
"""Request to finetune a model.""" """Request to finetune a model using reinforcement learning from human feedback.
:param job_uuid: Unique identifier for the training job
:param finetuned_model: URL or path to the base model to fine-tune
:param dataset_id: Unique identifier for the training dataset
:param validation_dataset_id: Unique identifier for the validation dataset
:param algorithm: RLHF algorithm to use for training
:param algorithm_config: Configuration parameters for the RLHF algorithm
:param optimizer_config: Configuration parameters for the optimization algorithm
:param training_config: Configuration parameters for the training process
:param hyperparam_search_config: Configuration for hyperparameter search
:param logger_config: Configuration for training logging
"""
job_uuid: str job_uuid: str
@ -140,7 +230,16 @@ class PostTrainingJob(BaseModel):
@json_schema_type @json_schema_type
class PostTrainingJobStatusResponse(BaseModel): class PostTrainingJobStatusResponse(BaseModel):
"""Status of a finetuning job.""" """Status of a finetuning job.
:param job_uuid: Unique identifier for the training job
:param status: Current status of the training job
:param scheduled_at: (Optional) Timestamp when the job was scheduled
:param started_at: (Optional) Timestamp when the job execution began
:param completed_at: (Optional) Timestamp when the job finished, if completed
:param resources_allocated: (Optional) Information about computational resources allocated to the job
:param checkpoints: List of model checkpoints created during training
"""
job_uuid: str job_uuid: str
status: JobStatus status: JobStatus
@ -160,7 +259,11 @@ class ListPostTrainingJobsResponse(BaseModel):
@json_schema_type @json_schema_type
class PostTrainingJobArtifactsResponse(BaseModel): class PostTrainingJobArtifactsResponse(BaseModel):
"""Artifacts of a finetuning job.""" """Artifacts of a finetuning job.
:param job_uuid: Unique identifier for the training job
:param checkpoints: List of model checkpoints created during training
"""
job_uuid: str job_uuid: str
checkpoints: list[Checkpoint] = Field(default_factory=list) checkpoints: list[Checkpoint] = Field(default_factory=list)