Uploaded image for project: 'AI Platform Core Components'
  1. AI Platform Core Components
  2. AIPCC-7171

[dynamo] [dynamic] `nn.LazyLinear` reject SymInt when direct using `torch.compile()`

    • Icon: Story Story
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • None
    • PyTorch
    • PyTorch Sprint 19

          1. 🐛 Describe the bug

      ```python
      import torch
      import torch.nn as nn
      import torch.nn.functional as F
      from torch._inductor import config

      config.fallback_random = True
      torch.set_grad_enabled(False)
      torch._dynamo.config.capture_scalar_outputs = True

      class Model(nn.Module):

      def _init_(self):
      super()._init_()
      self.lazy_fc = nn.LazyLinear(out_features=128)

      def forward(self, x):
      x = self.lazy_fc
      return x

      model = Model()

      x = torch.randn(1, 28, 28)

      inputs = [x]

      device = "cpu"
      def run_test(model, inputs, device, backend):
      torch.manual_seed(0)
      model.to(device)
      inputs = [input.to(device) for input in inputs]
      if backend != "eager":
      model = torch.compile(model, backend=backend, dynamic=True)
      try:
      output = model(*inputs)
      print(f"succeed on

      {backend}

      ")
      except Exception as e:
      print(e)

      run_test(model, inputs, device, 'aot_eager')
      run_test(model, inputs, device, 'eager')

      ```

      If we first use eager to initialize lazylinear (i.e., swap the position of the last two lines of code), dynamo can catch `in_features` and run successfully.

          1. Error logs

      ```
      RuntimeError: /pytorch/build/aten/src/ATen/RegisterCPU_1.cpp:2512: SymIntArrayRef expected to contain only concrete integers
      succeed on eager
      ```

          1. Versions

      2.10.0.dev20251103+cu126

      cc @chauhang @penguinwu

              rh-ee-krastogi Kushagra Rastogi
              rh-ee-krastogi Kushagra Rastogi
              PyTorch Compile
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: