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

HPO logger handler #3061

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

St3V0Bay
Copy link

@St3V0Bay St3V0Bay commented Sep 7, 2023

Fixes #3023

Description:

Check list:

  • New tests are added (if a new feature is added)
  • New doc strings: description and/or example code are in RST format
  • Documentation is updated (if required)

@github-actions github-actions bot added examples Examples module: contrib Contrib module labels Sep 7, 2023

from ignite.engine import Engine, Events

_DEFAULT_METRIC_PATH = '/tmp/hypertune/output.metrics'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder whether this code could run on windows. If yes, we may need to provide OS-agnostic path using python tempfile module.

Copy link
Author

Choose a reason for hiding this comment

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

this is the path where the listener of the GCP HPO orchestration has a look. Whatever is dumped here (in terms of metric values) becomes visible to the Vertex platform. I found this path here https://github.com/GoogleCloudPlatform/cloudml-hypertune/blob/8e3530e1c4926ac64cf28330d1104b838e07a468/hypertune/hypertune.py#L24

Should we keep it?

Copy link
Collaborator

@vfdev-5 vfdev-5 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @St3V0Bay !
Can you please run this script to reformat the code to our format:

bash ./tests/run_code_style.sh install
bash ./tests/run_code_style.sh fmt

and let's also run mypy:

bash ./tests/run_code_style.sh mypy

Source: https://github.com/pytorch/ignite/blob/master/CONTRIBUTING.md#formatting-without-pre-commit

def __init__(
self,
evaluator: Engine | None = None,
metric_tag: UserString = 'training/hptuning/metric'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we use str here ?

Suggested change
metric_tag: UserString = 'training/hptuning/metric'
metric_tag: str = 'training/hptuning/metric'

Args:
engine: Ignite Engine, it can be a trainer, validator or evaluator.
"""
with self.lock:
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need a lock here ?

self.metrics.clear()
self.metrics.update(state_dict[MetricLoggerKeys.METRICS])

hpologger = HPOLogger()
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 we can remove this line.


class HPOLogger(object):
"""
Makes selected metric accessible for use by GCP Vertex AI hyperparameter tuning jobs. By adding only this
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please add a link to GCP Vertex AI as

`GCP Vertex AI <link>`_


Args:
evaluator: Evaluator to consume metric results from at the end of its evaluation run
metric_tag: Converts the metric value coming from the trainer/evaluator's state into a storable value
Copy link
Collaborator

Choose a reason for hiding this comment

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

Below this line we need to add .. versionadded:: 0.5.0 tag.
See https://github.com/pytorch/ignite/blob/master/CONTRIBUTING.md#writing-documentation for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples Examples module: contrib Contrib module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Event handler to "unlock" GCPs Vertex.AI hyperparameter tuning service
2 participants