-
Notifications
You must be signed in to change notification settings - Fork 48
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
feat: change tracker API to initialize tracker early and track additional metrics. #50
Closed
Closed
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1836a67
Generic Tracker API with command line arguments.
dushyantbehl e2a2e98
Merge remote-tracking branch 'upstream/main'
dushyantbehl 2d5ffa5
Bump aim version.
dushyantbehl 80453c4
default tracker none
dushyantbehl 9357243
Merge remote-tracking branch 'upstream/main'
dushyantbehl b0c170c
separate callbacks from train
dushyantbehl 4f93a7c
enable tracker to track extra metadata
dushyantbehl a28aa7b
Change to custom aim callback to disable multiple instantiation for
dushyantbehl 550604d
change default output path for aim run export
dushyantbehl c93329f
Merge remote-tracking branch 'upstream/main'
dushyantbehl f178c21
code format using black and minor nit to use public interface
dushyantbehl 2ceb54f
custom aim callback should be minimal
dushyantbehl 4f5acb6
Merge remote-tracking branch 'upstream/main'
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 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 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 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,14 @@ | ||
from dataclasses import dataclass | ||
|
||
@dataclass | ||
class AimConfig: | ||
# Name of the experiment | ||
experiment: str = None | ||
# 'repo' can point to a locally accessible directory (e.g., '~/.aim') or a remote repository hosted on a server. | ||
dushyantbehl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# When 'remote_server_ip' or 'remote_server_port' is set, it designates a remote aim repo. | ||
dushyantbehl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Otherwise, 'repo' specifies the directory, with a default of None representing '.aim'. | ||
dushyantbehl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
aim_repo: str = None | ||
aim_remote_server_ip: str = None | ||
aim_remote_server_port: int = None | ||
# Location of where run_hash is exported | ||
aim_run_hash_export_path: str = None |
This file contains 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
Empty file.
This file contains 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,47 @@ | ||
# Standard | ||
import os | ||
|
||
from tuning.tracker.tracker import Tracker | ||
|
||
# Third Party | ||
from aim.hugging_face import AimCallback | ||
|
||
class AimStackTracker(Tracker): | ||
|
||
def __init__(self, tracker_config): | ||
super().__init__(tracker_config) | ||
c = self.config | ||
exp = c.experiment | ||
ip = c.aim_remote_server_ip | ||
port = c.aim_remote_server_port | ||
repo = c.aim_repo | ||
hash_export_path = c.aim_run_hash_export_path | ||
|
||
if (ip is not None and port is not None): | ||
aim_callback = AimCallback( | ||
repo="aim://" + ip +":"+ port + "/", | ||
experiment=exp | ||
) | ||
if repo: | ||
aim_callback = AimCallback(repo=repo, experiment=exp) | ||
else: | ||
aim_callback = AimCallback(experiment=exp) | ||
|
||
run = aim_callback.experiment # Initialize Aim run | ||
run_hash = run.hash # Extract the hash | ||
|
||
# store the run hash | ||
if hash_export_path: | ||
with open(hash_export_path, 'w') as f: | ||
f.write(str(run_hash)+'\n') | ||
|
||
# Save Internal State | ||
self.hf_callback = aim_callback | ||
self.run = run | ||
|
||
def get_hf_callback(self): | ||
return self.hf_callback | ||
|
||
def track(self, metric, name, stage='additional_metrics'): | ||
context={'subset' : stage} | ||
self.run.track(metric, name=name, context=context) |
This file contains 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,11 @@ | ||
# Generic Tracker API | ||
|
||
class Tracker: | ||
def __init__(self, tracker_config) -> None: | ||
self.config = tracker_config | ||
|
||
def get_hf_callback(): | ||
return None | ||
|
||
def track(self, metric, name, stage): | ||
pass |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since there's a desire to implement multiple trackers, did we want to make the dependency (and imports) optional, just used when available and configured?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be done..but then do we still list these in the requirements.txt?
or do we throw an error and ask user to install the required tracker before importing it in the code.