Skip to content

Commit

Permalink
positional and kwargs corner case fix in for _build_args_kwargs (pyto…
Browse files Browse the repository at this point in the history
…rch#2714)

Summary:

## Context:
Setting None in positional args is colliding with the kwargs in situations when kwargs contains the argument name accepted by the method.

Eg :
```
def input_dist(ctx, id_feature_list):
    ...

// If _build_args_kwargs returns:
args = [None]
kwargs = {'id_feature_list': KJT}

input_dist(ctx, *args, **kwargs)
// extends to
input_dist(ctx, None, id_feature_list=KJT)
```

which results in "TypeError: got multiple values for argument 'id_feature_list'" because id_feature_list is provided both positionally (None) and via kwargs.

## Fix:
Ensure _build_args_kwargs does not append None to args when an argument is already correctly assigned in kwargs.

Differential Revision: D68892351
  • Loading branch information
aliafzal authored and facebook-github-bot committed Jan 31, 2025
1 parent b3e19e2 commit ebc45fe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion torchrec/distributed/train_pipeline/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ def _build_args_kwargs(
else:
args.append(arg)
else:
args.append(None)
if arg_info.name:
kwargs[arg_info.name] = None
else:
args.append(None)
return args, kwargs


Expand Down

0 comments on commit ebc45fe

Please sign in to comment.