feat: Implement persistent CUBIN caching, multi-threaded context safety, and cross-platform NVRTC support (#175)#193
Open
Franklalalala wants to merge 3 commits intoPASSIONLab:mainfrom
Open
Conversation
to support sm_89 machine
Author
|
me personally do not understand the underlining mechanism, though it indeed fix the issue smh... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Content
This PR introduces a robust disk-based caching mechanism for NVRTC JIT compilation, ensures CUDA context safety across multiple threads, and provides cross-platform compatibility (Windows/Linux). It significantly optimizes the startup time of models using JIT-compiled kernels by avoiding redundant compilation.
🎯 Motivation
🛠️ Core Differences & Implementation Details
The new implementation introduces several critical enhancements over the previous version:
Deterministic Persistent Caching
compiledflag; compilation was lost on process exit.sm_xx), compilation options, source code, and kernel name expressions..cubin(binary) and.names(lowered name mappings) to~/.cache/openequivarianceor a custom path viaOEQ_CACHE_PATH.Atomic & Safe File I/O
PIDandThreadID) and then atomically moved to the final destination usingstd::rename.Automatic CUDA Context Management
ensure_cuda_context(). This function detects if the calling thread has an active CUDA context. If not, it retains and sets the Primary Context for the device. This is crucial for stability in multi-threaded C++ or Python environments.Cross-Platform Portability
_WIN32) for directory creation (mkdirvs_mkdir) and process identification (getpidvs_getpid).<cinttypes>andPRIx64for consistent 64-bit hex formatting across different compilers/architectures.Robust Error Handling
delete[] log;is called even when astd::logic_erroris thrown during NVRTC failures, preventing memory leaks during iterative debugging.🤖 Contribution Note
This PR was developed through a collaborative effort between the contributor and multiple AI systems (Gemini 3.1 Pro Preview, GPT-5.4 High & Claude 4.6 Thinking models). We have worked together to address complex technical edge cases (such as atomic renames and primary context retention) to ensure the long-term stability and performance of the
OpenEquivariancelibrary.I have verified these changes on my local environment, and they successfully resolve the redundant JIT overhead described in Issue #175.