Skip to content

[torch.compile] split shared compilation hash helpers#29057

Closed
vnadathur wants to merge 7 commits intovllm-project:mainfrom
vnadathur:fix-nightly
Closed

[torch.compile] split shared compilation hash helpers#29057
vnadathur wants to merge 7 commits intovllm-project:mainfrom
vnadathur:fix-nightly

Conversation

@vnadathur
Copy link
Contributor

@vnadathur vnadathur commented Nov 20, 2025

Motivation

PR: #26468 removed envs.compute_hash which was being used by compilation_config_hash_factors, which decorators.py relies on for aot cache keys.

Both _compute_code_hash and compilation_config_hash_factors exist to keep aot and jit hashing consistent. backends.py had a duplicate of their logic

The Fix

This pr creates a shared helper instead of inlining them and updates the helper itself to call the new envs.compile_factors().

Thanks for pointing this out @zhxchen17

Test

@zhxchen17 does this fix the issue with pytorch nightly?

cc @ProExpertProg @WorldExplored

Signed-off-by: WorldExplored <srreyansh.sethi@gmail.com>
Co-Authored-By: vnadathur <236933696+vnadathur@users.noreply.github.com>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request does a good job of refactoring the compilation hashing logic into shared helpers, which improves code reuse and maintainability. However, I've found a critical issue where the hashing algorithm for code hashing was changed from sha256 to md5, which could lead to cache inconsistencies and collisions. I've also identified a performance issue due to a redundant function call. Please see my detailed comments for suggestions on how to address these points.

Signed-off-by: WorldExplored <srreyansh.sethi@gmail.com>
Co-Authored-By: vnadathur <236933696+vnadathur@users.noreply.github.com>
Copy link
Collaborator

@ProExpertProg ProExpertProg left a comment

Choose a reason for hiding this comment

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

Can we instead refactor the decorator to use the new & cleaner approach instead of restoring the older code?

…e the logic inline

Signed-off-by: vnadathur <glvikramn@gmail.com>
@vnadathur
Copy link
Contributor Author

@zhxchen17 i tried to hit ur concern here:

In other words, we don't have the same hashing algorithm between VLLM_USE_AOT_COMPILE=1 and VLLM_USE_AOT_COMPILE=0. I wonder does anyone think that will be a problem?

@zhxchen17
Copy link
Contributor

Thanks for the fix! I think this looks ok to me as well.

@zhxchen17
Copy link
Contributor

zhxchen17 commented Nov 20, 2025

@zhxchen17 i tried to hit ur concern here:

In other words, we don't have the same hashing algorithm between VLLM_USE_AOT_COMPILE=1 and VLLM_USE_AOT_COMPILE=0. I wonder does anyone think that will be a problem?

@vnadathur Deleted my original comment there since I think that's not accurate.

@ProExpertProg I like this fix slightly better because it shares the code for code hashing. I think in the short term it's okay to remove compilation_config_hash_factors tho. I wonder whether it will be a problem if in the future we decide to introduce a new common source of hashing (in addition to env+compiler config) that only got added to one path but not the other one. If we think it's unlikely, I think it's fine to have small duplication.

@zou3519 zou3519 added the ready ONLY add when PR is ready to merge/full CI is needed label Nov 20, 2025
@vnadathur vnadathur changed the title [torch.compile] fix shared compilation hash helpers [torch.compile] split shared compilation hash helpers Nov 20, 2025
per discussion on slack

Signed-off-by: vnadathur <glvikramn@gmail.com>
Copy link
Collaborator

@ProExpertProg ProExpertProg left a comment

Choose a reason for hiding this comment

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

I think if we're cleaning this up, let's really clean it up. I would prefer to land #29058 for now. I agree it would be good to keep the two cache hashes in sync but they are already different and the only common part is hash of config and envs, both of which come from the same member methods on the config and envs already.

@ProExpertProg ProExpertProg mentioned this pull request Nov 20, 2025
5 tasks
Signed-off-by: vnadathur <glvikramn@gmail.com>
Co-Authored-By: Srreyansh Sethi <107075589+WorldExplored@users.noreply.github.com>
Copy link
Collaborator

@ProExpertProg ProExpertProg left a comment

Choose a reason for hiding this comment

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

This looks fine as well, @zou3519 @drisspg @zhxchen17 can you check this works for you, happy to merge as is and improve structure later

Copy link
Collaborator

@ProExpertProg ProExpertProg left a comment

Choose a reason for hiding this comment

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

Let's merge #29058 for now. After that we can properly restructure the config, including pulling out the compile cache factors so they can be stored with other cache artifacts

WorldExplored and others added 2 commits November 20, 2025 13:35
Signed-off-by: WorldExplored <srreyansh.sethi@gmail.com>
Co-Authored-By: vnadathur <236933696+vnadathur@users.noreply.github.com>
Signed-off-by: Srreyansh Sethi <107075589+WorldExplored@users.noreply.github.com>
@ProExpertProg
Copy link
Collaborator

Let's just do this in #29117, can we close this?

@vnadathur vnadathur closed this Nov 20, 2025
WorldExplored added a commit to vnadathur/vllm that referenced this pull request Nov 21, 2025
PR: vllm-project#29057

Signed-off-by: WorldExplored <srreyansh.sethi@gmail.com>
Co-Authored-By: vnadathur <236933696+vnadathur@users.noreply.github.com>
@vnadathur vnadathur deleted the fix-nightly branch December 8, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants