Repository: pytorch
Issue: Tensor Parallel doesn't work with torch.compile
Labels: oncall: distributed,triaged,oncall: pt2,module: dtensor,pt2d-triage-nov2024

### 🐛 Describe the bug

torch 2.0.1 column parallel output is not sharded (not sure why the documentation is wrong), which seems to be fixed/matching with documentation in 2.1.0 and 2.2.0 (nightly versions). But in those nightly versions torch.compile fails for the provided toy example: https://github.com/pytorch/examples/blob/cead596caa90600188e1055cd9166ab4e7dfd303/distributed/tensor_parallelism/tensor_parallel_example.py. 

Is there a simple working example with tensor parallel and torch.compile()?

### Error logs

Running basic Megatron style TP example on rank 0.
Running basic Megatron style TP example on rank 1.
Traceback (most recent call last):
  File "/home/srikanth.m/pt2_llama/tp_toy.py", line 90, in <module>
    mp.spawn(demo_tp, args=(args,), nprocs=args.world_size, join=True)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/multiprocessing/spawn.py", line 246, in spawn
    return start_processes(fn, args, nprocs, join, daemon, start_method="spawn")
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/multiprocessing/spawn.py", line 202, in start_processes
    while not context.join():
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/multiprocessing/spawn.py", line 163, in join
    raise ProcessRaisedException(msg, error_index, failed_process.pid)
torch.multiprocessing.spawn.ProcessRaisedException: 

-- Process 1 terminated with the following error:
Traceback (most recent call last):
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/multiprocessing/spawn.py", line 74, in _wrap
    fn(i, *args)
  File "/home/srikanth.m/pt2_llama/tp_toy.py", line 71, in demo_tp
    output = model(inp)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 338, in _fn
    return fn(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 500, in catch_errors
    return callback(frame, cache_entry, hooks, frame_state)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 634, in _convert_frame
    result = inner_convert(frame, cache_entry, hooks, frame_state)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 140, in _fn
    return fn(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 382, in _convert_frame_assert
    return _compile(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 562, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 189, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 484, in compile_inner
    out_code = transform_code_object(code, transform)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1028, in transform_code_object
    transformations(instructions, code_options)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 451, in transform
    tracer.run()
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2088, in run
    super().run()
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 728, in run
    and self.step()
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 691, in step
    getattr(self, inst.opname)(inst)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2176, in RETURN_VALUE
    self.output.compile_subgraph(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 872, in compile_subgraph
    self.compile_and_call_fx_graph(tx, list(reversed(stack_values)), root)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 999, in compile_and_call_fx_graph
    compiled_fn = self.call_user_compiler(gm)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 189, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 1066, in call_user_compiler
    raise BackendCompilerFailed(self.compiler_fn, e).with_traceback(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 1051, in call_user_compiler
    compiled_fn = compiler_fn(gm, self.example_inputs())
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/repro/after_dynamo.py", line 117, in debug_wrapper
    compiled_gm = compiler_fn(gm, example_inputs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/__init__.py", line 1568, in __call__
    return compile_fx(model_, inputs_, config_patches=self.config)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 1143, in compile_fx
    return aot_autograd(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/backends/common.py", line 55, in compiler_fn
    cg = aot_module_simplified(gm, example_inputs, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 3891, in aot_module_simplified
    compiled_fn = create_aot_dispatcher_function(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 189, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 3379, in create_aot_dispatcher_function
    fw_metadata = run_functionalized_fw_and_collect_metadata(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 757, in inner
    flat_f_outs = f(*flat_f_args)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 3496, in functional_call
    out = Interpreter(mod).run(*args[params_len:], **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/fx/interpreter.py", line 138, in run
    self.env[node] = self.run_node(node)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/fx/interpreter.py", line 195, in run_node
    return getattr(self, n.op)(n.target, args, kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/fx/interpreter.py", line 267, in call_function
    return target(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_tensor.py", line 1386, in __torch_function__
    ret = func(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/distributed/_tensor/api.py", line 241, in __torch_dispatch__
    return op_dispatch.operator_dispatch(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/distributed/_tensor/dispatch.py", line 109, in operator_dispatch
    out, _, _ = _operator_dispatch(op_call, args, kwargs, sharding_propagator)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/distributed/_tensor/dispatch.py", line 265, in _operator_dispatch
    local_results = op_call(*local_tensor_args, **local_tensor_kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_ops.py", line 448, in __call__
    return self._op(*args, **kwargs or {})
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/utils/_stats.py", line 20, in wrapper
    return fn(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_subclasses/fake_tensor.py", line 1290, in __torch_dispatch__
    return self.dispatch(func, types, args, kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_subclasses/fake_tensor.py", line 1421, in dispatch
    ) = self.validate_and_convert_non_fake_tensors(func, converter, args, kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_subclasses/fake_tensor.py", line 1642, in validate_and_convert_non_fake_tensors
    args, kwargs = tree_map_only(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/utils/_pytree.py", line 362, in tree_map_only
    return tree_map(map_only(ty)(fn), pytree)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/utils/_pytree.py", line 292, in tree_map
    return tree_unflatten([fn(i) for i in flat_args], spec)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/utils/_pytree.py", line 292, in <listcomp>
    return tree_unflatten([fn(i) for i in flat_args], spec)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/utils/_pytree.py", line 343, in inner
    return f(x)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_subclasses/fake_tensor.py", line 1632, in validate
    raise Exception(
torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
Exception: Please convert all Tensors to FakeTensors first or instantiate FakeTensorMode with 'allow_non_fake_inputs'. Found in aten.addmm.default(FakeTensor(..., device='cuda:1', size=(16,)), _to_functional_tensor(FakeTensor(..., device='cuda:1', size=(20, 10)),
       device='cuda:1'), FakeTensor(..., device='cuda:1', size=(10, 16)))

While executing %linear : [num_users=1] = call_function[target=torch._C._nn.linear](args = (%prim_from_local, %l_self_net1_weight, %l_self_net1_bias), kwargs = {})
Original traceback:
  File "/home/srikanth.m/pt2_llama/utils.py", line 41, in forward
    return self.net2(self.relu(self.net1(x)))
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1568, in _call_impl
    result = forward_call(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/linear.py", line 114, in forward
    return F.linear(input, self.weight, self.bias)


Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information


You can suppress this exception and fall back to eager by setting:
    import torch._dynamo
    torch._dynamo.config.suppress_errors = True


### Minified repro

TORCHDYNAMO_VERBOSE=1 python tp_toy.py --compile
Running basic Megatron style TP example on rank 0.
Running basic Megatron style TP example on rank 1.
Traceback (most recent call last):
  File "/home/srikanth.m/pt2_llama/tp_toy.py", line 90, in <module>
    mp.spawn(demo_tp, args=(args,), nprocs=args.world_size, join=True)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/multiprocessing/spawn.py", line 246, in spawn
    return start_processes(fn, args, nprocs, join, daemon, start_method="spawn")
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/multiprocessing/spawn.py", line 202, in start_processes
    while not context.join():
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/multiprocessing/spawn.py", line 163, in join
    raise ProcessRaisedException(msg, error_index, failed_process.pid)
torch.multiprocessing.spawn.ProcessRaisedException: 

-- Process 0 terminated with the following error:
Traceback (most recent call last):
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/multiprocessing/spawn.py", line 74, in _wrap
    fn(i, *args)
  File "/home/srikanth.m/pt2_llama/tp_toy.py", line 71, in demo_tp
    output = model(inp)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 338, in _fn
    return fn(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 500, in catch_errors
    return callback(frame, cache_entry, hooks, frame_state)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 634, in _convert_frame
    result = inner_convert(frame, cache_entry, hooks, frame_state)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 140, in _fn
    return fn(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 382, in _convert_frame_assert
    return _compile(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 562, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 189, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 484, in compile_inner
    out_code = transform_code_object(code, transform)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1028, in transform_code_object
    transformations(instructions, code_options)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 451, in transform
    tracer.run()
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2088, in run
    super().run()
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 728, in run
    and self.step()
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 691, in step
    getattr(self, inst.opname)(inst)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2176, in RETURN_VALUE
    self.output.compile_subgraph(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 872, in compile_subgraph
    self.compile_and_call_fx_graph(tx, list(reversed(stack_values)), root)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 999, in compile_and_call_fx_graph
    compiled_fn = self.call_user_compiler(gm)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 189, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 1066, in call_user_compiler
    raise BackendCompilerFailed(self.compiler_fn, e).with_traceback(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 1051, in call_user_compiler
    compiled_fn = compiler_fn(gm, self.example_inputs())
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/repro/after_dynamo.py", line 117, in debug_wrapper
    compiled_gm = compiler_fn(gm, example_inputs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/__init__.py", line 1568, in __call__
    return compile_fx(model_, inputs_, config_patches=self.config)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_inductor/compile_fx.py", line 1143, in compile_fx
    return aot_autograd(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/backends/common.py", line 55, in compiler_fn
    cg = aot_module_simplified(gm, example_inputs, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 3891, in aot_module_simplified
    compiled_fn = create_aot_dispatcher_function(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 189, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 3379, in create_aot_dispatcher_function
    fw_metadata = run_functionalized_fw_and_collect_metadata(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 757, in inner
    flat_f_outs = f(*flat_f_args)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_functorch/aot_autograd.py", line 3496, in functional_call
    out = Interpreter(mod).run(*args[params_len:], **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/fx/interpreter.py", line 138, in run
    self.env[node] = self.run_node(node)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/fx/interpreter.py", line 195, in run_node
    return getattr(self, n.op)(n.target, args, kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/fx/interpreter.py", line 267, in call_function
    return target(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_tensor.py", line 1386, in __torch_function__
    ret = func(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/distributed/_tensor/api.py", line 241, in __torch_dispatch__
    return op_dispatch.operator_dispatch(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/distributed/_tensor/dispatch.py", line 109, in operator_dispatch
    out, _, _ = _operator_dispatch(op_call, args, kwargs, sharding_propagator)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/distributed/_tensor/dispatch.py", line 265, in _operator_dispatch
    local_results = op_call(*local_tensor_args, **local_tensor_kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_ops.py", line 448, in __call__
    return self._op(*args, **kwargs or {})
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/utils/_stats.py", line 20, in wrapper
    return fn(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_subclasses/fake_tensor.py", line 1290, in __torch_dispatch__
    return self.dispatch(func, types, args, kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_subclasses/fake_tensor.py", line 1421, in dispatch
    ) = self.validate_and_convert_non_fake_tensors(func, converter, args, kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_subclasses/fake_tensor.py", line 1642, in validate_and_convert_non_fake_tensors
    args, kwargs = tree_map_only(
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/utils/_pytree.py", line 362, in tree_map_only
    return tree_map(map_only(ty)(fn), pytree)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/utils/_pytree.py", line 292, in tree_map
    return tree_unflatten([fn(i) for i in flat_args], spec)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/utils/_pytree.py", line 292, in <listcomp>
    return tree_unflatten([fn(i) for i in flat_args], spec)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/utils/_pytree.py", line 343, in inner
    return f(x)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/_subclasses/fake_tensor.py", line 1632, in validate
    raise Exception(
torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
Exception: Please convert all Tensors to FakeTensors first or instantiate FakeTensorMode with 'allow_non_fake_inputs'. Found in aten.addmm.default(FakeTensor(..., device='cuda:0', size=(16,)), _to_functional_tensor(FakeTensor(..., device='cuda:0', size=(20, 10)),
       device='cuda:0'), FakeTensor(..., device='cuda:0', size=(10, 16)))

While executing %linear : [num_users=1] = call_function[target=torch._C._nn.linear](args = (%prim_from_local, %l_self_net1_weight, %l_self_net1_bias), kwargs = {})
Original traceback:
  File "/home/srikanth.m/pt2_llama/utils.py", line 41, in forward
    return self.net2(self.relu(self.net1(x)))
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1568, in _call_impl
    result = forward_call(*args, **kwargs)
  File "/home/srikanth.m/anaconda3/envs/dl_env/lib/python3.10/site-packages/torch/nn/modules/linear.py", line 114, in forward
    return F.linear(input, self.weight, self.bias)



You can suppress this exception and fall back to eager by setting:
    import torch._dynamo
    torch._dynamo.config.suppress_errors = True


### Versions

Collecting environment information...
PyTorch version: 2.2.0.dev20230907+cu118
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.27.0
Libc version: glibc-2.35

Python version: 3.10.12 (main, Jul  5 2023, 18:54:27) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-78-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: H100 80GB HBM3
GPU 1: H100 80GB HBM3
GPU 2: H100 80GB HBM3
GPU 3: H100 80GB HBM3
GPU 4: H100 80GB HBM3
GPU 5: H100 80GB HBM3
GPU 6: H100 80GB HBM3
GPU 7: H100 80GB HBM3

Nvidia driver version: 520.61.05
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.4
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.4
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.4
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.4
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.4
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.4
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.4
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn.so.8.9.3
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.9.3
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.9.3
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.9.3
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.9.3
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.9.3
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.9.3
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Address sizes:                   46 bits physical, 57 bits virtual
Byte Order:                      Little Endian
CPU(s):                          224
On-line CPU(s) list:             0-223
Vendor ID:                       GenuineIntel
Model name:                      Intel(R) Xeon(R) Platinum 8480+
CPU family:                      6
Model:                           143
Thread(s) per core:              2
Core(s) per socket:              56
Socket(s):                       2
Stepping:                        8
Frequency boost:                 enabled
CPU max MHz:                     2001.0000
CPU min MHz:                     800.0000
BogoMIPS:                        4000.00
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                  VT-x
L1d cache:                       5.3 MiB (112 instances)
L1i cache:                       3.5 MiB (112 instances)
L2 cache:                        224 MiB (112 instances)
L3 cache:                        210 MiB (2 instances)
NUMA node(s):                    2
NUMA node0 CPU(s):               0-55,112-167
NUMA node1 CPU(s):               56-111,168-223
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Not affected
Vulnerability Retbleed:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected

Versions of relevant libraries:
[pip3] numpy==1.25.0
[pip3] pytorch-triton==2.1.0+e6216047b8
[pip3] torch==2.2.0.dev20230907+cu118
[pip3] torch2trt==0.4.0
[pip3] torchvision==0.17.0.dev20230907+cu118
[pip3] triton==2.0.0
[conda] blas                      1.0                         mkl  
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] libjpeg-turbo             2.0.0                h9bf148f_0    pytorch-nightly
[conda] magma-cuda121             2.6.1                         1    pytorch
[conda] mkl                       2023.1.0         h6d00ec8_46342  
[conda] mkl-fft                   1.3.6                    pypi_0    pypi
[conda] mkl-include               2023.1.0         h06a4308_46342  
[conda] mkl-random                1.2.2                    pypi_0    pypi
[conda] mkl-service               2.4.0                    pypi_0    pypi
[conda] mkl_fft                   1.3.6           py310h1128e8f_1  
[conda] mkl_random                1.2.2           py310h1128e8f_1  
[conda] numpy                     1.25.0                   pypi_0    pypi
[conda] numpy-base                1.25.0          py310hb5e798b_0  
[conda] pytorch                   2.2.0.dev20230907    py3.10_cpu_0    pytorch-nightly
[conda] pytorch-cuda              11.8                 h7e8668a_5    pytorch-nightly
[conda] pytorch-mutex             1.0                         cpu    pytorch-nightly
[conda] pytorch-triton            2.1.0+e6216047b8          pypi_0    pypi
[conda] torch                     2.2.0.dev20230907+cu118          pypi_0    pypi
[conda] torch2trt                 0.4.0                    pypi_0    pypi
[conda] torchaudio                2.2.0.dev20230907       py310_cpu    pytorch-nightly
[conda] torchtriton               2.0.0                     py310    pytorch
[conda] torchvision               0.17.0.dev20230907+cu118          pypi_0    pypi
[conda] triton                    2.0.0.post1              pypi_0    pypi


cc @H-Huang @awgu @kwen2501 @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @c-p-i-o @chauhang @penguinwu @tianyu-l @XilunWu @mrshenli @pritamdamania87 @zhaojuanmao @satgera @rohan-varma @gqchen @aazzolini @osalpekar @jiayisuse @ezyang @msaroufim @bdhirsh @anijain2305 @zou3519 @kiukchung @lucasllc