Convert fake tensors to detected fake mode in pattern matcher replace_by_example#176938
Convert fake tensors to detected fake mode in pattern matcher replace_by_example#176938frgossen wants to merge 4 commits intogh/frgossen/4/basefrom
Conversation
…_by_example When running pre-grad passes outside the `fake_mode` wrapper in `compile_fx`, the fake tensors attached to graph nodes can belong to a different fake mode than the one active during pattern replacement tracing. This mismatch triggers the "Mixing fake modes NYI" assertion. Fix this by detecting the fake mode from the example values in `Match.replace_by_example` and converting any fake tensors into that mode before calling `trace_fn`. This removes the need for the `wrapped_run_pre_grad_passes` shim in `compile_fx` that previously papered over the problem by restoring the original fake mode. [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/176938
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (3 Unrelated Failures)As of commit e616cfd with merge base e45dfba ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following job failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…_by_example When running pre-grad passes outside the `fake_mode` wrapper in `compile_fx`, the fake tensors attached to graph nodes can belong to a different fake mode than the one active during pattern replacement tracing. This mismatch triggers the "Mixing fake modes NYI" assertion. Fix this by detecting the fake mode from the example values in `Match.replace_by_example` and converting any fake tensors into that mode before calling `trace_fn`. This removes the need for the `wrapped_run_pre_grad_passes` shim in `compile_fx` that previously papered over the problem by restoring the original fake mode. ghstack-source-id: c5c06e4 Pull Request resolved: #176938
This PR needs a
|
zou3519
left a comment
There was a problem hiding this comment.
seems reasonable modulo the fx.map_arg comment
…her replace_by_example" When running pre-grad passes outside the `fake_mode` wrapper in `compile_fx`, the fake tensors attached to graph nodes can belong to a different fake mode than the one active during pattern replacement tracing. This mismatch triggers the "Mixing fake modes NYI" assertion. Fix this by detecting the fake mode from the example values in `Match.replace_by_example` and converting any fake tensors into that mode before calling `trace_fn`. This removes the need for the `wrapped_run_pre_grad_passes` shim in `compile_fx` that previously papered over the problem by restoring the original fake mode. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo [ghstack-poisoned]
…_by_example When running pre-grad passes outside the `fake_mode` wrapper in `compile_fx`, the fake tensors attached to graph nodes can belong to a different fake mode than the one active during pattern replacement tracing. This mismatch triggers the "Mixing fake modes NYI" assertion. Fix this by detecting the fake mode from the example values in `Match.replace_by_example` and converting any fake tensors into that mode before calling `trace_fn`. This removes the need for the `wrapped_run_pre_grad_passes` shim in `compile_fx` that previously papered over the problem by restoring the original fake mode. ghstack-source-id: 33be38c Pull Request resolved: #176938
…her replace_by_example" When running pre-grad passes outside the `fake_mode` wrapper in `compile_fx`, the fake tensors attached to graph nodes can belong to a different fake mode than the one active during pattern replacement tracing. This mismatch triggers the "Mixing fake modes NYI" assertion. Fix this by detecting the fake mode from the example values in `Match.replace_by_example` and converting any fake tensors into that mode before calling `trace_fn`. This removes the need for the `wrapped_run_pre_grad_passes` shim in `compile_fx` that previously papered over the problem by restoring the original fake mode. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo [ghstack-poisoned]
…_by_example When running pre-grad passes outside the `fake_mode` wrapper in `compile_fx`, the fake tensors attached to graph nodes can belong to a different fake mode than the one active during pattern replacement tracing. This mismatch triggers the "Mixing fake modes NYI" assertion. Fix this by detecting the fake mode from the example values in `Match.replace_by_example` and converting any fake tensors into that mode before calling `trace_fn`. This removes the need for the `wrapped_run_pre_grad_passes` shim in `compile_fx` that previously papered over the problem by restoring the original fake mode. ghstack-source-id: 6654245 Pull Request resolved: #176938
…her replace_by_example" When running pre-grad passes outside the `fake_mode` wrapper in `compile_fx`, the fake tensors attached to graph nodes can belong to a different fake mode than the one active during pattern replacement tracing. This mismatch triggers the "Mixing fake modes NYI" assertion. Fix this by detecting the fake mode from the example values in `Match.replace_by_example` and converting any fake tensors into that mode before calling `trace_fn`. This removes the need for the `wrapped_run_pre_grad_passes` shim in `compile_fx` that previously papered over the problem by restoring the original fake mode. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo [ghstack-poisoned]
…_by_example When running pre-grad passes outside the `fake_mode` wrapper in `compile_fx`, the fake tensors attached to graph nodes can belong to a different fake mode than the one active during pattern replacement tracing. This mismatch triggers the "Mixing fake modes NYI" assertion. Fix this by detecting the fake mode from the example values in `Match.replace_by_example` and converting any fake tensors into that mode before calling `trace_fn`. This removes the need for the `wrapped_run_pre_grad_passes` shim in `compile_fx` that previously papered over the problem by restoring the original fake mode. ghstack-source-id: e36bc0a Pull Request resolved: #176938
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Stack from ghstack (oldest at bottom):
When running pre-grad passes outside the
fake_modewrapper incompile_fx, the fake tensors attached to graph nodes can belong to adifferent fake mode than the one active during pattern replacement
tracing. This mismatch triggers the "Mixing fake modes NYI" assertion.
Fix this by detecting the fake mode from the example values in
Match.replace_by_exampleand converting any fake tensors into thatmode before calling
trace_fn. This removes the need for thewrapped_run_pre_grad_passesshim incompile_fxthat previouslypapered over the problem by restoring the original fake mode.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo