Repository navigation
[OMNIML-6259] Speed up CI JIT compiles: Triton cache and arch-limited CUDA wheels #2905
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
base: main
Are you sure you want to change the base?
Changes from all commits
2cf9e94
4cd9307
80e399d
88279bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
|
|
||
| import glob | ||
| import os | ||
| import re | ||
| import shutil | ||
| import tarfile | ||
| import tempfile | ||
|
|
@@ -133,6 +134,24 @@ def partial_unit(session, subset): | |
| "mamba_ssm": {"MAMBA_FORCE_BUILD": "TRUE"}, | ||
| "causal_conv1d": {"CAUSAL_CONV1D_FORCE_BUILD": "TRUE"}, | ||
| } | ||
| # Their setup.py files hardcode one -gencode flag per architecture (nine with CUDA 13) and ignore TORCH_CUDA_ARCH_LIST. | ||
| _GENCODE = re.compile( | ||
| r'^(?P<indent>[ \t]*)cc_flag\.append\("-gencode"\)\n[ \t]*cc_flag\.append\("arch=compute_(?P<arch>\d+),code=sm_\d+"\)', | ||
| re.MULTILINE, | ||
| ) | ||
|
|
||
|
|
||
| def _only_runner_archs(setup_py): | ||
| """Drop the ``-gencode`` entries for the architectures not in TORCH_CUDA_ARCH_LIST, which CI sets to its GPU.""" | ||
| archs = os.environ.get("TORCH_CUDA_ARCH_LIST") | ||
| if not archs: | ||
| return setup_py | ||
| keep = {re.sub(r"\D", "", arch) for arch in re.split(r"[;\s]+", archs)} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Support named CUDA architectures before filtering. If 🤖 Prompt for AI Agents |
||
| # ``pass`` keeps an ``if`` block valid when all of its entries are dropped | ||
| patched = _GENCODE.sub(lambda m: m[0] if m["arch"] in keep else f"{m['indent']}pass", setup_py) | ||
| if not _GENCODE.search(patched): | ||
| raise ValueError(f"No -gencode entry of setup.py matches TORCH_CUDA_ARCH_LIST={archs!r}") | ||
| return patched | ||
|
|
||
|
|
||
| def _wheelhouse(): | ||
|
|
@@ -157,7 +176,7 @@ def _build_wheel(session, name, wheelhouse): | |
| source = sdist.removesuffix(".tar.gz") | ||
| setup_py = os.path.join(source, "setup.py") | ||
| with open(setup_py) as f: | ||
| patched = f.read().replace("-std=c++17", "-std=c++20") | ||
| patched = _only_runner_archs(f.read().replace("-std=c++17", "-std=c++20")) | ||
| with open(setup_py, "w") as f: | ||
| f.write(patched) | ||
| session.run(*pip_wheel, source, env=_FORCE_BUILD[name]) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming: this action is no longer about "extensions" (Triton kernels aren't extensions), and the next cache (Inductor, FlashInfer, numba, ...) would make it worse. Suggest a name that covers any runtime-compiled cache:
.github/actions/cache-extensions->restore-jit-caches,.github/actions/save-extensions->save-jit-caches(matches theactions/cache/restore/saveverbs; "JIT" is already the term in the descriptions)ext-cache->jit-caches, step names "Restore JIT caches" / "Save JIT caches" ingpu_tests.ymland_example_tests_runner.yml<name>-key/<name>-hitpair per cache, socache-key/cache-hit->torch-ext-key/torch-ext-hitnext totriton-key/triton-hit; inputcache-key->env-key(it is the GPU + image discriminator, not a cache key)torch-ext-/triton-: they are per-cache and accurate, and renaming them would invalidate the existing cachesOptional, can be a follow-up: have the restore action write each cache's key/hit to
$GITHUB_ENVand let the save action read them, so adding a cache no longer addswith:inputs to both workflows. Composite actions have no post hook, so the explicitalways()save step stays.Doing the rename here is cheaper than later, since every caller would change again.