Skip to content

Something like mark_unbacked but only does size oblivious #137100

@ezyang

Description

@ezyang

🐛 Describe the bug

Let's say you have some code where you need the inputs to not 0/1 specialize. Today, we tell you to do torch._dynamo.mark_unbacked to avoid 0/1 specialization. But doing this actually triggers two orthogonal mechanisms:

  • You opt into the alternate size oblivious semantics, which allows you to avoid doing specializations on 0/1 in many situations
  • You say no guards allowed on this value at all

But the second is not at all necessary! For example, if I have:

def f(x):
  if x.size(0) >= 10:
    return x + x
  else:
   return x * 3

If I didn't want x to 0/1 specialize, I might still be perfectly happy to install a guard u0 >= 10. Now, if I'm using mark_unbacked to avoid situations where I'd have to compile exponentially many kernels, I'd have to make sure that I don't actually trigger too many of these guards, but this is something I'd like be more than happy to solve for at some later point in time.

Sort of related to hybrid unbacked SymInts.

Versions

main

cc @gchanan @zou3519 @kadeng @msaroufim @chauhang @penguinwu @bobrenjc93

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions