Replies: 3 comments
-
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.
-
I agree something like this might be useful. Especially with a "Decide" + "Do" structure it might be useful to allow all agents in parallel to decide what to do. |
Beta Was this translation helpful? Give feedback.
-
I am highly doubtful about going down this route. True parallelism is a highly complicated and challenging topic. There are experimental research projects exploring this for ABMs, typically on top of CUDA. These see very little use beyond those developing them despite the obvious speedup potential. Because of this, in my view, it is well beyond what MESA is and should be in the foreseeable future. |
Beta Was this translation helpful? Give feedback.
-
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