About dynamo.disable

Hi, I have a question about how torch._dynamo.disable behaves inside nested model structures.

In my setup, I have a deeply nested model, and I applied @torch._dynamo.disable to a small inner function at the deepest level.
When I run torch.compile, Dynamo ends up splitting the whole model into many small subgraphs.

I have two related questions:

  1. Why doesn’t Dynamo just split the graph into two parts — one from the beginning of the model up to the entry of the disabled function, and another from right after that function to the end of the model — instead of cutting it into many small pieces?

  2. Is there any way to make Dynamo perform the segmentation in that “two-subgraph” manner (i.e., a single contiguous FX graph before and after the disabled region)?

Thanks!