Skip to content

only check accuracy of mutated args#1961

Open
shunting314 wants to merge 1 commit intoshunting314/stack/29from
shunting314/stack/32
Open

only check accuracy of mutated args#1961
shunting314 wants to merge 1 commit intoshunting314/stack/29from
shunting314/stack/32

Conversation

@shunting314
Copy link
Copy Markdown
Contributor

@shunting314 shunting314 commented Apr 6, 2026

Stacked PRs:


only check accuracy of mutated args

Previously if there are mutated args, we'll check every argument no matter if it's actually mutated. It would cause issue for SymmMemTensor signal_pad ptr. When we clone a symm memory tensor, we replace the signal_pad ptr as well. It does not make sense to compare the value of signal_pad ptr. Sometimes they pass the check since pointer addresses can be close. But it's also common that they fail the check.

@shunting314 shunting314 force-pushed the shunting314/stack/32 branch from ee9724e to 9df8e0d Compare April 6, 2026 20:48
@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 and removed request for jansel April 6, 2026 21:33
@shunting314 shunting314 marked this pull request as draft April 6, 2026 21:34
@shunting314 shunting314 changed the base branch from shunting314/stack/29 to main April 6, 2026 21:34
@shunting314 shunting314 changed the base branch from main to shunting314/stack/29 April 6, 2026 21:34
@shunting314 shunting314 marked this pull request as ready for review April 6, 2026 21:34
stack-info: PR: #1961, branch: shunting314/stack/32
@shunting314 shunting314 marked this pull request as draft April 6, 2026 21:53
@shunting314 shunting314 changed the base branch from shunting314/stack/29 to main April 6, 2026 21:53
@shunting314 shunting314 force-pushed the shunting314/stack/32 branch from 9df8e0d to d739251 Compare April 6, 2026 21:53
@shunting314 shunting314 changed the base branch from main to shunting314/stack/29 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/29 to main April 7, 2026 18:22
@shunting314 shunting314 changed the base branch from main to shunting314/stack/29 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/29 to main April 7, 2026 23:13
@shunting314 shunting314 changed the base branch from main to shunting314/stack/29 April 7, 2026 23:13
@shunting314 shunting314 marked this pull request as ready for review April 7, 2026 23:13
check_fn(args, self._baseline_post_args)
args_flat, _ = tree_flatten(args)
baseline_flat, _ = tree_flatten(self._baseline_post_args)
mutated_idx_set = set(self._mutated_arg_indices)
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.

Are the indices still correct after you flatten things? If you have f([a,b], c) is arg 2 b or c? It seems like this is changing that from c to b.

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.

arg 2 (count starts from 1) would be b here.

The self._mutated_arg_indices is constructed like this:

  1. flat the args
  2. filter away non-tensor args
  3. track the index of mutated tensors in the tensor list

I was thinking about simplifying things by letting self._mutated_arg_indices track the index in the non-filtered flattened args, but the following comment makes me hesitate:

# we should only count tensors, since they won't be bound or removed

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. I don't want to see the same flattening and filtering code duplicated in multiple places.

@shunting314 shunting314 marked this pull request as draft April 8, 2026 18:16
@shunting314 shunting314 changed the base branch from shunting314/stack/29 to main April 8, 2026 18:16
@shunting314 shunting314 changed the base branch from main to shunting314/stack/29 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