Skip to content

fix _clone_args when there are non-tensor input#1963

Open
shunting314 wants to merge 1 commit intoshunting314/stack/33from
shunting314/stack/34
Open

fix _clone_args when there are non-tensor input#1963
shunting314 wants to merge 1 commit intoshunting314/stack/33from
shunting314/stack/34

Conversation

@shunting314
Copy link
Copy Markdown
Contributor

@shunting314 shunting314 commented Apr 6, 2026

@shunting314 shunting314 force-pushed the shunting314/stack/34 branch from 102ad18 to 632298b Compare April 6, 2026 21:34
shunting314 added a commit that referenced this pull request Apr 6, 2026
stack-info: PR: #1963, branch: shunting314/stack/34
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 6, 2026
@shunting314 shunting314 requested review from jansel and yf225 April 6, 2026 21:35
stack-info: PR: #1963, branch: shunting314/stack/34
@shunting314 shunting314 marked this pull request as draft April 6, 2026 21:53
@shunting314 shunting314 changed the base branch from shunting314/stack/33 to main April 6, 2026 21:53
@shunting314 shunting314 force-pushed the shunting314/stack/34 branch from 632298b to 241d005 Compare April 6, 2026 21:53
@shunting314 shunting314 changed the base branch from main to shunting314/stack/33 April 6, 2026 21:53
@shunting314 shunting314 marked this pull request as ready for review April 6, 2026 21:53
@shunting314 shunting314 marked this pull request as draft April 7, 2026 18:22
@shunting314 shunting314 changed the base branch from shunting314/stack/33 to main April 7, 2026 18:22
@shunting314 shunting314 changed the base branch from main to shunting314/stack/33 April 7, 2026 18:22
@shunting314 shunting314 marked this pull request as ready for review April 7, 2026 18:22
@shunting314 shunting314 marked this pull request as draft April 7, 2026 23:13
@shunting314 shunting314 changed the base branch from shunting314/stack/33 to main April 7, 2026 23:13
@shunting314 shunting314 changed the base branch from main to shunting314/stack/33 April 7, 2026 23:13
@shunting314 shunting314 marked this pull request as ready for review April 7, 2026 23:13

def _should_clone(idx: int) -> bool:
return idx_to_clone is None or idx in idx_to_clone
idx_to_clone_set = set(idx_to_clone) if idx_to_clone is not None else None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this the same data structure as in #1961? That PR didn't ignore non-tensors I believe. Is there a cleaner way to to manage this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's the same data structure. I think the main complexity is from letting the data-structure store indices of flattend-filted-tensor list.

If the code comment mentioned in #1961 (comment) is not a problem, we can change this data structure to store indices of flatted arg list before filtering away tensors. Otherwise, I think things can be cleaned up by added a API to return flattend-filted-tensor list from the original args.

Any comments about this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's try to clean this up. I think we need:

  1. A better name that reflects the filtered+flattened nature.
  2. Some helpers methods or data structures to make working this easier.

@shunting314 shunting314 marked this pull request as draft April 8, 2026 18:16
@shunting314 shunting314 changed the base branch from shunting314/stack/33 to main April 8, 2026 18:16
@shunting314 shunting314 changed the base branch from main to shunting314/stack/33 April 8, 2026 18:16
@shunting314 shunting314 marked this pull request as ready for review April 8, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants