feat: introduce fine_tuning API #4761
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Closes #3708
Scaffolds the
fine_tuningAPI. This is intended to be an OpenAI compatible API that may allow us to deprecate our post-training API. No providers have been implemented / migrated. Current conformance summary is provided below.OpenAI Fine-Tuning API Conformance Summary
Conformance Score: 88.1% (63 schema issues, 1 missing property, 0 breaking changes)
✅ Implementation Status
6 Endpoints Implemented:
POST /v1/fine_tuning/jobs- Create fine-tuning jobGET /v1/fine_tuning/jobs- List fine-tuning jobsGET /v1/fine_tuning/jobs/{id}- Retrieve fine-tuning jobPOST /v1/fine_tuning/jobs/{id}/cancel- Cancel fine-tuning jobGET /v1/fine_tuning/jobs/{id}/checkpoints- List job checkpointsGET /v1/fine_tuning/jobs/{id}/events- List job eventsOpenAI-Compatible Models:
FineTuningJob- Core job object with all OpenAI fieldsFineTuneMethod- Supports supervised, DPO, and reinforcement methodsFineTuningJobHyperparameters- Training configuration with auto defaultsFineTuningJobEvent- Job logging and eventsFineTuningJobCheckpoint- Training checkpoints🔧 Key Technical Details
Nullable Field Handling:
nullable_openai_stylefor required nullable fields (e.g.,finished_at,error,validation_file)remove_null_from_anyoffor optional non-nullable fields (e.g.,hyperparameters,seed,organization_id)Breaking Changes: None (verified with oasdiff)
📊 Remaining Issues (Non-Breaking)
The 63 remaining issues are format/representation differences that don't affect API functionality:
anyOfvsnullable: true- functionally equivalent)1 Missing Property:
metadataquery parameter onGET /fine_tuning/jobs(FastAPI doesn't support deepObject style parameters natively)🎯 Conformance Strategy
Prioritized functional compatibility over strict format matching: