# State of symbolic shapes branch

**URL:** <https://dev-discuss.pytorch.org/t/state-of-symbolic-shapes-branch/777>\
**Category:** compiler\
**Created:** [September 19, 2022, 5:32pm UTC](https://dev-discuss.pytorch.org/t/state-of-symbolic-shapes-branch/777 "2022-09-19T17:32:53Z")\
**Posts on this page:** 1\
**Showing post:** 76

<div class="post-metadata">

**Author:** ![ezyang](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/ezyang/32/12_2.png) [@ezyang](https://dev-discuss.pytorch.org/u/ezyang)\
**Post date:** [January 29, 2024, 3:50am UTC](https://dev-discuss.pytorch.org/t/state-of-symbolic-shapes-branch/777/76 "2024-01-29T03:50:33Z")

</div>

# State of PT2: Jan 28, 2024 edition

- Calibrations were this week.
- Joel, Jeffrey, Alban, Brian and Edward convened to discuss subclass view fakeification again. Subclass view fakeification occurs when we are given a tensor subclass which is a view of another tensor (the canonical example is a nested tensor which is a view of a dense tensor of all the packed data), and we need to convert it into a faithful fake representation so we can simulate operations on it in Dynamo and AOT Autograd. Construction of views in fake tensors is traditionally done by fakeifying the base tensor, and then reapplying a recorded view function which specifies how to “replay” the view on an arbitrary new base. The problem of subclass view fakeification is that these view functions typically hard code size / tensors that are free variables of the view operation, but when fakeifying, these need to be swapped out with symbolic integers and corresponding fake tensors. Joel’s resolution after the meeting was to reify view functions so that this information can be swapped. Notes: [Subclass View Fake-ification in PT2 - Google Docs](https://docs.google.com/document/d/1C5taWiplmX7nKiURXDOAZG2W5VNJ2iV0fQFq92H0Cxw/edit#heading=h.vl1gidtprtoo)
- Shampoo compile time is still a problem. I talked to some folks on Wednesday who were like “our job is stuck in produce\_guards” and it turned out to be the exact same tensors\_definitely\_do\_not\_overlap guard explosion that caused two other SEVs described at [Meta issue: Automatic dynamic shapes can cause compile-time performance cliffs · Issue #118213 · pytorch/pytorch · GitHub](https://github.com/pytorch/pytorch/issues/118213). Brian is going to try to fix the tensors\_definitely\_do\_not\_overlap problem in a few weeks. I showed Yanbo how to navigate the logs to find the culprit (in this case, just searching for symbolic\_shapes logs was enough to identify this as the same problem.) There is some difficulty reliably turning of automatic dynamic shapes (which would help with this problem) that needs to be studied in more detail.
- Two interesting new posts: [Micro-optimizations for the most micro of benchmarks](https://dev-discuss.pytorch.org/t/micro-optimizations-for-the-most-micro-of-benchmarks/1836) and [[RFC] New Python operator registration API](https://dev-discuss.pytorch.org/t/rfc-new-python-operator-registration-api/1838) which I highly recommend
- I’ve been talking Elias and Mario through the plan to remove unsound 0/1 specialization [Eliminate compile time ranges for a simpler analysis · Issue #117361 · pytorch/pytorch · GitHub](https://github.com/pytorch/pytorch/issues/117361) and people are on board, I am going to implement this next week.
- A bit of chatter about what to do about backtraces in distributed interleaving each other. Chip Turner shared that if you pass appropriate arguments to torchrun like `torchrun --role mnist-trainer --log-dir /tmp/l -t 3 -r 3 mnist/main.py` good things happen. Unfortunately in internal prod we are still shoving everything to stderr but maybe we can change that. Meta only: [https://fb.workplace.com/groups/mast.users/posts/1451868658730526](https://fb.workplace.com/groups/mast.users/posts/1451868658730526)
- We’re using dmypy instead of mypy for typechecking now in lintrunner. Typechecking is a lot faster! If you think there’s some weird cache problem, you can say `dmypy stop` to restart the daemon.
- A lot of dynamic shapes bugs in Inductor specifically this week: [Inductor sizevars wrapper assignment DCE hazard · Issue #118385 · pytorch/pytorch · GitHub](https://github.com/pytorch/pytorch/issues/118385) [assert isinstance(value, CppCSEVariable) and value.is\_vec · Issue #118379 · pytorch/pytorch · GitHub](https://github.com/pytorch/pytorch/issues/118379) [Inductor mixed device operations not handled correctly, maybe buffer reuse problem? · Issue #118299 · pytorch/pytorch · GitHub](https://github.com/pytorch/pytorch/issues/118299) . I’ve personally been mucking around a bit in Inductor recently!
- Landed stuff:
  - [Realize inputs to DynamicScalar before unwrapping storage](https://github.com/pytorch/pytorch/pull/118125) - another “oops we fed the wrong thing to an extern kernel” bug
  - Landed from last week: [Fix several bugs related to unbacked SymInt codegen in inductor](https://github.com/pytorch/pytorch/pull/117862), [Rename unbacked SymInt prefix to u](https://github.com/pytorch/pytorch/pull/117859), [Document OpsHandler protocol](https://github.com/pytorch/pytorch/pull/117790)

- Notable new bugs:
  - [Inductor: KeyError: ‘could not find u6’](https://github.com/pytorch/pytorch/issues/118218)
  - [Inductor sizevars wrapper assignment DCE hazard](https://github.com/pytorch/pytorch/issues/118385)
  - [Further simplifying guards](https://github.com/pytorch/pytorch/issues/118332) -
  - [Potential correctness problem with symbolic size deduplication leading to spurious dependence on tangents in functorch partitioner](https://github.com/pytorch/pytorch/issues/118224)

---

_[View the full topic](https://dev-discuss.pytorch.org/t/state-of-symbolic-shapes-branch/777)._
