Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

[retiarii] support visualize model space with the hpo chart on webui #4304

Merged
merged 25 commits into from
Dec 10, 2021

Conversation

QuanluZhang
Copy link
Contributor

@QuanluZhang QuanluZhang commented Nov 10, 2021

Description

support the hyper-parameter chart for retiarii experiment.

Checklist

  • search space generated by retiarii engine is stored to db through nnimanager
  • add a sub dict in trial configuration for visualization
  • modify webui for correct visualization of the hyper parameter chart
  • test case
  • doc: no doc should be updated

How to test

run the multi-trial nas example and view the hyper-parameter chart

@QuanluZhang QuanluZhang marked this pull request as ready for review November 11, 2021 11:08
@liuzhe-lz liuzhe-lz mentioned this pull request Nov 12, 2021
86 tasks
@@ -27,6 +27,7 @@ class CommandType(Enum):
SendTrialJobParameter = b'SP'
NoMoreTrialJobs = b'NO'
KillTrialJob = b'KI'
ReportSearchSpace = b'RS'
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the visual search space could be directly embedded into original search space, rather than requiring a new channel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we should add a new transmission direction, i.e., sending search space from tuner/advisor to nnimanager. Previously, search space is sent from nnimanager to tuner/advisor

Copy link
Contributor

Choose a reason for hiding this comment

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

We already have update search space in REST API. See Experiment.update_search_space() for an example implementation.
I think Retiarii should report search space use this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update search space is from nnimanager to advisor, not advisor to nnimanager

Copy link
Contributor

Choose a reason for hiding this comment

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

Experiment.update_search_space() is from experiment launcher (RetiariiExperiment) to NNI manager, and then to dispatcher.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to using this function



class PythonGraphData:
def __init__(self, class_name: str, init_parameters: Dict[str, Any],
mutation: Dict[str, Any], evaluator: Evaluator) -> None:
mutation: Dict[str, Any], evaluator: Evaluator, visual_hp: dict = None) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

visual_hp can be inferred from mutation I think.


def dump(self) -> dict:
return {
'class_name': self.class_name,
'init_parameters': self.init_parameters,
'mutation': self.mutation,
'evaluator': self.evaluator
'evaluator': self.evaluator,
'_visual_hyper_params_': self.visual_hp
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think visual_hyper_params is so special that it needs to be quoted with underline.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that depends on whether _visual_hyper_params_ is designed to be Retiarii only.
In HPO scenario all other stuffs are meant for tuning algorithm, but this field is for web UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

some other stuffs are meant for trial. in hpo, those stuffs are visualizable, but in retiarii they are not. that is why we need a new field. "visual_hyper_params" is special, because it delivers redundant data


class BaseGraphData:
def __init__(self, model_script: str, evaluator: Evaluator) -> None:
def __init__(self, model_script: str, evaluator: Evaluator, visual_hp: dict = None) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest renaming it into something like mutation_summary. It's not for visualization purpose only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point

"""
Execution engine uses this API to report the search space extracted by
strategy to nnimanager which stores the search space into db,
so that webui can access the search space like HPO
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing period.

if mutator.label is not None:
label = mutator.label
else:
label = f'auto_label_{auto_label_seq}'
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does auto_label come from? I think this logic is already done in dry_run_for_search_space, and self is never used in this function. Suggest refact it into a util.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to util. dry_run_for_search_space cannot be used as the generated search space should follow our search space format

self.model_script = model_script
self.evaluator = evaluator
self.mutation_summary = mutation_summary
Copy link
Contributor

@cruiseliu cruiseliu Dec 5, 2021

Choose a reason for hiding this comment

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

This introduces a new term so it needs doc/comment to describe what is "mutation summary".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added



class BaseStrategy(abc.ABC):

@classmethod
def get_model_space(self, base_model: Model, applied_mutators: List[Mutator]) -> None:

Choose a reason for hiding this comment

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

This looks really weird. BaseStrategy is an interface, yet you put concrete implementations into it.

@@ -193,6 +193,8 @@ def _start_strategy(self):
)

_logger.info('Start strategy...')
search_space = BaseStrategy.get_model_space(base_model_ir, self.applied_mutators)

Choose a reason for hiding this comment

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

Should call dry_run_for_formated_search_space here. Not sure whether every search space can be successfully formatted though.

@@ -27,13 +28,14 @@ import {
* @returns Parsed structured parameters and unexpected entries
*/
function inferTrialParameters(
paramObj: object,
paramObj: RetiariiParameter,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this RetiariiParameter? How about normal trials?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the changes above are not needed. In L35, we can put:

'mutation_summary' in paramObj ? (paramObj as any).mutation_summary : paramObj;

Copy link
Contributor

Choose a reason for hiding this comment

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

@ultmaster @QuanluZhang also fix this in PR #4314

class BaseGraphData:
def __init__(self, model_script: str, evaluator: Evaluator) -> None:
"""
Parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

AttributesParameters

@ultmaster ultmaster closed this Dec 10, 2021
@ultmaster ultmaster reopened this Dec 10, 2021
@liuzhe-lz liuzhe-lz merged commit 357ec6e into microsoft:master Dec 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants