Replies: 1 comment
-
Here is what I found while researching about async support in Solara:1. Task decorator:
2. Use_task hook:
So the decorator and hook can be useful in integrating async step function support with Solara visualization. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Motivation
Currently agents'
step()
functions are executed sequentially through AgentSet'sdo()
andshuffle_do()
functions. If there are I/O operations involved instep()
(e.g., disk or network I/O operations), they can potentially reduce performance and reponsiveness of the model. For example, in the upcoming Mesa-LLM project, agents will most likely need to query large language models at each step, through either local deployment or API calls.Note that sequential execution of agents'
step()
functions may be necessary, depending on specific model logic. For example in Schelling's segregation model, each agent's decision depends on other agents' earlier actions, sostep()
functions need to be called one after another. Conversely, in models where agents can observe and act simultaneously, or if I/O operations can be performed independently, these expensive I/Os might be a bottleneck.Potential Solution?
I'm wondering whether these cases can benefit from asynchronous execution of agents'
step()
functions. There could be a new async step function (or with any other function name) defined by users such as:But AgentSet will need to be updated accordingly, for instance with new async versions of
do()
andshuffle_do()
:However, this means that
model.step()
functions will also need to be async:As a result, SolaraViz will not work unless we update it to use async model step function too.
I also thought about letting users create their own AgentSet class:
But mesa.Model uses our own mesa.AgentSet and there's no way of inserting a custom AgentSet. Even if it can be done, there is still the same problem of converting
model.step()
to async and making it work with SolaraViz.Any better ideas?
Beta Was this translation helpful? Give feedback.
All reactions