Repository navigation
Studio small-host INT8: armed layers compile once (eager-only call counters, follow-up to #17167) - #17193
Merged
Conversation
…a compiled armed layer compiles once
Member
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
[skip ci]
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
Follow-up to #17167. That PR arms the existing small-host INT8 layers (
Int8WeightLinear.act_int8 = True) for an explicit Turing INT8 request, so families such as FLUX.1 now run with armed layers too. Every forward of an armed layer increments a module-level diagnostic counter (_INT8_ACT_COUNTS["dequant"]on the weight-only branch,["int8_act"]on the W8A8 branch). Undertorch.compile, Dynamo guards on the exact value of that global int, so each call invalidates the last graph and recompiles:fullgraph=True: call 9 raisesFailOnRecompileLimitHitAn fp16 pipeline makes it worse.
_int8_act_okdeclines fp16 on the dtype check, so the newly armed layer takes the weight-only dequant branch exactly as before, except that it now also bumps the counter.Fix
The counters are eager-only diagnostics, and nothing in the backend reads them during a render.
forwardnow skips the increment whentorch.compiler.is_compiling()is true. Inside a trace that check is a constant, so it adds no graph break. Eager counting is unchanged. The math on both branches is unchanged, andUNSLOTH_DIFFUSION_SMALL_HOST_INT8_ACT=0still turns W8A8 off.Test (CPU, torch 2.12.1)
test_diffusion_small_host_int8_act.py::test_armed_layer_compiles_once_and_still_counts_eager_callsbuilds a real armedInt8WeightLinearin fp16, so it takes the dequant branch. An eager call bumps the counter by one. The test then compiles the layer withfullgraph=Trueand a frame-counting backend and runs 12 calls.FailOnRecompileLimitHit: Hard failure due to fullgraph=TrueAll small-host test files (
test_diffusion_small_host*.py,test_video_small_host.py): 127 passed, 7 skipped.Not covered
torch._int_mm) takes the same counter change, but it was not compiled on a T4 here.