lab
lab copied to clipboard
Why is reset so slow?
I'm finding it that reset of the envrionment takes around 0.35 secs which is kinda slowish? Is there a way to optimize it?
I have been searching through the code but apart from the start() method which has two for loops haven't find anything slow? Is it due to the quake engine or smth else?
Any info is highly appreciated
I think 0.35 seconds is about as fast as it gets. Internally, I believe they restart/reload the level from scratch on every reset. If you're using something like random maze generation, then it gets worse with 5-15 seconds per reset. However, this can be optimized with the level cache.
@alex-petrenko thanks for answering! Is there any way to hack it not to reload the level from scratch just randomly reset positions of objects/colors? No need to reload everything, it would be a huge boost to total frames per second for RL.
There must be a way but I'm not an expert.
I'd guess you can just do it on the level of the scenario, basically running the same very long episode but just resetting positions of the actors. This won't give you done=True, but in your RL code you can use some auxiliary variables from info
dictionary to detect episode termination.
@alex-petrenko that's what I was thinking too, any idea where I should look first? codebase is new to me
Sorry, I'm relatively new too. My first suggestion is to measure how much you're actually losing. Try to minimize the losses by making your episode longer and/or doing all resets in parallel if you can (e.g. set episode duration to the exact same number of frames for all envs).
If you absolutely need to fix this, I think you need to look at the Lua code of the scenario that you're using, and figure out from there. It is possible to create callbacks between C++ and Lua code, so you can detect the reset event and trigger the cleanup in Lua. Sorry, I don't think I can guide you any further :)
@alex-petrenko Thanks for all the info!
Hi, You can return an empty string from getNextMap. This will quick reload the current map.
@charlesbeattie Do you know if it randomizes the level still and where can it be located? Thanks!
Anything related to map generation is baked in. The some entities are contained within the map and so are baked in. But you can add entities dynamically too. See game_scripts/levels/demos/extra_entities.lua for an example for creating entities without rebuilding the map. (These features came in later in the dev cycle so we more heavily relied on level caching.)