Skip to content

PPO with composite distribution crash before giving the warning on how to fix it. #2939

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

Open
siegelaaron94 opened this issue May 4, 2025 · 0 comments

Comments

@siegelaaron94
Copy link

This block

if log_prob.batch_size != adv_shape:
log_prob.batch_size = adv_shape

causes
AttributeError: 'Tensor' object has no attribute 'batch_size'

Before, the warning on how to fix it is shown.

if not is_tensor_collection(prev_log_prob):
# this isn't great: in general, multi-head actions should have a composite log-prob too
warnings.warn(
"You are using a composite distribution, yet your log-probability is a tensor. "
"Make sure you have called tensordict.nn.set_composite_lp_aggregate(False).set() at "
"the beginning of your script to get a proper composite log-prob.",
category=UserWarning,
)
if is_tensor_collection(log_prob):
log_prob = _sum_td_features(log_prob)
log_prob.view_as(prev_log_prob)

The order of the 2 blocks needs to be swapped

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

No branches or pull requests

1 participant