Skip to content

Conversation

@matteobettini
Copy link
Member

@matteobettini matteobettini commented Jul 12, 2024

continuation of #122

What we vectorize

Let me recap the levels of looping:

  1. there are multiple agents
  2. each agent can have multiple lidars
  3. each lidar sees multtiple entities
  4. at multiple angles
  5. in multiple environments

And here is what we vectorize:

  1. I wouldn't vectorize this as of now as not all agents have lidars
  2. i also would not vectorize this as the user might want to read out different lidars at different times (although I would consider it in the future)
  3. in this PR
  4. in this PR
  5. vmas does this already

Benchmarking

pollock scenario

use_vmas_env(
        scenario_name="pollock",
        render=False,
        save_render=False,
        random_action=True,
        continuous_actions=False,
        n_agents=15,
        n_lines=15,
        n_boxes=15,
        lidar=True,
        n_steps=100,
        num_envs=32,
 )

before PR:

M1 cpu: 134.55210709571838s
CUDA: 571.7651047706604s

after PR:

M1 cpu: 22.2061710357666s (0.16x the previous time)
CUDA: 91.27248549461365s (0.15 x the previous time)

benefit will increase in the number of steps and envs

🚀

@codecov
Copy link

codecov bot commented Jul 12, 2024

Codecov Report

Attention: Patch coverage is 99.46524% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.22%. Comparing base (a9d545f) to head (418ad04).

Files Patch % Lines
vmas/simulator/core.py 99.37% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
+ Coverage   87.47%   88.22%   +0.75%     
==========================================
  Files          82       83       +1     
  Lines        9507     9688     +181     
==========================================
+ Hits         8316     8547     +231     
+ Misses       1191     1141      -50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@matteobettini
Copy link
Member Author

@Zartris if you wanna review / try it out this shoulf be mega fasttttt

@matteobettini matteobettini changed the title [Feature] Vecotrized lidar [Feature] Vectorized lidar Jul 12, 2024
@Zartris
Copy link
Contributor

Zartris commented Jul 12, 2024

Oh that was quick! Ill take a look today

@matteobettini
Copy link
Member Author

pollock scenario

use_vmas_env(
        scenario_name="pollock",
        render=False,
        save_render=False,
        random_action=True,
        continuous_actions=False,
        n_agents=15,
        n_lines=15,
        n_boxes=15,
        lidar=True,
        n_steps=100,
        num_envs=32,
 )

before PR:

  • M1 cpu: 134.55210709571838s
  • CUDA: 571.7651047706604s

after PR:

  • M1 cpu: 22.2061710357666s (0.16x the previous time)
  • CUDA: 91.27248549461365s (0.15 x the previous time)

🚀

@Zartris
Copy link
Contributor

Zartris commented Jul 12, 2024

Everything seems to work good.

@matteobettini matteobettini merged commit cd7c14a into main Jul 12, 2024
@matteobettini matteobettini deleted the vec_lidar branch July 12, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants