-
Notifications
You must be signed in to change notification settings - Fork 66
docs: Add documentation on experiment tracking. #257
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
Merged
ashokponkumar
merged 9 commits into
foundation-model-stack:main
from
dushyantbehl:experiment_tracking_readme
Aug 7, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
18c5ee2
Add documentation on experiment tracking.
dushyantbehl 46f6b51
Reword few sentences and remove minor extras.
dushyantbehl e924028
Merge branch 'main' into experiment_tracking_readme
dushyantbehl 4235c33
Merge branch 'main' into experiment_tracking_readme
dushyantbehl 98e5361
Merge branch 'main' into experiment_tracking_readme
dushyantbehl 8e4d403
Merge branch 'main' into experiment_tracking_readme
dushyantbehl ff32fa8
Update README.md
dushyantbehl a811744
Merge branch 'main' into experiment_tracking_readme
dushyantbehl f4d504f
Merge branch 'main' into experiment_tracking_readme
dushyantbehl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| # Experiment Tracker | ||
|
|
||
| Experiment tracking is an optional feature of this repo. We have introduced experiment tracking to help in systematically recording hyperparameters, model configurations, and results from each experiment automatically and with the help of third party trackers like [Aimstack](https://aimstack.io). | ||
|
|
||
| Tracking can be enabled by passing a config in the [Training Arguments](https://github.com/foundation-model-stack/fms-hf-tuning/blob/a9b8ec8d1d50211873e63fa4641054f704be8712/tuning/config/configs.py#L131) | ||
| with the name of the enabled trackers passed as a list. | ||
dushyantbehl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ``` | ||
dushyantbehl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| from tuning import sft_trainer | ||
|
|
||
| training_args = TrainingArguments( | ||
| ..., | ||
| trackers = ["aim", "file_logger"] | ||
| ) | ||
|
|
||
| sft_trainer.train(train_args=training_args,...) | ||
| ``` | ||
|
|
||
| For each of the requested trackers the code expects you to pass a config to the `sft_trainer.train` function which can be specified through `tracker_conifgs` argument [here](https://github.com/foundation-model-stack/fms-hf-tuning/blob/a9b8ec8d1d50211873e63fa4641054f704be8712/tuning/sft_trainer.py#L78) details of which are present below. | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ## Tracker Configurations | ||
|
|
||
| ## File Logging Tracker | ||
|
|
||
| [File Logger](../tuning/trackers/filelogging_tracker.py) is an inbuilt tracker which can be used to dump loss at every log interval to a file. | ||
|
|
||
| Currently `File Logger` is enabled by default and will dump loss at every log interval of a training to a default file path specified [here](../tuning/config/tracker_configs.py) inside the output folder passed during training. | ||
|
|
||
| To override the location of file logger please pass an instance of the [FileLoggingTrackerConfig](../tuning/config/tracker_configs.py) to `tracker_configs` argument. | ||
|
|
||
| ``` | ||
| from tuning import sft_trainer | ||
| from tuning.config.tracker_configs import FileLoggingTrackerConfig, TrackerConfigFactory | ||
|
|
||
| training_args = TrainingArguments( | ||
| ..., | ||
| trackers = ["file_logger"] | ||
| ) | ||
|
|
||
|
|
||
| logs_file = "new_train_logs.jsonl" | ||
|
|
||
| tracker_configs = TrackerConfigFactory( | ||
| file_logger_config=FileLoggingTrackerConfig( | ||
| training_logs_filename=logs_file | ||
| ) | ||
| ) | ||
|
|
||
| sft_trainer.train(train_args=training_args, tracker_configs=tracker_configs, ...) | ||
| ``` | ||
|
|
||
| Currently File Logging tacker supports only one argument and this file will be placed inside the `train_args.output` folder. | ||
|
|
||
| ## Aimstack Tracker | ||
|
|
||
| To enable [Aim](https://aimstack.io) users need to pass `"aim"` as the requested tracker as part of the [training argument](https://github.com/foundation-model-stack/fms-hf-tuning/blob/a9b8ec8d1d50211873e63fa4641054f704be8712/tuning/config/configs.py#L131). | ||
|
|
||
|
|
||
| When using Aimstack, users need to specify additional arguments which specify where the Aimstack database is present and what experiment name to use | ||
| for tracking the training. | ||
|
|
||
| Aimstack supports either a local (`filesystem path`) based db location or a remote (`aim_server:port`) based database location. | ||
|
|
||
| See Aim [documentation](https://aimstack.readthedocs.io/en/latest/using/remote_tracking.html) for more details. | ||
|
|
||
| After [initialising a repo](https://aimstack.readthedocs.io/en/latest/quick_start/setup.html#initializing-aim-repository), users can specify the location of the | ||
dushyantbehl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| repo either local or remote. | ||
|
|
||
| For a local aim database where `aim_repo` should point to the path of where the initialized Aimstack repo is present, | ||
|
|
||
| ``` | ||
| from tuning import sft_trainer | ||
| from tuning.config.tracker_configs import AimConfig, TrackerConfigFactory | ||
|
|
||
| training_args = TrainingArguments( | ||
| ..., | ||
| trackers = ["aim"], | ||
| ) | ||
|
|
||
| tracker_configs = TrackerConfigFactory( | ||
| aim_config=AimConfig( | ||
| experiment="experiment-name", | ||
| aim_repo=<path_to_the_repo> | ||
| ) | ||
| ) | ||
|
|
||
| sft_trainer.train(train_args=training_args, tracker_configs=tracker_configs,....) | ||
| ``` | ||
|
|
||
| or, for a remote server where aimstack database is running at `aim://aim_remote_server_ip:aim_remote_server_port` | ||
|
|
||
| ``` | ||
| from tuning import sft_trainer | ||
| from tuning.config.tracker_configs import AimConfig, TrackerConfigFactory | ||
|
|
||
| training_args = TrainingArguments( | ||
| ..., | ||
| trackers = ["aim"], | ||
| ) | ||
|
|
||
| tracker_configs = TrackerConfigFactory( | ||
| aim_config=AimConfig( | ||
| experiment="experiment-name", | ||
| aim_remote_server_ip=<server_url>, | ||
| aim_remote_server_port=<server_port> | ||
| ) | ||
| ) | ||
|
|
||
| sft_trainer.train(train_args=training_args, tracker_configs=tracker_configs,....) | ||
| ``` | ||
|
|
||
| The code expects either the `local` or `remote` repo to be specified and will result in a `ValueError` otherwise. | ||
| See [AimConfig](https://github.com/foundation-model-stack/fms-hf-tuning/blob/a9b8ec8d1d50211873e63fa4641054f704be8712/tuning/config/tracker_configs.py#L25) for more details. | ||
|
|
||
|
|
||
| ## Running the code via command line `tuning/sft_trainer::main` function | ||
|
|
||
| If running the code via main function of [sft_trainer.py](../tuning/sft_trainer.py) the arguments to enable and customise trackers can be passed via commandline. | ||
|
|
||
| To enable tracking please pass | ||
|
|
||
| ``` | ||
| --tracker <aim/file_logger> | ||
| ``` | ||
|
|
||
| To further customise tracking you can specify additional arguments needed by the tracker like | ||
|
|
||
| ``` | ||
| --tracker aim --aim_repo <path-to-aimrepo> --experiment <experiment-name> | ||
| ``` | ||
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.
Uh oh!
There was an error while loading. Please reload this page.