feat: Backend-First Training API (Phase 1) #521
Merged
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.
Training is now initiated through
backend.train()instead ofmodel.train().Migration Guide
Before (deprecated):
After (recommended):
Summary
This PR implements Phase 1 of the Backend-First Training API (RFC #519), providing:
New API:
backend.train(model, trajectory_groups, **kwargs)LocalTrainResultandServerlessTrainResultwithstep,metrics, and backend-specific fields (e.g.,checkpoint_path)Explicit Logging
backend.train()does NOT automatically log trajectories or metricsmodel.log()once after training to log both trajectories and metrics togetherExtended
model.log()metricsandstepkwargs for logging training metrics alongside trajectoriesawait model.log(groups, metrics=result.metrics, step=result.step, split="train")Fixed
get_inference_name()model.name@stepfor LocalBackend after registrationDeprecation Warning
model.train()now emits aDeprecationWarningwith migration instructionsPhase 2 (Future)
In a future release, we will:
model.train()method entirelyart.TrainConfigandart.dev.TrainConfigclassesFiles Changed
Core:
src/art/model.py- Extendedlog(), deprecation warning, fixedget_inference_name()src/art/backend.py- Addedtrain()stub and_model_inference_name()src/art/local/backend.py- Addedtrain()with full kwargs,_model_inference_name()src/art/serverless/backend.py- Addedtrain()with backend-specific kwargssrc/art/types.py- AddedTrainResult,LocalTrainResult,ServerlessTrainResultsrc/art/__init__.py- Exported new typesExamples (all updated to new API):
examples/2048/train.pyexamples/benchmarking_comparison_models.pyexamples/hn_title_generator/train.pyexamples/just-the-facts/just_the_facts/train.pyexamples/mcp-rl/mcp_rl/train.pyexamples/openenv_echo.pyexamples/prisoners-dilemma.ipynbexamples/rock-paper-tool-use.ipynbexamples/temporal_clue/*.pyand*.ipynbexamples/tic_tac_toe/*.pyexamples/tic_tac_toe_self_play/*.pyTests:
tests/test_backend_train_api.py(new)tests/integration/test_multi_checkpoint_training.pyCloses #519