# FX

**URL:** https://dev-discuss.pytorch.org/c/compiler/fx/9.md

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

---

## [About the FX category](https://dev-discuss.pytorch.org/t/about-the-fx-category/18)

<div class="topic-metadata">

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

</div>

All topics about torch.fx, it’s current and future.

---

## [How to get graph weights in torch compile with custom backend?](https://dev-discuss.pytorch.org/t/how-to-get-graph-weights-in-torch-compile-with-custom-backend/3285)

<div class="topic-metadata">

**Author:** [@RunnerZhong](https://dev-discuss.pytorch.org/u/RunnerZhong)\
**Replies:** 1\
**Last updated:** [January 27, 2026, 10:53pm UTC](https://dev-discuss.pytorch.org/t/how-to-get-graph-weights-in-torch-compile-with-custom-backend/3285 "2026-01-27T22:53:57Z")

</div>

In custom backend fx graph, all weights or parameters are lifted to placeholder type. And how can I get the weights/parameters origin value in this FX graph ? I want to do something in custom backend during compile.

---

## [Export\_memory\_timeline doesn't work with torch.profile](https://dev-discuss.pytorch.org/t/export-memory-timeline-doesnt-work-with-torch-profile/3143)

<div class="topic-metadata">

**Author:** [@nimisha](https://dev-discuss.pytorch.org/u/nimisha)\
**Replies:** 0\
**Last updated:** [July 23, 2025, 6:21am UTC](https://dev-discuss.pytorch.org/t/export-memory-timeline-doesnt-work-with-torch-profile/3143 "2025-07-23T06:21:40Z")

</div>

When using PyTorch Profiler’s export\_memory\_timeline on a standard (eager-mode) model, the resulting HTML visualization displays memory allocations with distinct colors and labels—parameters and activations are clearly i…

---

## [Detect shared weights across subgraphs in torch.compile](https://dev-discuss.pytorch.org/t/detect-shared-weights-across-subgraphs-in-torch-compile/3058)

<div class="topic-metadata">

**Author:** [@nimisha](https://dev-discuss.pytorch.org/u/nimisha)\
**Replies:** 2\
**Last updated:** [June 23, 2025, 7:26am UTC](https://dev-discuss.pytorch.org/t/detect-shared-weights-across-subgraphs-in-torch-compile/3058 "2025-06-23T07:26:33Z")

</div>

I have a model that shares the same weight tensor across multiple layers. After compiling the model, it’s split into three subgraphs, and that shared weight appears in both the first and third subgraphs. In my custom bac…

---

## [Empty tensor with SymInt size](https://dev-discuss.pytorch.org/t/empty-tensor-with-symint-size/2909)

<div class="topic-metadata">

**Author:** [@nimisha](https://dev-discuss.pytorch.org/u/nimisha)\
**Replies:** 1\
**Last updated:** [April 15, 2025, 11:12am UTC](https://dev-discuss.pytorch.org/t/empty-tensor-with-symint-size/2909 "2025-04-15T11:12:01Z")

</div>

I am currently working on a custom pass in PyTorch FX, where I need to create an empty tensor whose shape matches the output shape of a specific node. However, I am encountering an issue because the shape of the node in …

---

## [No CPU backend in triton](https://dev-discuss.pytorch.org/t/no-cpu-backend-in-triton/2599)

<div class="topic-metadata">

**Author:** [@zero000064](https://dev-discuss.pytorch.org/u/zero000064)\
**Replies:** 4\
**Last updated:** [January 20, 2025, 9:04pm UTC](https://dev-discuss.pytorch.org/t/no-cpu-backend-in-triton/2599 "2025-01-20T21:04:54Z")

</div>

I’m reproducing a test failure in my pull request, https://hud.pytorch.org/pr/pytorch/pytorch/139141#33075326227, a triton failure in CPU backend. BUt my triton doesn’t have CPU backend, so I couldn’t test it. Here’s C…

---

## [Defining the Core ATen Opset](https://dev-discuss.pytorch.org/t/defining-the-core-aten-opset/1464)

<div class="topic-metadata">

**Author:** [@SS-JIA](https://dev-discuss.pytorch.org/u/SS-JIA)\
**Replies:** 12\
**Last updated:** [August 21, 2024, 3:51am UTC](https://dev-discuss.pytorch.org/t/defining-the-core-aten-opset/1464 "2024-08-21T03:51:02Z")

</div>

TL;DR Folks from across Meta internal PyTorch Core, PyTorch Edge, and PyTorch Compiler teams collaborated to review a list of commonly used ATen operators and discussed whether each should be added to the core ATen opera…

---

## [Connecting PyTorch sparse tensors with MLIR](https://dev-discuss.pytorch.org/t/connecting-pytorch-sparse-tensors-with-mlir/1803)

<div class="topic-metadata">

**Author:** [@aartbik](https://dev-discuss.pytorch.org/u/aartbik)\
**Replies:** 4\
**Last updated:** [August 8, 2024, 6:01pm UTC](https://dev-discuss.pytorch.org/t/connecting-pytorch-sparse-tensors-with-mlir/1803 "2024-08-08T18:01:06Z")

</div>

Greetings! First time poster in this forum, after incorrectly starting the topic in the user forum. I won’t repeat those postings here (since I hope you will read them there), but in a nutshell, the MLIR Sparsifier team…

---

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

<div class="topic-metadata">

**Author:** [@TharinduRusira](https://dev-discuss.pytorch.org/u/TharinduRusira)\
**Replies:** 0\
**Last updated:** [July 26, 2024, 8:04pm UTC](https://dev-discuss.pytorch.org/t/understanding-torch-fx-traceback-preserve-node-meta/2321 "2024-07-26T20:04:36Z")

</div>

I previously posted this topic on PyTorch Forums but I think this is a topic best suited for the dev forum. I’m trying to understand the scope of torch.fx.traceback.preserve\_node\_meta(). Can someone please explain the s…

---

## [Compiled autograd with custom ops error](https://dev-discuss.pytorch.org/t/compiled-autograd-with-custom-ops-error/2295)

<div class="topic-metadata">

**Author:** [@tdomagal](https://dev-discuss.pytorch.org/u/tdomagal)\
**Replies:** 1\
**Last updated:** [July 19, 2024, 8:55am UTC](https://dev-discuss.pytorch.org/t/compiled-autograd-with-custom-ops-error/2295 "2024-07-19T08:55:01Z")

</div>

I try to use custom op implementation with enabled compiled autograd and enabled autocast. My op forward and backward are decorated with torch.cuda.amp decorators: custom\_bwd, custom\_fwd Receiving the following error: …

---

## [Different points at which fusion occurs?](https://dev-discuss.pytorch.org/t/different-points-at-which-fusion-occurs/2099)

<div class="topic-metadata">

**Author:** [@Amogh](https://dev-discuss.pytorch.org/u/Amogh)\
**Replies:** 8\
**Last updated:** [May 21, 2024, 10:26pm UTC](https://dev-discuss.pytorch.org/t/different-points-at-which-fusion-occurs/2099 "2024-05-21T22:26:04Z")

</div>

I understand that can\_fuse and scores\_fusion are responsible for fusion of buffers at the Inductor IR level. But I also see some fusions in the fx\_passes before the lowering to Inductor IR goes through. Can someone clari…

---

## [Is there a plan for FX in a C++ IR?](https://dev-discuss.pytorch.org/t/is-there-a-plan-for-fx-in-a-c-ir/1889)

<div class="topic-metadata">

**Author:** [@Sujoy\_Saraswati](https://dev-discuss.pytorch.org/u/Sujoy_Saraswati)\
**Replies:** 2\
**Last updated:** [February 28, 2024, 3:39pm UTC](https://dev-discuss.pytorch.org/t/is-there-a-plan-for-fx-in-a-c-ir/1889 "2024-02-28T15:39:21Z")

</div>

Hi, Is there a way to consume the FX graphs directly from C++? As per How to get the computation graph and pass it to C++? - #2 by James\_Reed - FX (Functional Transformations) - PyTorch Forums, there was no plan for thi…

---

## [How to trace torch.autograd.backward or torch.autograd.grad?](https://dev-discuss.pytorch.org/t/how-to-trace-torch-autograd-backward-or-torch-autograd-grad/1684)

<div class="topic-metadata">

**Author:** [@botbw](https://dev-discuss.pytorch.org/u/botbw)\
**Replies:** 3\
**Last updated:** [December 5, 2023, 9:40am UTC](https://dev-discuss.pytorch.org/t/how-to-trace-torch-autograd-backward-or-torch-autograd-grad/1684 "2023-12-05T09:40:53Z")

</div>

Hi there, I would like to trace the backward graph, which has multiple outputs (stage\_output) and inputs (input\_values), and some of outputs require grad (specified by outputs\_with\_grads\_idxs, which looks like below and …

---

## [Why is silu\_backward decomposed in fx graph trace?](https://dev-discuss.pytorch.org/t/why-is-silu-backward-decomposed-in-fx-graph-trace/1319)

<div class="topic-metadata">

**Author:** [@liufengwei0103](https://dev-discuss.pytorch.org/u/liufengwei0103)\
**Replies:** 4\
**Last updated:** [June 21, 2023, 1:18am UTC](https://dev-discuss.pytorch.org/t/why-is-silu-backward-decomposed-in-fx-graph-trace/1319 "2023-06-21T01:18:50Z")

</div>

When I tried to trace silu and silu\_backward by below code import torch import torch.nn as nn from torch.fx.experimental.proxy\_tensor import ProxyTorchDispatchMode, PythonKeyTracer from torch.fx.\_symbolic\_trace import T…

---

## [Backward module does not contains weight's gradients calculation](https://dev-discuss.pytorch.org/t/backward-module-does-not-contains-weights-gradients-calculation/1332)

<div class="topic-metadata">

**Author:** [@ConnollyLeon](https://dev-discuss.pytorch.org/u/ConnollyLeon)\
**Replies:** 0\
**Last updated:** [June 16, 2023, 8:10am UTC](https://dev-discuss.pytorch.org/t/backward-module-does-not-contains-weights-gradients-calculation/1332 "2023-06-16T08:10:19Z")

</div>

I am trying to analyze the training procedure by utilizing torch.fx and aot\_autograd. However, with pytorch 2.0, I cannot capture the gradient calculation of weights. PyTorch 1.11.0 + functorch 0.1.0 As you can see in …

---

## [How to customize tracing granularity for GraphAppendingTracer?](https://dev-discuss.pytorch.org/t/how-to-customize-tracing-granularity-for-graphappendingtracer/1049)

<div class="topic-metadata">

**Author:** [@tq-zhang](https://dev-discuss.pytorch.org/u/tq-zhang)\
**Replies:** 0\
**Last updated:** [February 13, 2023, 6:46am UTC](https://dev-discuss.pytorch.org/t/how-to-customize-tracing-granularity-for-graphappendingtracer/1049 "2023-02-13T06:46:22Z")

</div>

hi guys, is there any possible way to control the tracing granularity when using GraphAppendingTracer? I find this example will trace through everything, but if I got some functions or modules need to be wrapped using to…

---

## [Dynamo/FX: patching a function to add more outputs not working](https://dev-discuss.pytorch.org/t/dynamo-fx-patching-a-function-to-add-more-outputs-not-working/866)

<div class="topic-metadata">

**Author:** [@nunoplopes](https://dev-discuss.pytorch.org/u/nunoplopes)\
**Replies:** 2\
**Last updated:** [November 21, 2022, 7:06pm UTC](https://dev-discuss.pytorch.org/t/dynamo-fx-patching-a-function-to-add-more-outputs-not-working/866 "2022-11-21T19:06:02Z")

</div>

Hi, I’ve been playing a bit with Dynamo+FX and I wanted to prototype a transformation that increases the number of outputs of a graph. Example: import operator from typing import List import torch import torch.\_dynamo…
