-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[retiarii] support visualize model space with the hpo chart on webui #4304
Conversation
fix hyper-parameter graph issue in retiarii experiment
nni/runtime/protocol.py
Outdated
@@ -27,6 +27,7 @@ class CommandType(Enum): | |||
SendTrialJobParameter = b'SP' | |||
NoMoreTrialJobs = b'NO' | |||
KillTrialJob = b'KI' | |||
ReportSearchSpace = b'RS' |
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.
I thought the visual search space could be directly embedded into original search space, rather than requiring a new channel.
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.
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
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.
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.
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.
update search space is from nnimanager to advisor, not advisor to nnimanager
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.
Experiment.update_search_space()
is from experiment launcher (RetiariiExperiment
) to NNI manager, and then to dispatcher.
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.
updated to using this function
nni/retiarii/execution/python.py
Outdated
|
||
|
||
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: |
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.
visual_hp
can be inferred from mutation
I think.
nni/retiarii/execution/python.py
Outdated
|
||
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 |
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.
I don't think visual_hyper_params
is so special that it needs to be quoted with underline.
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.
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.
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.
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
nni/retiarii/execution/base.py
Outdated
|
||
class BaseGraphData: | ||
def __init__(self, model_script: str, evaluator: Evaluator) -> None: | ||
def __init__(self, model_script: str, evaluator: Evaluator, visual_hp: dict = None) -> None: |
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.
Suggest renaming it into something like mutation_summary
. It's not for visualization purpose only.
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.
good point
nni/retiarii/integration_api.py
Outdated
""" | ||
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 |
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.
Missing period.
nni/retiarii/strategy/base.py
Outdated
if mutator.label is not None: | ||
label = mutator.label | ||
else: | ||
label = f'auto_label_{auto_label_seq}' |
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.
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.
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.
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 |
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.
This introduces a new term so it needs doc/comment to describe what is "mutation summary".
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.
added
nni/retiarii/strategy/base.py
Outdated
|
||
|
||
class BaseStrategy(abc.ABC): | ||
|
||
@classmethod | ||
def get_model_space(self, base_model: Model, applied_mutators: List[Mutator]) -> None: |
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.
This looks really weird. BaseStrategy is an interface, yet you put concrete implementations into it.
nni/retiarii/experiment/pytorch.py
Outdated
@@ -193,6 +193,8 @@ def _start_strategy(self): | |||
) | |||
|
|||
_logger.info('Start strategy...') | |||
search_space = BaseStrategy.get_model_space(base_model_ir, self.applied_mutators) |
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.
Should call dry_run_for_formated_search_space
here. Not sure whether every search space can be successfully formatted though.
ts/webui/src/static/model/trial.ts
Outdated
@@ -27,13 +28,14 @@ import { | |||
* @returns Parsed structured parameters and unexpected entries | |||
*/ | |||
function inferTrialParameters( | |||
paramObj: object, | |||
paramObj: RetiariiParameter, |
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.
Why is this RetiariiParameter
? How about normal trials?
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.
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.
I think the changes above are not needed. In L35, we can put:
'mutation_summary' in paramObj ? (paramObj as any).mutation_summary : paramObj;
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.
@ultmaster @QuanluZhang also fix this in PR #4314
nni/retiarii/execution/base.py
Outdated
class BaseGraphData: | ||
def __init__(self, model_script: str, evaluator: Evaluator) -> None: | ||
""" | ||
Parameters |
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.
AttributesParameters
Description
support the hyper-parameter chart for retiarii experiment.
Checklist
How to test
run the multi-trial nas example and view the hyper-parameter chart