Skip to content

[GENERAL SUPPORT]: Reusing/importing trials. #4672

@cesare-montresor

Description

@cesare-montresor

Question

I'm in the condition of repeating the same NAS search using different settings ( optimizing against a different set of metrics, or fixing some experiment paramerter)

So, i'm trying to run a common the sobol phase ( with all metrics and unlocked params ) and then, i setup 4 different clients, for the experiements variants (namely A,B,C,D, which can run in parallel ).

In order to achieve this, currently I'm using multiple clients:
1x COMMON: strategy sobol, 30 trials
4x VARIANT (A,B,C,D): strategy sobol 30 trials + bo 30 trials
variants runs after COMMON and they are initialized using
client.experiment.warm_start_from_old_experiment() and they are succefully imported.
At this point, i would expect to pull from trial 31, however no, the client still starts from 1, and run 60 more trials, 30 sobol, 30 bo, ending up with 90 trials in total.
It doesn't look like there is a clean way to advance the generation strategy to reflect the current number of trials.

Alternatively i tried to create the new strategy using only the 'bo' steps, or if i l put 0 trials for the sobol step, crash at:

client.get_next_trial()

with:

Exception has occurred: DataRequiredError
`MapKeyToFloat` transform requires non-empty data.
  File "/home/cesare/Projects/StrangeNet/modularnet/src/modularnet/metamodel/experiment.py", line 500, in run_phase
    trials, stop = phase.client.get_next_trials(max_trials=parallel_trials)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ax.exceptions.core.DataRequiredError: `MapKeyToFloat` transform requires non-empty data.

What's the correct way of doing so ?

configure client


def configure_client(self, template:MetaModelTemplate, strategy:str='bo'):
        # seed_everything(self.seed) -> seed what ? ax client ?
        params = template.get_params()

        min_acc = template.get_value('nas_min_acc', 0.8) 
        objectives = {'val_acc': ObjectiveProperties(minimize=False, threshold=min_acc)}


        if template.get_value('exp_metric_modularity', False):
            min_mod_score = template.get_value('nas_min_mod_score', 0.2)
            objectives['modularity_score'] = ObjectiveProperties(minimize=False, threshold=min_mod_score) 
        
        sobol_step = GenerationStep(Generators.SOBOL, self.trials_prior )
        bo_step = GenerationStep(Generators.BOTORCH_MODULAR, self.trials_search)

        generation_steps = [ sobol_step ] 
        
        if strategy == 'bo':
            generation_steps.append(bo_step)
        

        ax_client = AxClient(
            generation_strategy=GenerationStrategy(steps=generation_steps),
        )

        ax_client.create_experiment( 
            name=self.name, 
            parameters=params,
            objectives=objectives,
            tracking_metric_names=['modularity_score','val_acc'],
        )


        
        return ax_client

        
        num_trials = client.experiment.num_trials
        if old_client is not None:
            imported_trials = client.experiment.warm_start_from_old_experiment(old_client.experiment, search_space_check_membership_raise_error=False)
            print(f"Imported {len(imported_trials)}/{len(old_client.experiment.trials)} trials from previous experiment")
        start_trials = client.experiment.num_trials
        while not stop:
            params, trial_index = client.get_next_trial()
            print(start_trials,params, trial_index)

Please provide any relevant code snippet if applicable.

Code of Conduct

  • I agree to follow this Ax's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions