Repository: pytorch
Issue: Dynamo fails on scalar bit shifts when `dynamic=True`
Labels: triaged,bug,oncall: pt2,module: dynamic shapes

### 🐛 Describe the bug

```python
import torch

@torch.compile(dynamic=True, backend='eager')
def f(x):
    return 1 << x

f(2)
```

The operations `>>` and  `<<` fail, while `{+, -, *, /}` are OK.

### Error logs

```python
Traceback (most recent call last):
  File "bug.py", line 7, in <module>
    f(2)
  File ".../lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 453, in _fn
    return fn(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 615, in catch_errors
    return callback(frame, cache_entry, hooks, frame_state)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 748, in _convert_frame
    result = inner_convert(frame, cache_entry, hooks, frame_state)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 390, in _convert_frame_assert
    return _compile(
  File "/usr/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 650, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
  File ".../lib/python3.10/site-packages/torch/_dynamo/utils.py", line 248, in time_wrapper
    r = func(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 531, in compile_inner
    out_code = transform_code_object(code, transform)
  File ".../lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1033, in transform_code_object
    transformations(instructions, code_options)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 155, in _fn
    return fn(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 496, in transform
    tracer.run()
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2126, in run
    super().run()
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 787, in run
    and self.step()
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 750, in step
    getattr(self, inst.opname)(inst)
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 241, in impl
    self.push(fn_var.call_function(self, self.popn(nargs), {}))
  File ".../lib/python3.10/site-packages/torch/_dynamo/variables/builtin.py", line 674, in call_function
    res = binop_handler(tx, args[0], args[1], {})
  File ".../lib/python3.10/site-packages/torch/_dynamo/variables/builtin.py", line 322, in dynamic_handler
    return wrap_fx_proxy(
  File ".../lib/python3.10/site-packages/torch/_dynamo/variables/builder.py", line 1291, in wrap_fx_proxy
    return wrap_fx_proxy_cls(target_cls=TensorVariable, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/variables/builder.py", line 1376, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx, allow_non_graph_fake=True)
  File ".../lib/python3.10/site-packages/torch/_dynamo/utils.py", line 1653, in get_fake_value
    raise TorchRuntimeError(str(e)).with_traceback(e.__traceback__) from None
  File ".../lib/python3.10/site-packages/torch/_dynamo/utils.py", line 1599, in get_fake_value
    ret_val = wrap_fake_exception(
  File ".../lib/python3.10/site-packages/torch/_dynamo/utils.py", line 1140, in wrap_fake_exception
    return fn()
  File ".../lib/python3.10/site-packages/torch/_dynamo/utils.py", line 1600, in <lambda>
    lambda: run_node(tx.output, node, args, kwargs, nnmodule)
  File ".../lib/python3.10/site-packages/torch/_dynamo/utils.py", line 1720, in run_node
    raise RuntimeError(fn_str + str(e)).with_traceback(e.__traceback__) from e
  File ".../lib/python3.10/site-packages/torch/_dynamo/utils.py", line 1699, in run_node
    return node.target(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/fx/experimental/sym_node.py", line 1242, in rbinary_magic_impl
    ret = wrap_node(getattr(other_node, method_attr)(self.node))
  File ".../lib/python3.10/site-packages/torch/fx/experimental/sym_node.py", line 255, in lshift
    return self._lshift(other)  # type: ignore[attr-defined]
  File ".../lib/python3.10/site-packages/torch/fx/experimental/sym_node.py", line 926, in binary_magic_impl
    out = func(self.expr, other.expr)
  File ".../lib/python3.10/site-packages/torch/fx/experimental/sym_node.py", line 571, in _sympy_lshift
    return LShift(a, b)
  File ".../lib/python3.10/site-packages/sympy/core/cache.py", line 70, in wrapper
    retval = cfunc(*args, **kwargs)
  File ".../lib/python3.10/site-packages/sympy/core/function.py", line 469, in __new__
    result = super().__new__(cls, *args, **options)
  File ".../lib/python3.10/site-packages/sympy/core/cache.py", line 70, in wrapper
    retval = cfunc(*args, **kwargs)
  File ".../lib/python3.10/site-packages/sympy/core/function.py", line 309, in __new__
    evaluated = cls.eval(*args)
  File ".../lib/python3.10/site-packages/torch/utils/_sympy/functions.py", line 249, in eval
    if shift < 0:
  File ".../lib/python3.10/site-packages/sympy/core/relational.py", line 511, in __bool__
    raise TypeError("cannot determine truth value of Relational")
torch._dynamo.exc.TorchRuntimeError: Failed running call_function <built-in function lshift>(*(1, s0), **{}):
cannot determine truth value of Relational

from user code:
   File "bug.py", line 5, in f
    return 1 << x

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

_No response_

### Versions

```
Collecting environment information...
PyTorch version: 2.3.0.dev20240204+cpu
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.4 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.16.3
Libc version: glibc-2.31

Python version: 3.10.13 (main, Aug 25 2023, 13:20:03) [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.4.0-170-generic-x86_64-with-glibc2.31
Is CUDA available: False
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090
Nvidia driver version: 515.43.04
cuDNN version: Probably one of the following:
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_train.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8
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
Byte Order:                         Little Endian
Address sizes:                      46 bits physical, 57 bits virtual
CPU(s):                             32
On-line CPU(s) list:                0-31
Thread(s) per core:                 2
Core(s) per socket:                 16
Socket(s):                          1
NUMA node(s):                       1
Vendor ID:                          GenuineIntel
CPU family:                         6
Model:                              106
Model name:                         Intel(R) Xeon(R) Silver 4314 CPU @ 2.40GHz
Stepping:                           6
Frequency boost:                    enabled
CPU MHz:                            885.906
CPU max MHz:                        3400.0000
CPU min MHz:                        800.0000
BogoMIPS:                           4800.00
Virtualization:                     VT-x
L1d cache:                          768 KiB
L1i cache:                          512 KiB
L2 cache:                           20 MiB
L3 cache:                           24 MiB
NUMA node0 CPU(s):                  0-31
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
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
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 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 invpcid_single 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 wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear pconfig flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] numpy==1.26.3
[pip3] torch==2.3.0.dev20240204+cpu
[conda] Could not collect
```

cc @ezyang @msaroufim @bdhirsh @anijain2305 @zou3519