[`NotImplementedError: AutogradFunctionVariable() is not a constant`] using xFormers
Labels: triaged, bug, oncall: pt2

### 🐛 Describe the bug

The failure seems to happen with this line:
https://github.com/facebookresearch/xformers/blob/fd21b404c41303fc8a6e506244ae7fb539110e6e/xformers/ops/memory_efficient_attention.py#L371-L374

### Error logs

```
torch version 1.14.0.dev20221115+cu117
Running forward
Traceback (most recent call last):
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 404, in _compile
    out_code = transform_code_object(code, transform)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 341, in transform_code_object
    transformations(instructions, code_options)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 392, in transform
    tracer.run()
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1518, in run
    super().run()
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 384, in run
    and self.step()
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 354, in step
    getattr(self, inst.opname)(inst)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 188, in wrapper
    return inner_fn(self, inst)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 811, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 296, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/variables/misc.py", line 572, in call_function
    return self.obj.call_method(tx, self.name, args, kwargs).add_options(self)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/variables/misc.py", line 65, in call_method
    inner_fn = self.const_getattr(self, name)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/variables/misc.py", line 40, in const_getattr
    search_type = self.typevar.as_python_constant()
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/variables/base.py", line 137, in as_python_constant
    raise NotImplementedError(f"{self} is not a constant")
NotImplementedError: AutogradFunctionVariable() is not a constant

from user code:
   File "/scratch/XXXX/xformers/xformers/ops/memory_efficient_attention.py", line 373, in supports
    if not super(MemoryEfficientAttentionCutlassOp, cls).supports(d):


You can suppress this exception and fall back to eager by setting:
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/scratch/XXXX/xformers/timm_try.py", line 24, in <module>
    model(inp, inp, inp)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 137, in __call__
    return self.forward(*args, **kwargs)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 134, in forward
    return optimized_forward(*args, **kwargs)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 169, in _fn
    return fn(*args, **kwargs)
  File "/scratch/XXXX/xformers/timm_try.py", line 16, in forward
    return xops.memory_efficient_attention(q, k, v)
  File "/scratch/XXXX/xformers/xformers/ops/memory_efficient_attention.py", line 923, in memory_efficient_attention
    ).op
  File "/scratch/XXXX/xformers/xformers/ops/memory_efficient_attention.py", line 790, in op
    if op.supports(self):
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 247, in catch_errors
    return callback(frame, cache_size)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 476, in _convert_frame
    result = inner_convert(frame, cache_size)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 118, in _fn
    return fn(*args, **kwargs)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 89, in time_wrapper
    r = func(*args, **kwargs)
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 349, in _convert_frame_assert
    return _compile(
  File "/scratch/XXXX/xformers-py10-pytorchN-cu117/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 466, in _compile
    raise InternalTorchDynamoError() from e
torch._dynamo.exc.InternalTorchDynamoError
```

### Repro

```
"""
conda install python=3.10 cudatoolkit=11.7 -c nvidia
python -m pip install numpy ninja --pre torch[dynamo] torchvision --force-reinstall --extra-index-url https://download.pytorch.org/whl/nightly/cu117
pip install -v -U git+https://github.com/facebookresearch/xformers.git@main#egg=xformers
# (this can take dozens of minutes)
"""
import torch
import torch._dynamo as dynamo
import xformers.ops as xops

torch._dynamo.config.verbose=True

device = "cuda"
dtype = torch.half

class xFormersMHA(torch.nn.Module):
    def forward(self, q, k, v):
        return xops.memory_efficient_attention(q, k, v)
model = xFormersMHA().to(device).to(dtype)
inp = torch.zeros([2, 10, 16, 128]).to(device).to(dtype)

print("torch version", torch.__version__)
model = dynamo.optimize()(model)

print("Running forward")
model(inp, inp, inp)
```

cc @ezyang @soumith @msaroufim @wconstab @ngimel @bdhirsh @fmassa