Skip to content
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

[BC] keep_temps update #411

Merged
merged 12 commits into from
Dec 23, 2024
Merged

[BC] keep_temps update #411

merged 12 commits into from
Dec 23, 2024

Conversation

tvmarino
Copy link
Collaborator

@tvmarino tvmarino commented Dec 20, 2024

Rename base_path to persistent_objects_path and keep_temps to explicit_temps_dir.
Makes sure that if persistent_objects_path is set then explicit_temps_dir is also set
or neither of them is set. Further, passes explicit_temps_dir to
compilation_runner.get_workdir_context and ensures that the flag
and argument are not set at the same time.

Copy link
Collaborator

@mtrofin mtrofin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, naming nits, but all can be addressed asynchronously wrt reviews.

@@ -80,14 +80,23 @@ def __exit__(self, exc, value, tb):
pass


def get_workdir_context():
def get_workdir_context(keep_temps: Optional[str] = None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/keep_temps/explicit_temps_dir. Otherwise it sounds like a boolean (yes, documentation explains, but why call the object bicycle when it's a car lol)

"""
if keep_temps and _KEEP_TEMPS.value:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see... _KEEP_TEMPS... maybe we can refactor this thing's name after. But let's name the API clearly.

Or you can rename both in one swoop after, up to you.

@@ -46,6 +46,13 @@
from compiler_opt.distributed import buffered_scheduler
from compiler_opt.distributed.local import local_worker_manager

_BASE_PATH = flags.DEFINE_string(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe _PERSISTENT_OBJECTS_PATH or something - "base" is very generic.

btw, could we "hitch" this path to be a subdirectory of where we save the model?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not completely sure how we can do this since the code that trains the model is completely separate from this. We could potentially replace this with a sub-directory of where we save the collected trajectories.

@@ -918,6 +927,10 @@ def gen_trajectories(
worker_manager_class: A pool of workers hosted on the local machines, each
in its own process.
"""
if (None in (_BASE_PATH.value, FLAGS.keep_temps) and
not all(el is None for el in (_BASE_PATH.value, FLAGS.keep_temps))):
raise ValueError(('Both flags keep_temps={FLAGS.keep_temps} and'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the if statement could probably be simpler if written without all the Python syntactic sugar?

if (_BASE_PATH.value is None or FLAGS.keep_temps is None) and (_BASE_PATH.value is not None and FLAGS.keep_temps is not None):
  pass

They're both understandable, but I think this is a quite a bit more readable.

if (None in (_BASE_PATH.value, FLAGS.keep_temps) and
not all(el is None for el in (_BASE_PATH.value, FLAGS.keep_temps))):
raise ValueError(('Both flags keep_temps={FLAGS.keep_temps} and'
'base_path={_BASE_PATH.value} should be set or be None'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that both of these have to be set? I think it would make sense to turning on keeping temps if either of the flags is set rather than requiring both.

(Sorry if I missed some conversation about this on the API design side).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think keep_temps can be set independently of base_path but if base path is set keep_temps should be set, so I will do this check instead.

@tvmarino tvmarino merged commit f179ce1 into google:main Dec 23, 2024
11 checks passed
@tvmarino tvmarino deleted the keep_temps_update branch December 23, 2024 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants