Skip to content

Conversation

@laithsakka
Copy link
Contributor

Summary:
re-generating the inputs (the fake tensors from real tensors) can change some dimension from static to dynamic, this does not sounds to me to be part of the intention of those custom passes .
But this can have complication, for details of the issue read below, what i suggest here is just read the meta['val'] from the input graph instead of regenerating a new fake tensor.

a failure here https://www.internalfb.com/diff/D65023233 that is related to executorch.

  1. one of the passes changes the dimension of the one of the inputs from [2, 2, 3, 1] to f32[s0, 2, 7 - s2] (because calling from fake_tensor_mode.from_real_tensor can do that)

  2. after running passes execuotorch revert the changes of the meta['val] values for all inputs to match the old graph values before the pass did run. (https://www.internalfb.com/code/fbsource/[92156447ae2c]/xplat/executorch/exir/pass_base.py?lines=688)

  3. But executorch only do that for inputs and not for the internal nodes of the graph.

  4. in this case that one of the inputs from:

def forward(self, p_conv1_bias: "f32[2]", p_conv2_bias: "f32[2]", `b__frozen_param0: "i8[2, 2, s2, 1]", b__frozen_param1: "i8[2, 2, s2, 1]", x: "f32[s0, 2, 4]"):

to
def forward(self, p_conv1_bias: "f32[2]", p_conv2_bias: "f32[2]", b__frozen_param0: "i8[2, 2, 3, 1]", b__frozen_param1: "i8[2, 2, 3, 1]", x: "f32[s0, 2, 4]"):

replacing every s2 with 3 in the place holders only but executorch do not apply the changes back to internal nodes we we still have i8[s0, 2, 7 - s2, 1] in the graph (s2 coming from no where now!)
5) executorch runs more passes on this (ruined graph)
6) we get an error in one internal node operation that checks that the a dimension have only one dynamic shape.
quantized_decomposed_quantize_per_tensor_default_4: "i8[s0, 2, 7 - s2, 1]" = executorch_exir_dialects_edge__ops_quantized_decomposed_quantize_per_tensor_default(aten_unsqueeze_copy_default_1, 0.012759864330291748, 55, -128, 127, torch.int8); aten_unsqueeze_copy_default_1 = None

which is right since s2 was replaced with 3, but the change was not propagated to all internal nodes.

Differential Revision: D65120377

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 29, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/6550

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 4d2d511 with merge base f0463c4 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 29, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D65120377

@laithsakka laithsakka changed the title read meta["val"] from arg for fake tensors instead of generating a fake tensor using fake_tensor_mode.from_real_tensor read meta["val"] from arg for place holders instead of generating a fake tensor using fake_tensor_mode.from_real_tensor Oct 29, 2024
laithsakka added a commit to laithsakka/executorch that referenced this pull request Oct 30, 2024
…ake tensor using fake_tensor_mode.from_real_tensor (pytorch#6550)

Summary:

re-generating the inputs (the fake tensors from real tensors) can change some dimension from static to dynamic, this does not sounds to me to be part of the intention of those custom passes .
But this can have complication, for details of the issue read below, what i suggest here is just read the meta['val'] from the input graph instead of regenerating a new fake tensor. 

a failure here https://www.internalfb.com/diff/D65023233 that is related to executorch. 

0) one of the passes changes the dimension of the one of the inputs from [2, 2, 3, 1] to f32[s0, 2, 7 - s2] (because calling from fake_tensor_mode.from_real_tensor can do that)

1) after running passes execuotorch revert the changes of the meta['val] values for all inputs to match the old graph values before the pass did run. (https://www.internalfb.com/code/fbsource/[92156447ae2c]/xplat/executorch/exir/pass_base.py?lines=688)

2) But executorch only do that for inputs and not for the internal nodes of the graph.

3) in this case that one of the inputs from:
   
``` def forward(self, p_conv1_bias: "f32[2]", p_conv2_bias: "f32[2]", `b__frozen_param0: "i8[2, 2, s2, 1]", b__frozen_param1: "i8[2, 2, s2, 1]", x: "f32[s0, 2, 4]"):```

to 
    ```def forward(self, p_conv1_bias: "f32[2]", p_conv2_bias: "f32[2]", b__frozen_param0: "i8[2, 2, 3, 1]", b__frozen_param1: "i8[2, 2, 3, 1]", x: "f32[s0, 2, 4]"):```

replacing every s2 with 3 in the place holders only **but executorch do not apply the changes back to internal nodes** we we still have i8[s0, 2, 7 - s2, 1] in the graph (s2 coming from no where now!)
5) executorch runs more passes on this (ruined graph) 
6) we get an error in one internal node operation that checks that the a dimension have only one dynamic shape.
        quantized_decomposed_quantize_per_tensor_default_4: "i8[s0, 2, 7 - s2, 1]" = executorch_exir_dialects_edge__ops_quantized_decomposed_quantize_per_tensor_default(aten_unsqueeze_copy_default_1, 0.012759864330291748, 55, -128, 127, torch.int8);  aten_unsqueeze_copy_default_1 = None

which is right since s2 was replaced with 3, but the change was not propagated to all internal nodes.

Differential Revision: D65120377
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D65120377

laithsakka added a commit to laithsakka/executorch that referenced this pull request Oct 30, 2024
…ake tensor using fake_tensor_mode.from_real_tensor (pytorch#6550)

Summary:

re-generating the inputs (the fake tensors from real tensors) can change some dimension from static to dynamic, this does not sounds to me to be part of the intention of those custom passes .
But this can have complication, for details of the issue read below, what i suggest here is just read the meta['val'] from the input graph instead of regenerating a new fake tensor. 

a failure here https://www.internalfb.com/diff/D65023233 that is related to executorch. 

0) one of the passes changes the dimension of the one of the inputs from [2, 2, 3, 1] to f32[s0, 2, 7 - s2] (because calling from fake_tensor_mode.from_real_tensor can do that)

1) after running passes execuotorch revert the changes of the meta['val] values for all inputs to match the old graph values before the pass did run. (https://www.internalfb.com/code/fbsource/[92156447ae2c]/xplat/executorch/exir/pass_base.py?lines=688)

2) But executorch only do that for inputs and not for the internal nodes of the graph.

3) in this case that one of the inputs from:
   
``` def forward(self, p_conv1_bias: "f32[2]", p_conv2_bias: "f32[2]", `b__frozen_param0: "i8[2, 2, s2, 1]", b__frozen_param1: "i8[2, 2, s2, 1]", x: "f32[s0, 2, 4]"):```

to 
    ```def forward(self, p_conv1_bias: "f32[2]", p_conv2_bias: "f32[2]", b__frozen_param0: "i8[2, 2, 3, 1]", b__frozen_param1: "i8[2, 2, 3, 1]", x: "f32[s0, 2, 4]"):```

replacing every s2 with 3 in the place holders only **but executorch do not apply the changes back to internal nodes** we we still have i8[s0, 2, 7 - s2, 1] in the graph (s2 coming from no where now!)
5) executorch runs more passes on this (ruined graph) 
6) we get an error in one internal node operation that checks that the a dimension have only one dynamic shape.
        quantized_decomposed_quantize_per_tensor_default_4: "i8[s0, 2, 7 - s2, 1]" = executorch_exir_dialects_edge__ops_quantized_decomposed_quantize_per_tensor_default(aten_unsqueeze_copy_default_1, 0.012759864330291748, 55, -128, 127, torch.int8);  aten_unsqueeze_copy_default_1 = None

which is right since s2 was replaced with 3, but the change was not propagated to all internal nodes.

Differential Revision: D65120377
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D65120377

…ake tensor using fake_tensor_mode.from_real_tensor (pytorch#6550)

Summary:

re-generating the inputs (the fake tensors from real tensors) can change some dimension from static to dynamic, this does not sounds to me to be part of the intention of those custom passes .
But this can have complication, for details of the issue read below, what i suggest here is just read the meta['val'] from the input graph instead of regenerating a new fake tensor. 

a failure here https://www.internalfb.com/diff/D65023233 that is related to executorch. 

0) one of the passes changes the dimension of the one of the inputs from [2, 2, 3, 1] to f32[s0, 2, 7 - s2] (because calling from fake_tensor_mode.from_real_tensor can do that)

1) after running passes execuotorch revert the changes of the meta['val] values for all inputs to match the old graph values before the pass did run. (https://www.internalfb.com/code/fbsource/[92156447ae2c]/xplat/executorch/exir/pass_base.py?lines=688)

2) But executorch only do that for inputs and not for the internal nodes of the graph.

3) in this case that one of the inputs from:
   
``` def forward(self, p_conv1_bias: "f32[2]", p_conv2_bias: "f32[2]", `b__frozen_param0: "i8[2, 2, s2, 1]", b__frozen_param1: "i8[2, 2, s2, 1]", x: "f32[s0, 2, 4]"):```

to 
    ```def forward(self, p_conv1_bias: "f32[2]", p_conv2_bias: "f32[2]", b__frozen_param0: "i8[2, 2, 3, 1]", b__frozen_param1: "i8[2, 2, 3, 1]", x: "f32[s0, 2, 4]"):```

replacing every s2 with 3 in the place holders only **but executorch do not apply the changes back to internal nodes** we we still have i8[s0, 2, 7 - s2, 1] in the graph (s2 coming from no where now!)
5) executorch runs more passes on this (ruined graph) 
6) we get an error in one internal node operation that checks that the a dimension have only one dynamic shape.
        quantized_decomposed_quantize_per_tensor_default_4: "i8[s0, 2, 7 - s2, 1]" = executorch_exir_dialects_edge__ops_quantized_decomposed_quantize_per_tensor_default(aten_unsqueeze_copy_default_1, 0.012759864330291748, 55, -128, 127, torch.int8);  aten_unsqueeze_copy_default_1 = None

which is right since s2 was replaced with 3, but the change was not propagated to all internal nodes.

Differential Revision: D65120377
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D65120377

@facebook-github-bot facebook-github-bot merged commit c8a3918 into pytorch:main Oct 30, 2024
41 checks passed
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 Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants