Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic files world reset #265

Merged
merged 18 commits into from
Oct 21, 2024
Merged

Dynamic files world reset #265

merged 18 commits into from
Oct 21, 2024

Conversation

aaravpandya
Copy link
Collaborator

@aaravpandya aaravpandya commented Oct 9, 2024

This PR adds support to dynamically reset the sim on runtime using different map files. We introduce new method set_maps(List: str) that takes in exactly the num_worlds file names and resets the sim to on these new maps.

Here is an example script to use the new functionality -

import gpudrive

scenes = ["data/examples/tfrecord-00012-of-01000_389.json",]

params = gpudrive.Parameters()
params.polylineReductionThreshold = 0.5

sim = gpudrive.SimManager(
    exec_mode=gpudrive.madrona.ExecMode.CPU,
    gpu_id=0,
    scenes=scenes,
    params=params,  # Environment parameters
)

shape_tensor = sim.shape_tensor().to_torch()

print(shape_tensor)
sim.set_maps(["data/examples/tfrecord-00001-of-01000_307.json"])
print(shape_tensor)

Expected output

(madrona) (base) aarav@emerge2-desktop:~/gpudrive$ python index.py
tensor([[ 18, 456]], dtype=torch.int32)
tensor([[ 10, 182]], dtype=torch.int32)

@aaravpandya aaravpandya changed the title Dynamic files world reset [WIP] Dynamic files world reset Oct 9, 2024
@aaravpandya aaravpandya linked an issue Oct 9, 2024 that may be closed by this pull request
@aaravpandya aaravpandya changed the title [WIP] Dynamic files world reset Dynamic files world reset Oct 9, 2024
src/init.hpp Outdated Show resolved Hide resolved
@daphnecor daphnecor added the documentation Improvements or additions to documentation label Oct 18, 2024
@daphnecor daphnecor added the enhancement New feature or request label Oct 18, 2024
Copy link
Contributor

@eugenevinitsky eugenevinitsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aaravpandya
Copy link
Collaborator Author

LGTM

This PR still needs some work. I just fixed an issue where it was not compiling to CUDA, and Daphne is fixing some issues related to shapes during training.

@eugenevinitsky
Copy link
Contributor

eugenevinitsky commented Oct 19, 2024

Ah can you mark it as WIP or a draft if it's not ready for review?

@daphnecor daphnecor merged commit fcb28b0 into main Oct 21, 2024
1 check passed
@daphnecor daphnecor deleted the ap_dynamicFiles branch October 21, 2024 13:38
KKGB pushed a commit to CILAB-MA/gpudrive_lab that referenced this pull request Oct 23, 2024
* Introduce new types for Map Resets

* Copy Maps to sim

* Hook up to reset

* Dont throw exceptions

* Hook up resetmap

* Hook up resetmap

* Fix the BVH tree limits

* Add resampling of scenarios method

* Add optional list param

* Fix cuda compile

* Missing semicolon

* Integrate resampling of scenarios with gym env and IPPO

* Revert max objects const

* Update default and remove redundancy

* Small improvements

* Fix

---------

Co-authored-by: Daphne Cornelisse <[email protected]>
KKGB pushed a commit to CILAB-MA/gpudrive_lab that referenced this pull request Oct 23, 2024
* Introduce new types for Map Resets

* Copy Maps to sim

* Hook up to reset

* Dont throw exceptions

* Hook up resetmap

* Hook up resetmap

* Fix the BVH tree limits

* Add resampling of scenarios method

* Add optional list param

* Fix cuda compile

* Missing semicolon

* Integrate resampling of scenarios with gym env and IPPO

* Revert max objects const

* Update default and remove redundancy

* Small improvements

* Fix

---------

Co-authored-by: Daphne Cornelisse <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable swapping the set of training files
3 participants