Skip to content

[ET-VK] Fix caching mechanism to account for included files #12441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2025

Conversation

SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented Jul 14, 2025

Stack from ghstack (oldest at bottom):

Changes

  • Update the gen_vulkan_spv.py script to account for changes to included files when decided whether to perform a re-compilation

Additional Changes

Also applied some misc fixes:

  • Allow the Python preprocessor to handle unescaped \ used to extend macros to multiple lines. Fixed this by replacing these with \ before running the preprocessor.
  • Fixed an issue where build would unexpectedly pass when trying to recompile a failing build multiple time. This would cause the caching mechanism to use a old cached build artifact since no changes were detected. Fixed this by removing any existing cached artifacts on unsuccessful build.

Context

The gen_vulkan_spv.py script which handles GLSL shader codegen and GLSL -> SPIR-V compilation for the ExecuTorch Vulkan backend has a caching mechanism to only recompile modified files for the purpose of developer efficiency. However, this mechanism currently doesn't consider whether included files have been changed. Therefore, if a include file is modified without first modifying the source file which uses it, the changes to the include file will not be captured.

Differential Revision: D78275585

## Changes

* Update the `gen_vulkan_spv.py` script to account for changes to included files when decided whether to perform a re-compilation


## Additional Changes

Also applied some misc fixes:

* Allow the Python preprocessor to handle unescaped `\` used to extend macros to multiple lines. Fixed this by replacing these with `\` before running the preprocessor.
* Fixed an issue where build would unexpectedly pass when trying to recompile a failing build multiple time. This would cause the caching mechanism to use a old cached build artifact since no changes were detected. Fixed this by removing any existing cached artifacts on unsuccessful build.

## Context

The `gen_vulkan_spv.py` script which handles GLSL shader codegen and GLSL -> SPIR-V compilation for the ExecuTorch Vulkan backend has a caching mechanism to only recompile modified files for the purpose of developer efficiency. However, this mechanism currently doesn't consider whether included files have been changed. Therefore, if a include file is modified without first modifying the source file which uses it, the changes to the include file will not be captured.

Differential Revision: [D78275585](https://our.internmc.facebook.com/intern/diff/D78275585/)

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Jul 14, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit bb3c625 with merge base 1540659 (image):

NEW FAILURE - The following job has failed:

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

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78275585

Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@facebook-github-bot facebook-github-bot merged commit b63cb72 into gh/SS-JIA/256/base Jul 14, 2025
98 of 102 checks passed
@facebook-github-bot facebook-github-bot deleted the gh/SS-JIA/256/head branch July 14, 2025 18:02
@@ -545,6 +545,9 @@ def escape(line: str) -> str:
def preprocess(
input_text: str, variables: Dict[str, Any], input_path: str = "codegen"
) -> str:
# Workaround to handle source files using \ to extend mecros to a new line
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Workaround to handle source files using \ to extend mecros to a new line
# Workaround to handle source files using \ to extend macros to a new line

@@ -654,8 +657,8 @@ def addSrcAndYamlFiles(self, src_dir_paths: List[str]) -> None:
for src_path in src_dir_paths:
# Collect glsl source files
src_files_list = glob.glob(
os.path.join(src_path, "**", "*.glsl*"), recursive=True
)
os.path.join(src_path, "**", "*.[gh]lsl*"), recursive=True
Copy link
Contributor

Choose a reason for hiding this comment

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

Update the comment to include hlsl. Not sure if you intended to put this change in this PR.

cache_dir, os.path.basename(src_file_fullpath) + ".t"
)
shutil.copyfile(src_file_fullpath, cached_src_file)
print(spv_to_glsl_map)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
print(spv_to_glsl_map)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants