Repository navigation
fix(compile): apply dynamo settings per call -- serving threads saw a limit of 8 (#47) - #57
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #57 +/- ##
==========================================
+ Coverage 79.45% 79.54% +0.08%
==========================================
Files 42 42
Lines 3218 3226 +8
==========================================
+ Hits 2557 2566 +9
+ Misses 661 660 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
… limit of 8 (#47) install_compiled_blocks set torch._dynamo.config.recompile_limit and suppress_errors once, on the installing thread. Dynamo's config overrides are ContextVars, so fits and predicts on engine/worker threads and asyncio.to_thread saw the defaults: a recompile limit of 8, hit at the first graph past warmup's 54 (as on prod's four A40 workers), after which dynamo stops compiling the blocks for the process -- every later fit ran eagerly -- and compile errors raised instead of falling back. with_compile_settings wraps the compiled forward in config.patch (one shared ConfigPatch; its saved state is itself a ContextVar stack, so it is safe across threads and nested calls; ~4 us per call). The settings no longer leak to other torch.compile users in the process. A100, every call on a separate thread (bench_stalls --call-thread): 3500x500 fit 2.31 -> 1.61 s, 3500x1000 5.49 -> 3.50 s; graphs past warmup now compile once instead of never. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…at install too - Dynamo also caps a code object's graphs at accumulated_recompile_limit (256), checked first, so the per-device recompile_limit above 256 had no effect; both are raised now (compile_settings). - with_compile_settings also sets them for the installing thread: on a torch whose config is process-wide, every call's shared patch then saves and restores the same values, so concurrent calls can't restore the defaults under one another. - Tests: an end-to-end CPU regression (eager backend: 10 graphs on one thread, then a new shape on another must compile -- fails with install-time-only settings), restore-on-raise, both limits. - CHANGELOG: past the limit dynamo compiles no new graph (warmed shapes keep theirs); the 3,500-row gains came from graphs built by the sweep's earlier 30k-row fits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
amrit110
force-pushed
the
perf/wide-fit-compiles
branch
from
October 20, 2026 21:27
5181ab1 to
c3c4c11
Compare
Member
Author
|
Review fixes pushed. The independent review reproduced the fix end to end on CPU.
Next, a separate PR in #47: a first 3,500 × 500 fit still compiles 3 graphs (12.7 s), and 30,000-row tables compile 2. Warmup should cover those families. |
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.
Part of #47.
Problem
install_compiled_blockssettorch._dynamo.config.recompile_limit(256 per GPU) andsuppress_errorsonce, on the thread that installs the blocks. Dynamo's config overrides are per thread (each is aContextVar). I verified this: a value set on one thread reads back as the default on another.Serving runs fits and predicts on other threads: engine and worker threads, and
asyncio.to_thread. Those threads saw dynamo's defaults:[0/54] torch._dynamo hit config.recompile_limit (8), at the first graph after warmup's 54. After that, dynamo stops compiling the block for the life of the process, so every later TabICL fit ran eagerly, including shapes warmup had compiled.suppress_errors=False. A compile error would fail the tenant's fit instead of falling back to eager, as the docs promise.I reproduced the exact prod warning on the A100 devbox with
bench_stalls.py --call-thread, which makes every call on a separate thread, as serving does.Fix
with_compile_settings: wraps the compiled forward inconfig.patch(...). One sharedConfigPatchserves every call; its saved state is itself aContextVarstack, so it is safe across threads and nested calls.torch.compileusers in the process.Results
A100, TabICL, every call on a separate thread. Data in
baselines/compile-call-thread-a100-{before,after}.jsonl.Predicts are unchanged: 0.05–0.18 s across all shapes.
Still open in #47
Shapes warmup doesn't cover now compile once per worker, instead of running eagerly forever:
q(recompile reason: stride mismatch, 128 vs 3,840,000). That costs 1–7 graphs, and the first such fit takes 5–25 s.Covering these in warmup, or avoiding the stride guard, is the next step. This PR documents the cost in
tabicl_compile.py.Tests
tests/unit/test_tabicl_compile.py:asyncio.to_thread.bench_stalls.pygains--tasksand--call-thread.Docs
tabicl_compile.pydocstring: the "Settings" section explains why the settings are applied per call, and the in-request compile costs use the measured numbers.🤖 Generated with Claude Code