Skip to content

Conversation

@minjang
Copy link
Contributor

@minjang minjang commented Aug 22, 2024

Not sure this is worthy to make it? I was annoyed by long sha256-based cache directory names, mostly 64 chars. So I quickly added base64-based shorter cache directory names.

Instead of fixing a dozen places that use hashlib.sha256, I patched the cache manager. 64-char names are mostly reduced to 43-44 chars.

A comparison:

> % ls -l $TRITON_CACHE_DIR
total 0
drwxr-xr-x 1 minjang users  40 Aug 21 19:02 44ae4aee7ef0ee0dd54e860cf44627e3b6cedabe87a228ac75988301b8a6bf60
drwxr-xr-x 1 minjang users  26 Aug 21 19:02 82dc2c9a5508bf07c72e02353c1e751dc54aae85666f139b2867b0a1e95e0e7b
drwxr-xr-x 1 minjang users 226 Aug 21 19:02 b8e240968a85711ba57b17bf8450f1ffbc85a8de8cd1f47aa87b241b53f9bf60
drwxr-xr-x 1 minjang users  26 Aug 21 19:03 gtwsmlUIvwfHLgI1PB51HcVKroVmbxObKGewoeleDns
drwxr-xr-x 1 minjang users  40 Aug 21 19:03 RK5K7n7w7g3VToYM9EYn47bO2r6HoiisdZiDAbimv2A
drwxr-xr-x 1 minjang users 226 Aug 21 19:03 uOJAloqFcRulexe_hFDx_7yFqN6M0fR6qHskG1P5v2A

test_core.py runs without any errors, and the cache directory has all base64-based shorter names.

@minjang minjang requested a review from ptillet as a code owner August 22, 2024 05:35
Copy link
Collaborator

@ThomasRaoux ThomasRaoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice

@ThomasRaoux ThomasRaoux merged commit d6b7a8a into main Aug 22, 2024
@ThomasRaoux ThomasRaoux deleted the minjang/base64_cache_dir branch August 22, 2024 14:52
Jokeren pushed a commit that referenced this pull request Aug 24, 2024
Not sure this is worthy to make it? I was annoyed by long sha256-based
cache directory names, mostly 64 chars. So I quickly added base64-based
shorter cache directory names.

Instead of fixing a dozen places that use `hashlib.sha256`, I patched
the cache manager. 64-char names are mostly reduced to 43-44 chars.

A comparison:
```
> % ls -l $TRITON_CACHE_DIR
total 0
drwxr-xr-x 1 minjang users  40 Aug 21 19:02 44ae4aee7ef0ee0dd54e860cf44627e3b6cedabe87a228ac75988301b8a6bf60
drwxr-xr-x 1 minjang users  26 Aug 21 19:02 82dc2c9a5508bf07c72e02353c1e751dc54aae85666f139b2867b0a1e95e0e7b
drwxr-xr-x 1 minjang users 226 Aug 21 19:02 b8e240968a85711ba57b17bf8450f1ffbc85a8de8cd1f47aa87b241b53f9bf60
drwxr-xr-x 1 minjang users  26 Aug 21 19:03 gtwsmlUIvwfHLgI1PB51HcVKroVmbxObKGewoeleDns
drwxr-xr-x 1 minjang users  40 Aug 21 19:03 RK5K7n7w7g3VToYM9EYn47bO2r6HoiisdZiDAbimv2A
drwxr-xr-x 1 minjang users 226 Aug 21 19:03 uOJAloqFcRulexe_hFDx_7yFqN6M0fR6qHskG1P5v2A
```

`test_core.py` runs without any errors, and the cache directory has all
base64-based shorter names.
davidberard98 added a commit to pytorch/pytorch that referenced this pull request Nov 8, 2024
In old triton versions, you take the hash of the triton kernel and use it in the filepath for the cached kernel. In Triton 3.2 (after triton-lang/triton#4553), the filepath will use the base-64-encoded representation of the hash in the path.

This PR checks whether the `_base64` function exists in triton, and if so, uses the base-64-encoded represenatation in the path.

[ghstack-poisoned]
davidberard98 added a commit to pytorch/pytorch that referenced this pull request Nov 8, 2024
In old triton versions, you take the hash of the triton kernel and use it in the filepath for the cached kernel. In Triton 3.2 (after triton-lang/triton#4553), the filepath will use the base-64-encoded representation of the hash in the path.

This PR checks whether the `_base64` function exists in triton, and if so, uses the base-64-encoded represenatation in the path.

ghstack-source-id: f0e880d
Pull Request resolved: #140190
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Nov 11, 2024
In old triton versions, you take the hash of the triton kernel and use it in the filepath for the cached kernel. In Triton 3.2 (after triton-lang/triton#4553), the filepath will use the base-64-encoded representation of the hash in the path.

This PR checks whether the `_base64` function exists in triton, and if so, uses the base-64-encoded represenatation in the path.

ghstack-source-id: 92c2018
Pull Request resolved: #140190
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Nov 11, 2024
…0190)

In old triton versions, you take the hash of the triton kernel and use it in the filepath for the cached kernel. In Triton 3.2 (after triton-lang/triton#4553), the filepath will use the base-64-encoded representation of the hash in the path.

This PR checks whether the `_base64` function exists in triton, and if so, uses the base-64-encoded represenatation in the path.

Pull Request resolved: #140190
Approved by: https://github.com/ezyang
pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
…orch#140190)

In old triton versions, you take the hash of the triton kernel and use it in the filepath for the cached kernel. In Triton 3.2 (after triton-lang/triton#4553), the filepath will use the base-64-encoded representation of the hash in the path.

This PR checks whether the `_base64` function exists in triton, and if so, uses the base-64-encoded represenatation in the path.

Pull Request resolved: pytorch#140190
Approved by: https://github.com/ezyang
bertmaher pushed a commit to bertmaher/triton that referenced this pull request Dec 10, 2024
Not sure this is worthy to make it? I was annoyed by long sha256-based
cache directory names, mostly 64 chars. So I quickly added base64-based
shorter cache directory names.

Instead of fixing a dozen places that use `hashlib.sha256`, I patched
the cache manager. 64-char names are mostly reduced to 43-44 chars.

A comparison:
```
> % ls -l $TRITON_CACHE_DIR
total 0
drwxr-xr-x 1 minjang users  40 Aug 21 19:02 44ae4aee7ef0ee0dd54e860cf44627e3b6cedabe87a228ac75988301b8a6bf60
drwxr-xr-x 1 minjang users  26 Aug 21 19:02 82dc2c9a5508bf07c72e02353c1e751dc54aae85666f139b2867b0a1e95e0e7b
drwxr-xr-x 1 minjang users 226 Aug 21 19:02 b8e240968a85711ba57b17bf8450f1ffbc85a8de8cd1f47aa87b241b53f9bf60
drwxr-xr-x 1 minjang users  26 Aug 21 19:03 gtwsmlUIvwfHLgI1PB51HcVKroVmbxObKGewoeleDns
drwxr-xr-x 1 minjang users  40 Aug 21 19:03 RK5K7n7w7g3VToYM9EYn47bO2r6HoiisdZiDAbimv2A
drwxr-xr-x 1 minjang users 226 Aug 21 19:03 uOJAloqFcRulexe_hFDx_7yFqN6M0fR6qHskG1P5v2A
```

`test_core.py` runs without any errors, and the cache directory has all
base64-based shorter names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants