Skip to content

[GENERAL SUPPORT]: Saving + loading experiment including trial data #3336

Open
@dthillaithevan

Description

Question

Hi,

What is the correct way to store and load an experiment and current trial data? My goal is to enable the ability to restart an optimization from any iteration using previously stored data.

The method below using to_json_snapshot() and load_from_json_file does not seem to work. Attempting to load the json data into another client and calling get_best_trial() results in an empty data error.

Thanks!

Please provide any relevant code snippet if applicable.

# Setup experiment
...

# Run N iterations of BO
for i in range(N_iter):
    params, it = ax_client.suggest_parameters()
    objective_value = objective(params)
    ax_client.update_optimizer(it, objective_value)
    
    # Save trial to json
    
    json_data = ax_client.to_json_snapshot()

    # Save data in each iteration
    with open("./exp.json", "w") as f: 
        json.dump(json_data, f)
        

# Load experiment + data from json
ax_client_2 = AxClient()
ax_client_2.load_from_json_file("./exp.json")

# This results in: Encountered error while trying to identify the best point: Cannot identify best point if experiment contains no data.
ax_client_2.get_best_trial()

Code of Conduct

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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