Repository navigation
Studio: run the int8 / fp8 Triton widen on the operand's GPU - #17133
Merged
Merged
Conversation
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. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
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.
Follow-up to #17068.
Problem
dequant_rowslaunched the int8 / stored-fp8 Triton widen and ran its CUDA-graph capture probe without making the operand's GPU current. Triton picks the launch device and stream from the current device, not from the tensor arguments (driver.active.get_current_device()thenget_current_stream(device)inJITFunction.run: v3.2.0, v3.7.1), andtorch.cuda.is_current_stream_capturing()also describes the current device's stream. A layer oncuda:1called whilecuda:0is current (an externaldevice_map/ Accelerate placement, which moves tensors without a device scope) therefore launches against the wrong device and stream; a rejected launch is caught and sets the process-wide_TRITON_STATE["failed"], which turns the fused widen off for every later layer. The packed nvfp4 launcher from #17067 already scopes its launch this way.Fix
Both the eligibility check (capture probe included) and the launch now run inside
torch.cuda.device(codes.device)when the codes are on CUDA (a null context otherwise, so the CPU / MPS paths are unchanged). The widen only runs in eager (_stored_weighttakes the pure torch path undertorch.compiler.is_compiling()), so nothing changes inside compiled graphs.Tests
test_the_triton_capture_probe_and_launch_run_on_the_operands_device(CPU, device context and capture probe recorded): both seecuda:1while the caller stays oncuda:0, and the caller's device is current again afterwards.test_the_triton_widen_of_a_layer_on_a_non_current_gpu(needs two GPUs): int8, e4m3 and e5m2 layers oncuda:1widen through Triton with device 0 current, bitwise equal to the old formula, and the failure latch stays clear.origin/maintests/test_diffusion_fp8_dequant.py(CPU)Two GPUs (Kaggle T4 x2, torch 2.11, triton 3.6), device 0 current, an int8 and an e4m3 layer on
cuda:1,_stored_weight(torch.bfloat16):origin/main_TRITON_STATE["failed"]after one callValueError('Pointer argument (at 0) cannot be accessed from Triton (cpu tensor?)')tests/test_diffusion_fp8_dequant.pyon that host (the two-GPU and single-GPU Triton cases included): 52 passed.