Skip to content

Conversation

@nmacchioni
Copy link
Contributor

@nmacchioni nmacchioni commented Dec 11, 2025

Summary: Similar to D85684098, but using the new PersistentMemoizer, one readable, and less constrictive keys (since _should_pad was refactored)

Test Plan: buck test fbcode//mode/opt caffe2/test/inductor:caching

Differential Revision: D88999540

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 11, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/170256

Note: Links to docs will display an error until the docs builds have been completed.

❌ 8 New Failures, 4 Cancelled Jobs, 1 Unrelated Failure

As of commit 7a4bbbe with merge base 52c7ad7 (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-codesync
Copy link

meta-codesync bot commented Dec 11, 2025

@nmacchioni has exported this pull request. If you are a Meta employee, you can view the originating Diff in D88999540.

@nmacchioni nmacchioni added the topic: not user facing topic category label Dec 12, 2025
nmacchioni added a commit to nmacchioni/pytorch that referenced this pull request Dec 12, 2025
…ch#170256)

Summary:

Similar to D85684098, but using the new PersistentMemoizer, one readable, and less constrictive keys (since _should_pad was refactored)

Test Plan: ```buck test fbcode//mode/opt caffe2/test/inductor:caching```

Differential Revision: D88999540
nmacchioni added a commit to nmacchioni/pytorch that referenced this pull request Dec 12, 2025
…ch#170256)

Summary:

Similar to D85684098, but using the new PersistentMemoizer, one readable, and less constrictive keys (since _should_pad was refactored)

```
{
  "cache_entries": {
    "should_pad": {
      "d05c99fdf8e1a35e43ba573d1a1acfa5": {
        "params": {
          "mat1": {
            "shape": [
              4096,
              4096
            ],
            "stride": [
              4096,
              1
            ],
            "dtype": "torch.bfloat16"
          },
          "mat2": {
            "shape": [
              4096,
              4096
            ],
            "stride": [
              4096,
              1
            ],
            "dtype": "torch.bfloat16"
          },
          "op": "aten.mm",
          "input": null,
          "mat1_exclude_padding_time": false,
          "mat2_exclude_padding_time": false
        },
        "result": false
      }
    }
  },
  "cache_size": 1
}
```

Test Plan: ```buck test fbcode//mode/opt caffe2/test/inductor:caching```

Differential Revision: D88999540
Summary:

Previously, when the interfaces were quite complex it made sense to abstract away the types that we put into the cache implementations. That way we shared complexity between interfaces and implementations.

Not that the interfaces are less complex, we can move this abstraction out of the implementations.

Mainly:
- cache impls now take str keys and bytes values
- except for the InMemoryCache, which takes Any values (with the assumption that Any is JSON-able)

This also has the added benefit of making InMemoryCache memory completely human readable (whether it is human readable in a way that actually makes sense is up to the user's encoding of results)

Test Plan: ```buck test fbcode//mode/opt caffe2/test/inductor:caching```

Reviewed By: aorenste

Differential Revision: D88979063
…70228)

Summary:

Similar to the OG impls, but heavily simplified. Introduces Memoizer and PersistentMemoizer classes.

Memoizer supports record, replay, and memoize functionality. Record simply caches the result of a function call. Replay checks for cached function call results and returns the cached result on hit, otherwise the function is called directly. Memoize is a combination of record and replay.

Memoizer is supported by an underlying _InMemoryCacheImpl instance.

PersistentMemoizer is nearly identical to Memoizer, other than also having an underlying _OnDiskCacheImpl instance such that cached results persist across program boundaries.

Test Plan: ```buck test fbcode//mode/opt caffe2/test/inductor:caching```

Differential Revision: D88979804
…h#170236)

Summary:

tldr; added a method to dump Memoizer's memory to disk in JSON format at program exit

in addition, we now include the encoded params in the cache entry (since the keys are hashes they don't provide much clues as to the origin of the entry by themself, hence why the params are now included)

note: the testing for the new dump method is actually included in the subsequent diff

Test Plan: ```buck test fbcode//mode/opt caffe2/test/inductor:caching```

Differential Revision: D88984165
Summary:

the reverse of dump

Test Plan: ```buck test fbcode//mode/opt caffe2/test/inductor:caching```

Differential Revision: D88984164
…ch#170256)

Summary:

Similar to D85684098, but using the new PersistentMemoizer, one readable, and less constrictive keys (since _should_pad was refactored)

```
{
  "cache_entries": {
    "should_pad": {
      "d05c99fdf8e1a35e43ba573d1a1acfa5": {
        "params": {
          "mat1": {
            "shape": [
              4096,
              4096
            ],
            "stride": [
              4096,
              1
            ],
            "dtype": "torch.bfloat16"
          },
          "mat2": {
            "shape": [
              4096,
              4096
            ],
            "stride": [
              4096,
              1
            ],
            "dtype": "torch.bfloat16"
          },
          "op": "aten.mm",
          "input": null,
          "mat1_exclude_padding_time": false,
          "mat2_exclude_padding_time": false
        },
        "result": false
      }
    }
  },
  "cache_size": 1
}
```

Test Plan: ```buck test fbcode//mode/opt caffe2/test/inductor:caching```

Reviewed By: v0i0

Differential Revision: D88999540
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant