Repository navigation
Add cuda_extension_utils JIT loader for CUDA/C++ extensions - #700
Merged
AkshitaB merged 3 commits intoJun 5, 2026
Merged
Conversation
Generic just-in-time loader (`load_cuda_extension`) that builds and caches CUDA/C++ extensions via torch.utils.cpp_extension, with arch/ABI-tagged build directories and cross-process build-lock handling so concurrent ranks don't clobber each other's builds. Pure-Python and import-safe on CPU (the cpp_extension import is lazy). Includes a CPU test for the pure-Python helpers. Co-Authored-By: Akshita Bhagia <[email protected]> Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
AkshitaB
force-pushed
the
akshitab/moe-cuda-extension-loader
branch
from
June 3, 2026 23:27
73d44d9 to
d424e5f
Compare
… API load_cuda_extension is the only function called outside this module, so: - rename the internal helpers cuda_arch_tag -> _cuda_arch_tag, torch_extension_abi_tag -> _torch_extension_abi_tag, and maybe_remove_stale_build_lock -> _maybe_remove_stale_build_lock (and update the unit-test imports), so they don't read as public API or get auto-documented; - add __all__ = ["load_cuda_extension"] to declare the real public surface; - add a return annotation to load_cuda_extension and an _env_int helper (replacing int(_env_float(...)) for the retry count). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
undfined
reviewed
Jun 4, 2026
…t wording - _force_rebuild_build_directory: gate the wipe on get_fs_local_rank() == 0 instead of global rank 0. The JIT build cache is typically node-local, so global-rank-0-only wiping left every other node's cache stale on multi-node jobs. get_fs_local_rank() resolves to global rank 0 on a shared FS (OLMO_SHARED_FS=1), per-node local rank 0 on node-local FS, and 0 when not distributed -- so each distinct cache is wiped once. - Correct the docstring: torch.utils.cpp_extension (not torch) is the lazily-imported part; import torch stays top-level. - Add a CPU test for the non-distributed force-rebuild path. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
What this adds
olmo_core.kernels.cuda_extension_utils— a generic just-in-time loader (load_cuda_extension) for CUDA/C++ extensions built viatorch.utils.cpp_extension, with:Import-safety / testing
Pure-Python and import-safe on CPU — the
cpp_extensionimport is lazy, so importing the module needs neither a GPU nor a compiler. Includescuda_extension_utils_test.py, a CPU unit test for the pure-Python helpers (env parsing, arch/ABI tag construction, lock handling). The actual extension build is exercised by GPU tests on hardware.🤖 Generated with Claude Code