question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Are there asynchronous parallel examples?

See original GitHub issue

I have a function that needs to be evaluate remotely

evaluate(parameter, server_id):
    # send `parameter` to server based on `server_id`
    return {'metric': (res, 0)}

For instance, I have 5 servers and want to optimize the metric in parallel. Currently the only way I could think of is to run the following :

import multiprocessing as mp
ps=[]
for i in range(5):
    parameters, trial_index = ax_client.get_next_trial()
    p = mp.Process(target=evaluate, args=(parameters, i))
    p.start()
    ps.append(p)
for i in range(5):
    ps[i].join()
    # retrieve data 
    ax_client.complete_trial(trial_index=trial_index, raw_data=retrieved_data)

This is actually synchronous, which is less efficient. Is there a way to construct an asynchronous parallel evaluation?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mpolson64commented, Apr 5, 2022

Hi @deng-cy thank you for reaching out! Your use case may be a good candidate for our Scheduler API, which has a tutorial here.

It involves a little more overhead to set up compared to the Service API, you will define a Runner object to send trials to your external system and Metric objects to retrieve the data once the trial has been run, but it gives you the ability to set maximum parallelism (among other settings) and allow Ax to handle scheduling, new point generation, and trial deployment and polling for you automatically. Personally this is my favorite way of using Ax as it allows the user to “set it and forget it”, which I find more than worth the effort in setting the Scheduler up for most experiments.

If you need any assistance setting this up or any other questions with your specific use case please feel free to continue to respond in this thread.

1reaction
deng-cycommented, Apr 9, 2022

@sgbaird Yeah Service API, I corrected it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The difference between Asynchronous and Parallel - Medium
Visual Studio magazine defines 'Asynchronous Programming' as “… a means of parallel programming in which a unit of work runs separately from the ......
Read more >
How to articulate the difference between asynchronous and ...
Async and Callbacks are just a mechanism that allows the programmer to express concurrency. Consider that well-known parallel programming design ...
Read more >
Asynchronous versus parallel versus concurrent programming
Asynchronous programming involves some calculations time-intensive tasks, which on the one hand are engaging a thread in the background but do not affect...
Read more >
Asynchronous Parallel Programming | SpringerLink
Asynchronous parallelism is the most general form of parallelism, whereby processors operate freely on tasks, and global synchronization is not required. In ...
Read more >
Asynchronous and Parallel Programming - C# Corner
This article provides a basic understanding of the two hot topics, asynchronous programming and parallel programming irrespective of the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found