# FX (Functional Transformations)

**URL:** https://discuss.pytorch.org/c/compile/fx-functional-transformations/31.md

[Latest](https://discuss.pytorch.org/latest.md) · [Categories](https://discuss.pytorch.org/categories.md)

---

## [About the FX (Functional Transformations) category](https://discuss.pytorch.org/t/about-the-fx-functional-transformations-category/112918)

<div class="topic-metadata">

**Author:** [@jspisak](https://discuss.pytorch.org/u/jspisak)\
**Replies:** 0

</div>

FX is a toolkit for developers to use to transform nn.Module instances. FX consists of three main components: a symbolic tracer, an intermediate representation , and Python code generation . The docs can be found here.

---

## [Transformation has broken link between images and masks](https://discuss.pytorch.org/t/transformation-has-broken-link-between-images-and-masks/225120)

<div class="topic-metadata">

**Author:** [@BigToni](https://discuss.pytorch.org/u/BigToni)\
**Replies:** 1\
**Last updated:** [July 24, 2026, 2:20pm UTC](https://discuss.pytorch.org/t/transformation-has-broken-link-between-images-and-masks/225120 "2026-07-24T14:20:15Z")

</div>

I am trying to augment a dataset. I have a dataset of images and masks that match. I run the following code and the masks are no longer matched with the images. What is going on?

---

## [SubgraphMatcher can't be initialized with MOE pattern](https://discuss.pytorch.org/t/subgraphmatcher-cant-be-initialized-with-moe-pattern/224909)

<div class="topic-metadata">

**Author:** [@Piotr\_Wojciechowski](https://discuss.pytorch.org/u/Piotr_Wojciechowski)\
**Replies:** 0\
**Last updated:** [May 7, 2026, 8:23pm UTC](https://discuss.pytorch.org/t/subgraphmatcher-cant-be-initialized-with-moe-pattern/224909 "2026-05-07T20:23:24Z")

</div>

Hello. I’m trying to replace exported Mixtral SparseMLP code with a custom op using fx.replace\_pattern API. However, I’m seeing errors like: “SubgraphMatcher cannot be initialized with an pattern with dead code”. Becaus…

---

## ["Offset increment outside graph capture encountered unexpectedly" is a specific PyTorch Windows issue that's known to occur with CUDA Graphs. This is a bug in PyTorch Windows builds](https://discuss.pytorch.org/t/offset-increment-outside-graph-capture-encountered-unexpectedly-is-a-specific-pytorch-windows-issue-thats-known-to-occur-with-cuda-graphs-this-is-a-bug-in-pytorch-windows-builds/224523)

<div class="topic-metadata">

**Author:** [@Hikmatullah\_Danish](https://discuss.pytorch.org/u/Hikmatullah_Danish)\
**Replies:** 0\
**Last updated:** [February 10, 2026, 1:46pm UTC](https://discuss.pytorch.org/t/offset-increment-outside-graph-capture-encountered-unexpectedly-is-a-specific-pytorch-windows-issue-thats-known-to-occur-with-cuda-graphs-this-is-a-bug-in-pytorch-windows-builds/224523 "2026-02-10T13:46:25Z")

</div>

"Offset increment outside graph capture encountered unexpectedly" is a specific PyTorch Windows issue that’s known to occur with CUDA Graphs. This is a bug in PyTorch Windows builds!

---

## [How to verify that default\_decompositions successfully reduce operators to the Core ATen IR set?](https://discuss.pytorch.org/t/how-to-verify-that-default-decompositions-successfully-reduce-operators-to-the-core-aten-ir-set/224262)

<div class="topic-metadata">

**Author:** [@Tongkai](https://discuss.pytorch.org/u/Tongkai)\
**Replies:** 0\
**Last updated:** [December 30, 2025, 5:11pm UTC](https://discuss.pytorch.org/t/how-to-verify-that-default-decompositions-successfully-reduce-operators-to-the-core-aten-ir-set/224262 "2025-12-30T17:11:01Z")

</div>

Is there a way to test if all ops in default\_decompositions can be fully decomposed into the Core ATen IR (~180 ops) using ep.run\_decompositions, as specified in the Export IR documentation (https://docs.pytorch.org/docs…

---

## [TS2EPConverter and \`dynamic\_shapes\`](https://discuss.pytorch.org/t/ts2epconverter-and-dynamic-shapes/223472)

<div class="topic-metadata">

**Author:** [@olokobayusuf](https://discuss.pytorch.org/u/olokobayusuf)\
**Replies:** 0\
**Last updated:** [October 5, 2025, 2:27pm UTC](https://discuss.pytorch.org/t/ts2epconverter-and-dynamic-shapes/223472 "2025-10-05T14:27:54Z")

</div>

We are working with pipelines where we have to convert pre-existing torch.jit models to downstream AI serving formats (e.g. ONNX, ExecuTorch). The current torch.export.export API does not support these, so instead we use…

---

## [Autofunctionalize v2 / Reinplace](https://discuss.pytorch.org/t/autofunctionalize-v2-reinplace/222984)

<div class="topic-metadata">

**Author:** [@Jerome\_Ku](https://discuss.pytorch.org/u/Jerome_Ku)\
**Replies:** 0\
**Last updated:** [September 9, 2025, 4:53pm UTC](https://discuss.pytorch.org/t/autofunctionalize-v2-reinplace/222984 "2025-09-09T16:53:28Z")

</div>

@bdhirsh On pytorch nightly 2.9.0.dev20250907+cu128, running the following inplace op (see original context) withenable\_auto\_functionalized\_v2 enabled / disabled doesn’t seem to have an effect: import torch import torc…

---

## [How to understand the files generated by TORCH\_COMPILE\_DEBUG](https://discuss.pytorch.org/t/how-to-understand-the-files-generated-by-torch-compile-debug/222854)

<div class="topic-metadata">

**Author:** [@Guitenbay](https://discuss.pytorch.org/u/Guitenbay)\
**Replies:** 0\
**Last updated:** [September 4, 2025, 3:30am UTC](https://discuss.pytorch.org/t/how-to-understand-the-files-generated-by-torch-compile-debug/222854 "2025-09-04T03:30:32Z")

</div>

I use torch.compile to run the resnet50 model. The env are: TORCH\_COMPILE\_DEBUG=1 INDUCTOR\_ORIG\_FX\_SVG=1 INDUCTOR\_POST\_FUSION\_SVG=1 TORCHINDUCTOR\_FX\_GRAPH\_CACHE=0 then I get some files: I know orig\_fx\_graph\_diagram…

---

## [Preserving bits like conj, neg during functionalization](https://discuss.pytorch.org/t/preserving-bits-like-conj-neg-during-functionalization/220768)

<div class="topic-metadata">

**Author:** [@cz2h](https://discuss.pytorch.org/u/cz2h)\
**Replies:** 0\
**Last updated:** [June 12, 2025, 2:59pm UTC](https://discuss.pytorch.org/t/preserving-bits-like-conj-neg-during-functionalization/220768 "2025-06-12T14:59:03Z")

</div>

Hi team, I am looking into \_\_torch\_dispatch\_\_ under functional\_tensor.py. During the forward pass there is logic of cloning arg tensor and call the decomposition function, but the bits like conj/neg are resolved during …

---

## [Why adaptive\_avg\_pool1d became adaptive\_avg\_pool2d in make\_fx?](https://discuss.pytorch.org/t/why-adaptive-avg-pool1d-became-adaptive-avg-pool2d-in-make-fx/219280)

<div class="topic-metadata">

**Author:** [@heshuju](https://discuss.pytorch.org/u/heshuju)\
**Replies:** 1\
**Last updated:** [April 21, 2025, 1:37am UTC](https://discuss.pytorch.org/t/why-adaptive-avg-pool1d-became-adaptive-avg-pool2d-in-make-fx/219280 "2025-04-21T01:37:03Z")

</div>

I need to use the make\_fx interface to output aten ops and convert them into corresponding torch diaclects. But I found that make\_fx will replace some ops. How does this happen and how should I solve it? import torch im…

---

## [How does torch.fx work with activation checkpointing?](https://discuss.pytorch.org/t/how-does-torch-fx-work-with-activation-checkpointing/152913)

<div class="topic-metadata">

**Author:** [@Frank\_Leeeee](https://discuss.pytorch.org/u/Frank_Leeeee)\
**Replies:** 2\
**Last updated:** [February 13, 2025, 3:38am UTC](https://discuss.pytorch.org/t/how-does-torch-fx-work-with-activation-checkpointing/152913 "2025-02-13T03:38:03Z")

</div>

I am wondering how we can use torch.utils.checkpoint together with torch.fx. Simple example is given below: import torch import torch.nn as nn import torch.fx as fx from torch.utils.checkpoint import checkpoint class …

---

## [Torch IR support for torch.exported graph](https://discuss.pytorch.org/t/torch-ir-support-for-torch-exported-graph/216458)

<div class="topic-metadata">

**Author:** [@Sung\_Hyuck\_Hong](https://discuss.pytorch.org/u/Sung_Hyuck_Hong)\
**Replies:** 0\
**Last updated:** [February 10, 2025, 9:50am UTC](https://discuss.pytorch.org/t/torch-ir-support-for-torch-exported-graph/216458 "2025-02-10T09:50:31Z")

</div>

Hello, Is there any plan in PyTorch’s roadmap to enable the retrieval of a GraphModule with Torch IR directly in the future? To the best of my knowledge, tracing the model with torch.export.export directly will result i…

---

## [\[torch.export\] How to disable sym\_size\_int?](https://discuss.pytorch.org/t/torch-export-how-to-disable-sym-size-int/216199)

<div class="topic-metadata">

**Author:** [@Sung\_Hyuck\_Hong](https://discuss.pytorch.org/u/Sung_Hyuck_Hong)\
**Replies:** 2\
**Last updated:** [February 7, 2025, 1:12am UTC](https://discuss.pytorch.org/t/torch-export-how-to-disable-sym-size-int/216199 "2025-02-07T01:12:12Z")

</div>

Hello, I noticed that from torch 2.5, torch.ops.aten.sym\_size\_int is introduced to improve the coverage of dynamic shape support during torch.\_dynamo.export tracing. For example, if the torch code is written as batch\_s…

---

## [Aot\_export\_module captures more forward variables/parameters](https://discuss.pytorch.org/t/aot-export-module-captures-more-forward-variables-parameters/215320)

<div class="topic-metadata">

**Author:** [@sycz00](https://discuss.pytorch.org/u/sycz00)\
**Replies:** 2\
**Last updated:** [January 23, 2025, 9:10am UTC](https://discuss.pytorch.org/t/aot-export-module-captures-more-forward-variables-parameters/215320 "2025-01-23T09:10:36Z")

</div>

Hey folks, I want to capture the forward and backward computation of the swin-transformer. The code below tries to do that and I encountered the following issue: the number of parameters of the model is 173 while the n…

---

## [Combine vmap, func.grad with tensordict](https://discuss.pytorch.org/t/combine-vmap-func-grad-with-tensordict/215086)

<div class="topic-metadata">

**Author:** [@Roy-Kid](https://discuss.pytorch.org/u/Roy-Kid)\
**Replies:** 0\
**Last updated:** [January 7, 2025, 11:48pm UTC](https://discuss.pytorch.org/t/combine-vmap-func-grad-with-tensordict/215086 "2025-01-07T23:48:27Z")

</div>

Hi everyone, I am trying to move my code to tensordict(td) and vmap along batch according to How to apply vmap on a heterogeneous tensor - #5 by soulitzer. Since vmap not support batched tensordict, now I just use batch…

---

## [A node type in export IR graph](https://discuss.pytorch.org/t/a-node-type-in-export-ir-graph/213565)

<div class="topic-metadata">

**Author:** [@mhs4670go](https://discuss.pytorch.org/u/mhs4670go)\
**Replies:** 1\
**Last updated:** [November 28, 2024, 5:20am UTC](https://discuss.pytorch.org/t/a-node-type-in-export-ir-graph/213565 "2024-11-28T05:20:57Z")

</div>

I’m working on graph transformation with export IR graph in ExportedProgram after torch.export.export. When I implemented a pass for the transformation, I had one question about a node type. For example, this constant p…

---

## [Any chance to preserve some ops while decomposing PT2E model?](https://discuss.pytorch.org/t/any-chance-to-preserve-some-ops-while-decomposing-pt2e-model/211859)

<div class="topic-metadata">

**Author:** [@siahuat0727](https://discuss.pytorch.org/u/siahuat0727)\
**Replies:** 1\
**Last updated:** [November 16, 2024, 5:30pm UTC](https://discuss.pytorch.org/t/any-chance-to-preserve-some-ops-while-decomposing-pt2e-model/211859 "2024-11-16T17:30:01Z")

</div>

Hi team, I wonder is there any way to preserve some type of ops while doing decomposition ep.run\_decompositions()? For example, aten.upsample\_nearest2d.vec (div\_5, None, \[2.0, 2.0\]) will convert to: opcode …

---

## [Handling LSTM states as model's inputs/outputs using fx.symbolic\_trace](https://discuss.pytorch.org/t/handling-lstm-states-as-models-inputs-outputs-using-fx-symbolic-trace/212548)

<div class="topic-metadata">

**Author:** [@ir0098](https://discuss.pytorch.org/u/ir0098)\
**Replies:** 0\
**Last updated:** [November 5, 2024, 12:59pm UTC](https://discuss.pytorch.org/t/handling-lstm-states-as-models-inputs-outputs-using-fx-symbolic-trace/212548 "2024-11-05T12:59:14Z")

</div>

I want to modify a simple model having lstm layers in a way that it receives the states as additional inputs and returns updated states as additional outputs. Indeed, it is required to run model in realtime mode for each…

---

## [Torch.fx.symbolic\_trace with multiple GPUs](https://discuss.pytorch.org/t/torch-fx-symbolic-trace-with-multiple-gpus/208732)

<div class="topic-metadata">

**Author:** [@yazanobeidi](https://discuss.pytorch.org/u/yazanobeidi)\
**Replies:** 1\
**Last updated:** [October 29, 2024, 12:30pm UTC](https://discuss.pytorch.org/t/torch-fx-symbolic-trace-with-multiple-gpus/208732 "2024-10-29T12:30:22Z")

</div>

Hi there, I couldn’t find any documentation around this topic. I’d like to torch.fx.symbolic\_trace a large model that exceeds a single GPU memory e.g. LLaMa 405B. I have multiple GPUs. What’s the best way to go about d…

---

## [Is Export IR incompatible with fx.Interpreter?](https://discuss.pytorch.org/t/is-export-ir-incompatible-with-fx-interpreter/211277)

<div class="topic-metadata">

**Author:** [@kmaeng](https://discuss.pytorch.org/u/kmaeng)\
**Replies:** 1\
**Last updated:** [October 8, 2024, 4:13am UTC](https://discuss.pytorch.org/t/is-export-ir-incompatible-with-fx-interpreter/211277 "2024-10-08T04:13:12Z")

</div>

Dear Experts: I am having trouble running Export IR through fx.Interpreter. I thought the two should be compatible because I read that export IR is based on FX IR and also code like torch.export.unflatten.InterpreterMod…

---

## [How to turn a autograd.Function into custom\_ops](https://discuss.pytorch.org/t/how-to-turn-a-autograd-function-into-custom-ops/208579)

<div class="topic-metadata">

**Author:** [@mksit](https://discuss.pytorch.org/u/mksit)\
**Replies:** 0\
**Last updated:** [August 24, 2024, 4:21pm UTC](https://discuss.pytorch.org/t/how-to-turn-a-autograd-function-into-custom-ops/208579 "2024-08-24T16:21:00Z")

</div>

I want to wrap an existing torch.autograd.Function without modifying the internal to a custom operator, but the torch.library.register\_autograd api requires backward and setup\_context functions separately. What is the p…

---

## [‘len’ is not supported in symbolic tracing by default](https://discuss.pytorch.org/t/len-is-not-supported-in-symbolic-tracing-by-default/154940)

<div class="topic-metadata">

**Author:** [@yang\_wang](https://discuss.pytorch.org/u/yang_wang)\
**Replies:** 7\
**Last updated:** [August 22, 2024, 8:53am UTC](https://discuss.pytorch.org/t/len-is-not-supported-in-symbolic-tracing-by-default/154940 "2024-08-22T08:53:35Z")

</div>

Hello, I now have a requirement to parse the yolov3 network constructed by mmdetion. In mmdetion, the yolov3 network is divided into backbone, neck, bbox, and 3 parts. But when I use torch.fx to parse this model, I have …

---

## [Add an input to a model with torch.compile](https://discuss.pytorch.org/t/add-an-input-to-a-model-with-torch-compile/207298)

<div class="topic-metadata">

**Author:** [@Vgmodel](https://discuss.pytorch.org/u/Vgmodel)\
**Replies:** 0\
**Last updated:** [July 31, 2024, 10:11am UTC](https://discuss.pytorch.org/t/add-an-input-to-a-model-with-torch-compile/207298 "2024-07-31T10:11:54Z")

</div>

Hello, I have a PyTorch function that use torch.fx to add a second input to my model and performed some additional operations. Since torch.fx is not handling control flow, I want to use torch.compile with a custom back…

---

## [Noob here ! Need help with "RuntimeError: Input type (torch.FloatTensor)"](https://discuss.pytorch.org/t/noob-here-need-help-with-runtimeerror-input-type-torch-floattensor/206967)

<div class="topic-metadata">

**Author:** [@Hst\_Effr](https://discuss.pytorch.org/u/Hst_Effr)\
**Replies:** 1\
**Last updated:** [July 25, 2024, 2:55pm UTC](https://discuss.pytorch.org/t/noob-here-need-help-with-runtimeerror-input-type-torch-floattensor/206967 "2024-07-25T14:55:59Z")

</div>

Hello everyone, First of all I would like to point out that I am a total noob on python etc, and that I have been trying to understand for 3 days what I am doing. So there you have it, I would like to use the Audio-File…

---

## [Tracking statistics of operators without overwriting forward pass?](https://discuss.pytorch.org/t/tracking-statistics-of-operators-without-overwriting-forward-pass/206678)

<div class="topic-metadata">

**Author:** [@Whisper](https://discuss.pytorch.org/u/Whisper)\
**Replies:** 0\
**Last updated:** [July 22, 2024, 3:12am UTC](https://discuss.pytorch.org/t/tracking-statistics-of-operators-without-overwriting-forward-pass/206678 "2024-07-22T03:12:11Z")

</div>

I’m looking to track output statistics of operators within networks. Take the following network: class Model(nn.Module): def \_\_init\_\_(self): super().\_\_init\_\_() self.fc1 = nn.Linear(3, 3) self.fc2 = nn.Line…

---

## [Understanding torch.fx.traceback.preserve\_node\_meta()](https://discuss.pytorch.org/t/understanding-torch-fx-traceback-preserve-node-meta/205319)

<div class="topic-metadata">

**Author:** [@trusira](https://discuss.pytorch.org/u/trusira)\
**Replies:** 1\
**Last updated:** [July 10, 2024, 5:39pm UTC](https://discuss.pytorch.org/t/understanding-torch-fx-traceback-preserve-node-meta/205319 "2024-07-10T17:39:50Z")

</div>

Hi, I’m trying to understand the scope of torch.fx.traceback.preserve\_node\_meta(). Can someone please explain torch.fx.Node’s meta preservation in the context of the following example? # A simple torch module class Si…

---

## [When should I detect a fake tensor mode?](https://discuss.pytorch.org/t/when-should-i-detect-a-fake-tensor-mode/205660)

<div class="topic-metadata">

**Author:** [@mhs4670go](https://discuss.pytorch.org/u/mhs4670go)\
**Replies:** 1\
**Last updated:** [July 6, 2024, 12:33am UTC](https://discuss.pytorch.org/t/when-should-i-detect-a-fake-tensor-mode/205660 "2024-07-06T00:33:54Z")

</div>

Hello. I’m writing a constant folding pass of the fx graph that is made by torch.export.export. When I update a meta data for newly created nodes, I’m using fake mode like below. new\_node.meta\["val"\] = fake\_mode.from\_…

---

## [FX graph resorting a torch model's positional args based on execution order](https://discuss.pytorch.org/t/fx-graph-resorting-a-torch-models-positional-args-based-on-execution-order/203992)

<div class="topic-metadata">

**Author:** [@ktexb](https://discuss.pytorch.org/u/ktexb)\
**Replies:** 1\
**Last updated:** [June 11, 2024, 3:16pm UTC](https://discuss.pytorch.org/t/fx-graph-resorting-a-torch-models-positional-args-based-on-execution-order/203992 "2024-06-11T15:16:27Z")

</div>

It seems like the order of the args in an FX graph are dependent on the order of execution of the args, rather than however the args were expected in the model definition. Is this expected behaviour? And if it is, how s…

---

## [Fx on split and cat combination](https://discuss.pytorch.org/t/fx-on-split-and-cat-combination/154207)

<div class="topic-metadata">

**Author:** [@Sydney\_Hauke](https://discuss.pytorch.org/u/Sydney_Hauke)\
**Replies:** 1\
**Last updated:** [June 10, 2024, 4:06pm UTC](https://discuss.pytorch.org/t/fx-on-split-and-cat-combination/154207 "2024-06-10T16:06:44Z")

</div>

Hi, I am tracing some model containing a consecutive call to split whose output is then passed to cat : import torch from torch.fx import symbolic\_trace class M(torch.nn.Module): def forward(self, x): y = …

---

## [Node Meta Data not propagated to replaced nodes while using fx subgraph rewrite?](https://discuss.pytorch.org/t/node-meta-data-not-propagated-to-replaced-nodes-while-using-fx-subgraph-rewrite/185517)

<div class="topic-metadata">

**Author:** [@yshnsh](https://discuss.pytorch.org/u/yshnsh)\
**Replies:** 2\
**Last updated:** [June 5, 2024, 6:16am UTC](https://discuss.pytorch.org/t/node-meta-data-not-propagated-to-replaced-nodes-while-using-fx-subgraph-rewrite/185517 "2024-06-05T06:16:01Z")

</div>

I am trying to write custom subgraph rewrite using torch fx subgraph\_rewriter. I see that after the replacement the added nodes do not contain “meta” information. Is there any way to capture these during the pattern matc…

[Next page](https://discuss.pytorch.org/c/compile/fx-functional-transformations/31.md?page=1)
