Torch randn cannot take symbol shapes as shape argument.
Labels: triaged, oncall: pt2, module: dynamic shapes

### 🐛 Describe the bug

torch randn fails stand if the input shape has non-concrete types. This smells like a bug to me though as randn_like would work in this example since it can get the symbolic shape of the tensor. I can post 

### Error logs

```

Error executing job with overrides: []
Traceback (most recent call last):
  File "/diffusion/run.py", line 26, in <module>
    main()
  File "/usr/lib/python3/dist-packages/hydra/main.py", line 94, in decorated_main
    _run_hydra(
  File "/usr/lib/python3/dist-packages/hydra/_internal/utils.py", line 394, in _run_hydra
    _run_app(
  File "/usr/lib/python3/dist-packages/hydra/_internal/utils.py", line 457, in _run_app
    run_and_report(
  File "/usr/lib/python3/dist-packages/hydra/_internal/utils.py", line 223, in run_and_report
    raise ex
  File "/usr/lib/python3/dist-packages/hydra/_internal/utils.py", line 220, in run_and_report
    return func()
  File "/usr/lib/python3/dist-packages/hydra/_internal/utils.py", line 458, in <lambda>
    lambda: hydra.run(
  File "/usr/lib/python3/dist-packages/hydra/_internal/hydra.py", line 132, in run
    _ = ret.return_value
  File "/usr/lib/python3/dist-packages/hydra/core/utils.py", line 260, in return_value
    raise self._return_value
  File "/usr/lib/python3/dist-packages/hydra/core/utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
  File "/diffusion/run.py", line 22, in main
    return train(config)
  File "/diffusion/diffusion/train.py", line 139, in train
    return eval_and_then_train()
  File "/diffusion/diffusion/train.py", line 136, in eval_and_then_train
    trainer.eval()
  File "/usr/lib/python3/dist-packages/composer/trainer/trainer.py", line 2656, in eval
    self._eval_loop(
  File "/usr/lib/python3/dist-packages/composer/trainer/trainer.py", line 2780, in _eval_loop
    self.state.outputs = self._original_model.eval_forward(self.state.batch)
  File "/diffusion/diffusion/models/stable_diffusion.py", line 206, in eval_forward
    unet_out, targets, timesteps = self.forward(batch)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/eval_frame.py", line 333, in _fn
    return fn(*args, **kwargs)
  File "/diffusion/diffusion/models/stable_diffusion.py", line 173, in forward
    latents = self.vae.encode(inputs)['latent_dist'].sample().data
  File "/usr/lib/python3/dist-packages/torch/_dynamo/eval_frame.py", line 493, in catch_errors
    return callback(frame, cache_size, hooks, frame_state)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/convert_frame.py", line 605, in _convert_frame
    result = inner_convert(frame, cache_size, hooks, frame_state)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/convert_frame.py", line 132, in _fn
    return fn(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/convert_frame.py", line 370, in _convert_frame_assert
    return _compile(
  File "/usr/lib/python3/dist-packages/torch/_dynamo/convert_frame.py", line 536, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/utils.py", line 180, in time_wrapper
    r = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/convert_frame.py", line 447, in compile_inner
    out_code = transform_code_object(code, transform)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/bytecode_transformation.py", line 1028, in transform_code_object
    transformations(instructions, code_options)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/convert_frame.py", line 425, in transform
    tracer.run()
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 2071, in run
    super().run()
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 724, in run
    and self.step()
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 688, in step
    getattr(self, inst.opname)(inst)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 392, in wrapper
    return inner_fn(self, inst)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 1115, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 562, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/usr/lib/python3/dist-packages/torch/_dynamo/variables/functions.py", line 307, in call_function
    return super().call_function(tx, args, kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/variables/functions.py", line 261, in call_function
    return super().call_function(tx, args, kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/variables/functions.py", line 90, in call_function
    return tx.inline_user_function_return(
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 598, in inline_user_function_return
    result = InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 2176, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 2283, in inline_call_
    tracer.run()
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 724, in run
    and self.step()
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 688, in step
    getattr(self, inst.opname)(inst)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 392, in wrapper
    return inner_fn(self, inst)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 1167, in CALL_FUNCTION_KW
    self.call_function(fn, args, kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 562, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/usr/lib/python3/dist-packages/torch/_dynamo/variables/functions.py", line 261, in call_function
    return super().call_function(tx, args, kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/variables/functions.py", line 90, in call_function
    return tx.inline_user_function_return(
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 598, in inline_user_function_return
    result = InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 2176, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 2283, in inline_call_
    tracer.run()
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 724, in run
    and self.step()
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 688, in step
    getattr(self, inst.opname)(inst)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 392, in wrapper
    return inner_fn(self, inst)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 1167, in CALL_FUNCTION_KW
    self.call_function(fn, args, kwargs)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/symbolic_convert.py", line 562, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/usr/lib/python3/dist-packages/torch/_dynamo/variables/torch.py", line 716, in call_function
    tensor_variable = wrap_fx_proxy(
  File "/usr/lib/python3/dist-packages/torch/_dynamo/variables/builder.py", line 1163, in wrap_fx_proxy
    return wrap_fx_proxy_cls(
  File "/usr/lib/python3/dist-packages/torch/_dynamo/variables/builder.py", line 1237, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/utils.py", line 1351, in get_fake_value
    raise TorchRuntimeError(str(e)).with_traceback(e.__traceback__) from None
  File "/usr/lib/python3/dist-packages/torch/_dynamo/utils.py", line 1319, in get_fake_value
    return wrap_fake_exception(
  File "/usr/lib/python3/dist-packages/torch/_dynamo/utils.py", line 898, in wrap_fake_exception
    return fn()
  File "/usr/lib/python3/dist-packages/torch/_dynamo/utils.py", line 1320, in <lambda>
    lambda: run_node(tx.output, node, args, kwargs, nnmodule)
  File "/usr/lib/python3/dist-packages/torch/_dynamo/utils.py", line 1385, in run_node
    raise RuntimeError(fn_str + str(e)).with_traceback(e.__traceback__) from e
  File "/usr/lib/python3/dist-packages/torch/_dynamo/utils.py", line 1372, in run_node
    return node.target(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/torch/utils/_stats.py", line 20, in wrapper
    return fn(*args, **kwargs)
run_name: sd2-base-256
  File "/usr/lib/python3/dist-packages/torch/_subclasses/fake_tensor.py", line 1233, in __torch_dispatch__
run_name: sd2-base-256
    return self.dispatch(func, types, args, kwargs)
  File "/usr/lib/python3/dist-packages/torch/_subclasses/fake_tensor.py", line 1470, in dispatch
    op_impl_out = op_impl(self, func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/torch/_subclasses/fake_tensor.py", line 410, in constructors
    r = func(*args, **new_kwargs)
  File "/usr/lib/python3/dist-packages/torch/_ops.py", line 435, in __call__
    return self._op(*args, **kwargs or {})
torch._dynamo.exc.TorchRuntimeError: Failed running call_function <built-in method randn of type object at 0x7f3d98806900>(*((s1, 4, 32, 32),), **{'generator': None, 'device': device(type='cuda', index=0), 'dtype': torch.float16, 'layout': torch.strided}):
aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:3364: SymIntArrayRef expected to contain only concrete integers

from user code:
   File "/diffusion/diffusion/models/stable_diffusion.py", line 173, in <resume in forward>
    latents = self.vae.encode(inputs)['latent_dist'].sample().data
  File "/usr/lib/python3/dist-packages/diffusers/models/vae.py", line 659, in sample
    sample = randn_tensor(
  File "/usr/lib/python3/dist-packages/diffusers/utils/torch_utils.py", line 79, in randn_tensor
    latents = torch.randn(shape, generator=generator, device=rand_device, dtype=dtype, layout=layout).to(device)

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information
```

### Minified repro

_No response_

### Versions

Looking in indexes: https://download.pytorch.org/whl/nightly/cu118
Collecting torch
  Downloading https://download.pytorch.org/whl/nightly/cu118/torch-2.1.0.dev20230814%2Bcu118-cp310-cp310-linux_x86_64.whl (2321.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.3/2.3 GB 3.3 MB/s eta 0:00:00
Collecting torchvision
  Downloading https://download.pytorch.org/whl/nightly/cu118/torchvision-0.16.0.dev20230814%2Bcu118-cp310-cp310-linux_x86_64.whl (6.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.2/6.2 MB 23.0 MB/s eta 0:00:00
Collecting torchaudio
  Downloading https://download.pytorch.org/whl/nightly/cu118/torchaudio-2.1.0.dev20230814%2Bcu118-cp310-cp310-linux_x86_64.whl (3.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 18.9 MB/s eta 0:00:00
Requirement already satisfied: filelock in /usr/lib/python3/dist-packages (from torch) (3.12.2)
Requirement already satisfied: typing-extensions in /usr/lib/python3/dist-packages (from torch) (4.5.0)
Requirement already satisfied: sympy in /usr/lib/python3/dist-packages (from torch) (1.11.1)
Requirement already satisfied: networkx in /usr/lib/python3/dist-packages (from torch) (3.1)
Requirement already satisfied: jinja2 in /usr/lib/python3/dist-packages (from torch) (3.1.2)
Requirement already satisfied: fsspec in /usr/lib/python3/dist-packages (from torch) (2023.6.0)
Collecting pytorch-triton==2.1.0+e6216047b8 (from torch)
  Downloading https://download.pytorch.org/whl/nightly/pytorch_triton-2.1.0%2Be6216047b8-cp310-cp310-linux_x86_64.whl (96.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.4/96.4 MB 28.0 MB/s eta 0:00:00
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from torchvision) (1.24.2)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from torchvision) (2.31.0)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /usr/lib/python3/dist-packages (from torchvision) (9.3.0)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/lib/python3/dist-packages (from jinja2->torch) (2.1.2)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/lib/python3/dist-packages (from requests->torchvision) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests->torchvision) (2.8)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3/dist-packages (from requests->torchvision) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests->torchvision) (2023.5.7)
Requirement already satisfied: mpmath>=0.19 in /usr/lib/python3/dist-packages (from sympy->torch) (1.3.0)
DEPRECATION: mlnx-tools -5.2.0- has a non-standard version number. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of mlnx-tools or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063
Installing collected packages: pytorch-triton, torch, torchvision, torchaudio
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
diffusion 0.0.1 requires xformers==0.0.20, which is not installed.
diffusion 0.0.1 requires mosaicml==0.15.1, but you have mosaicml 0.14.1 which is incompatible.
mosaicml 0.14.1 requires torch<2.1,>=1.13.1, but you have torch 2.1.0.dev20230814+cu118 which is incompatible.
mosaicml 0.14.1 requires torchvision<0.16,>=0.13.1, but you have torchvision 0.16.0.dev20230814+cu118 which is incompatible.
torchdata 0.6.1 requires torch==2.0.1, but you have torch 2.1.0.dev20230814+cu118 which is incompatible.
torchtext 0.15.2 requires torch==2.0.1, but you have torch 2.1.0.dev20230814+cu118 which is incompatible.
Successfully installed pytorch-triton-2.1.0+e6216047b8 torch-2.1.0.dev20230814+cu118 torchaudio-2.1.0.dev20230814+cu118 torchvision-0.16.0.dev20230814+cu118


cc @ezyang @msaroufim @wconstab @bdhirsh @anijain2305