Persist trainer Triton/TorchInductor kernel caches in a Modal Volume - #65
Merged
Merged
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'DevinAI' or '@devin'.
|
Contributor
Author
|
/devin review |
Contributor
Contributor
|
Nice!! wondering if there's any more caching we can do to bring down the cold start times even more ref: https://research.nvidia.com/labs/nemotron/files/NVIDIA-Nemotron-3-Ultra-Technical-Report.pdf table 9 in particular, looks like SGLANG_CACHE_DIR is not set, and setting FLASHINFER_WORKSPACE_BASE might help too |
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.
Summary
Lilo port of modal-projects/stitch#251. Every trainer definition runs with
single_use_containers=True, so each trainer instance recompiled all Triton/Inductor kernels from scratch. This mounts one shared v2 Volume and points both compilers at it so later containers reuse earlier compiles.New
lilo/providers/modal/kernel_cache.py:Wired into all 13 trainer definitions (the
_singlevariant inherits via the shared module) and the scoped trainer:TRAINER_VOLUMES = { ..., CHECKPOINT_ROOT: checkpoint_volume, + KERNEL_CACHE_ROOT: kernel_cache_volume, } ... backend_env={ + **KERNEL_CACHE_ENV, # first, so per-definition entries can override "LILO_BACKEND_CONFIG": ...,run_engine_with_backendmergesbackend_envinto the backend subprocess env, and a locally started Ray cluster inherits it. For the pre-existing-cluster path (256k multi-node),miles_runtime._WORKER_ENV_VARSnow also forwardsTRITON_CACHE_DIR/TORCHINDUCTOR_CACHE_DIRviaruntime_envso actors on worker nodes write to the same volume.No explicit
commit(); v2 Volumes flush in the background and on container shutdown, same as #251.Measurement
qwen3_8_27b_miles_lora_64k(H200:8, TP4/CP2, LoRA rank 32) inlilo-deploy, ephemeral app built from this branch. Cold =lilo-kernel-cachewiped (triton/andinductor/deleted) before the run; warm = a fresh trainer container ~10 min later against the populated volume. Each run: fwd/bwd+optim at 128 tokens, then 65,536 tokens, then both again.Container start → ready for first step (Ray boot, actor init, HF→Megatron weight load; ~3–4 min) is not affected by this change — no Triton/Inductor compile happens in that phase.
Cache contents after the cold run: 574 Triton kernel dirs, Inductor
fxgraph/(231) +aotautograd/(232) entries. The Triton dir count did not change after the warm run, i.e. every Triton kernel was a cache hit and no new kernels were compiled.Takeaway: ~1.5 min saved per trainer start on this definition. The remaining ~140 s of the warm first step is not Triton/Inductor compile — it is dynamo tracing, autotune benchmarking, CUDA-graph capture and NCCL/TE warm-up that run every time regardless of cache. The 23 min Stitch saw on the 35B-A3B NVFP4 recipe does not transfer to this dense LoRA recipe. Also, trainer provisioning time was dominated by H200:8 queue wait (13 min on the cold run, ~2.5 min on the warm run) and is unaffected by this change.
Link to Devin session: https://modal.devinenterprise.com/sessions/21fe6974a320455ead92283cec40e59a
Open in Devin Desktop: https://modal.devinenterprise.com/desktop/session/21fe6974a320455ead92283cec40e59a?variant=devin
Requested by: @micahtyong