Bernhard add mean action - #541
Open
Kait0 wants to merge 42 commits into
Open
Conversation
…ent is continuous.
… into bernhard_01
…rything mode for now.
… into bernhard_01
Closed
vcharraut
reviewed
Jul 27, 2026
vcharraut
reviewed
Jul 27, 2026
Comment on lines
+337
to
+362
| self.register_buffer( | ||
| "JERK_LONG", | ||
| torch.tensor((-15.0, -4.0, 0.0, 4.0), dtype=torch.float32, requires_grad=False), | ||
| persistent=False, | ||
| ) | ||
| self.register_buffer( | ||
| "JERK_LAT", torch.tensor((-4.0, 0.0, 4.0), dtype=torch.float32, requires_grad=False), persistent=False | ||
| ) | ||
|
|
||
| self.register_buffer( | ||
| "ACCELERATION_VALUES", | ||
| torch.tensor( | ||
| (-4.0000, -2.6670, -1.3330, -0.0000, 1.3330, 2.6670, 4.0000), dtype=torch.float32, requires_grad=False | ||
| ), | ||
| persistent=False, | ||
| ) | ||
| self.register_buffer( | ||
| "STEERING_VALUES", | ||
| torch.tensor( | ||
| (-0.667, -0.500, -0.333, -0.167, 0.000, 0.167, 0.333, 0.500, 0.667), | ||
| dtype=torch.float32, | ||
| requires_grad=False, | ||
| ), | ||
| persistent=False, | ||
| ) | ||
|
|
Collaborator
There was a problem hiding this comment.
theses values should come directly from the BINDING defined in env_binding.h
Collaborator
Author
There was a problem hiding this comment.
why do you think that? These are method-specific hyperparameters.
Maybe the min and max possible values should come from the environment?
Collaborator
There was a problem hiding this comment.
Maybe the min and max possible values should come from the environment? -> Yes, should have been more specific
// Jerk action space (for JERK dynamics model)
static const float JERK_LONG[4] = {-15.0f, -4.0f, 0.0f, 4.0f};
static const float JERK_LAT[3] = {-4.0f, 0.0f, 4.0f};
// Classic action space (for CLASSIC dynamics model)
static const float ACCELERATION_VALUES[7] = {-4.0000f, -2.6670f, -1.3330f, -0.0000f, 1.3330f, 2.6670f, 4.0000f};
static const float STEERING_VALUES[9] = {-0.667f, -0.500f, -0.333f, -0.167f, 0.000f, 0.167f, 0.333f, 0.500f, 0.667f};We direclty want to use these variables here to avoid duplicate and potential errors
vcharraut
reviewed
Jul 27, 2026
| self.is_continuous = isinstance(env.single_action_space, pufferlib.spaces.Box) | ||
| self.is_continuous = ( | ||
| action_type == "continuous" | ||
| ) # TODO Check if what the `"trajectory"`, `"trajectory_frenet"`, `"trajectory_jerk" features do and if they are considered continuous. |
Collaborator
There was a problem hiding this comment.
you can remove the comment about traj, it is a mistake from the README.md
vcharraut
reviewed
Jul 27, 2026
| action = logits.sample().view(batch, -1) | ||
| if deterministic: | ||
| if action_selection != ACTION_SELECT_SAMPLE: | ||
| action = logits.loc.view(batch, -1) # TODO - DETERMINISTIC use mean action for eval |
Collaborator
There was a problem hiding this comment.
this comment seems obselete now
vcharraut
reviewed
Jul 27, 2026
vcharraut
reviewed
Jul 27, 2026
vcharraut
reviewed
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The same PR as 536 before, but without my personal files:
Added the option to make the policy use either the mean, the mode, or a sample of the distribution instead of the mode during inference.
This required a fundamental design change.
Previously, the action representation was hardcoded in the simulator.
Now there are two options: one for the agent, either continuous or discrete, and one for the environment, either continuous or discrete (to avoid removing features).
The default now is:
env.action_type: continuous
policy.action_type: discrete
The default for eval is kept in mode so that there is no change in behavior with the default configuration.
In local eval eval_simulation: gigaflow
and default parameters, this improved the latest nightly model slightly:
mean: "avg_distance_per_infraction": 16646
mode: "avg_distance_per_infraction": 16127
I verified that these changes have no influence on training performance.