feat: move trajectory logging from backend to frontend #518
+755
−343
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.
Summary
Implements RFC #511 - moves trajectory persistence and metrics reporting from the backend to the Model class, allowing backends to focus solely on training.
Key Changes
Model Class Additions
Model.log()now handles parquet writing, metrics calculation, history.jsonl, and wandb logging inlinebase_pathattribute (default: ".art") - configurable output pathreport_metricsattribute - explicit control over wandb logging (None= auto-detect,["wandb"]= enable,[]= disable)_get_wandb_run()method for lazy wandb initializationget_step()method now available on baseModelclass (returns 0 for non-trainable)TrainableModel Changes
train()now callslog()first, then delegates to backenddelete_checkpoints()reads history.jsonl locally to determine best checkpoint, then calls backendBackend Simplification
Backend._log()method entirely_delete_checkpoints()to_delete_checkpoint_files(steps_to_keep)_log_metrics(),_get_wandb_run(),_get_reward_std_dev_learning_rate_multiplier()from LocalBackendBreaking Changes
For Backend Interface (internal API, not user-facing)
Backend._log()method removedBackend._delete_checkpoints(benchmark, smoothing)renamed to_delete_checkpoint_files(steps_to_keep)For ServerlessBackend Users
Model.log()) instead of being sent to the APIRemoved Feature
scale_learning_rate_by_reward_std_devinternal config option removed - users who need this can implement it themselves using the history.jsonl dataMigration Guide
No changes required for standard usage. The following APIs work exactly as before:
New optional configuration:
Tests
Added comprehensive test suite in
tests/unit/test_frontend_logging.pycovering:Closes #511