This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
69ec88c
first-round update
QuanluZhang a317fd0
retiarii search space are stored in db through nnimanager
QuanluZhang c0bc292
add comments
QuanluZhang 1516035
update the logic of search space generation
QuanluZhang 4150951
update
QuanluZhang 486c6ce
add a sub dict for visualizing trial configuration
QuanluZhang 2bd2e7f
update
31ec053
Merge branch 'master' of github.com:microsoft/nni into dev-nas-config
QuanluZhang 29343b3
Merge pull request #8 from Lijiaoa/dev-retiarii-hyper
QuanluZhang bed2f2c
resolve comments
QuanluZhang 9414c2e
update webui accordingly
QuanluZhang a7dcf48
fix minor
QuanluZhang 34c1bd9
update
QuanluZhang 380a38e
minor
QuanluZhang 6c2e8f6
fix pylint
QuanluZhang 75cc679
fix pylint in cgo
QuanluZhang 23352cd
fix ut
QuanluZhang aae0206
fix import
QuanluZhang f9ef69d
Merge branch 'master' of github.com:microsoft/nni into dev-nas-config
QuanluZhang fd4fdc4
resolve comments
QuanluZhang 5e61502
fix webui
QuanluZhang 2cf99cd
minor
QuanluZhang 45b7caf
fix eslint
QuanluZhang 0619c7d
fix eslint
QuanluZhang cd6cfaa
minor
QuanluZhang 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,27 +8,39 @@ | |
from typing import Any, Dict, Iterable, List | ||
|
||
from .interface import AbstractExecutionEngine, AbstractGraphListener | ||
from .utils import get_mutation_summary | ||
from .. import codegen, utils | ||
from ..graph import Model, ModelStatus, MetricData, Evaluator | ||
from ..integration_api import send_trial, receive_trial_parameters, get_advisor | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class BaseGraphData: | ||
def __init__(self, model_script: str, evaluator: Evaluator) -> None: | ||
""" | ||
Parameters | ||
---------- | ||
model_script | ||
code of an instantiated PyTorch model | ||
evaluator | ||
training approach for model_script | ||
mutation_summary | ||
a dict of all the choices during mutations in the HPO search space format | ||
""" | ||
def __init__(self, model_script: str, evaluator: Evaluator, mutation_summary: dict) -> None: | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
|
||
def dump(self) -> dict: | ||
return { | ||
'model_script': self.model_script, | ||
'evaluator': self.evaluator | ||
'evaluator': self.evaluator, | ||
'mutation_summary': self.mutation_summary | ||
} | ||
|
||
@staticmethod | ||
def load(data) -> 'BaseGraphData': | ||
return BaseGraphData(data['model_script'], data['evaluator']) | ||
return BaseGraphData(data['model_script'], data['evaluator'], data['mutation_summary']) | ||
|
||
|
||
class BaseExecutionEngine(AbstractExecutionEngine): | ||
|
@@ -111,7 +123,8 @@ def budget_exhausted(self) -> bool: | |
|
||
@classmethod | ||
def pack_model_data(cls, model: Model) -> Any: | ||
return BaseGraphData(codegen.model_to_pytorch_script(model), model.evaluator) | ||
mutation_summary = get_mutation_summary(model) | ||
return BaseGraphData(codegen.model_to_pytorch_script(model), model.evaluator, mutation_summary) | ||
|
||
@classmethod | ||
def trial_execute_graph(cls) -> 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
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,25 @@ | ||
from typing import Any, List | ||
from ..graph import Model | ||
|
||
def _unpack_if_only_one(ele: List[Any]): | ||
if len(ele) == 1: | ||
return ele[0] | ||
return ele | ||
|
||
def get_mutation_dict(model: Model): | ||
return {mut.mutator.label: _unpack_if_only_one(mut.samples) for mut in model.history} | ||
|
||
def mutation_dict_to_summary(mutation: dict) -> dict: | ||
mutation_summary = {} | ||
for label, samples in mutation.items(): | ||
# FIXME: this check might be wrong | ||
if not isinstance(samples, list): | ||
mutation_summary[label] = samples | ||
else: | ||
for i, sample in enumerate(samples): | ||
mutation_summary[f'{label}_{i}'] = sample | ||
return mutation_summary | ||
|
||
def get_mutation_summary(model: Model) -> dict: | ||
mutation = get_mutation_dict(model) | ||
return mutation_dict_to_summary(mutation) |
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
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
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
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.
Attributes
Parameters