Skip to content

Studio: run the int8 / fp8 Triton widen on the operand's GPU - #17133

Merged
danielhanchen merged 1 commit into
mainfrom
studio-fp8-widen-operand-device
Nov 8, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
studio-fp8-widen-operand-device

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #17068.

Problem

dequant_rows launched 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() then get_current_stream(device) in JITFunction.run: v3.2.0, v3.7.1), and torch.cuda.is_current_stream_capturing() also describes the current device's stream. A layer on cuda:1 called while cuda:0 is current (an external device_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_weight takes the pure torch path under torch.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 see cuda:1 while the caller stays on cuda: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 on cuda:1 widen through Triton with device 0 current, bitwise equal to the old formula, and the failure latch stays clear.
origin/main this branch
tests/test_diffusion_fp8_dequant.py (CPU) 1 failed, 39 passed, 12 skipped 40 passed, 12 skipped

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 this branch
device current at the Triton launch 0 1
_TRITON_STATE["failed"] after one call ValueError('Pointer argument (at 0) cannot be accessed from Triton (cpu tensor?)') None
result exact (chunked torch fallback), fused widen now off for the process exact, through Triton

tests/test_diffusion_fp8_dequant.py on that host (the two-GPU and single-GPU Triton cases included): 52 passed.

@danielhanchen danielhanchen self-assigned this Nov 8, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T09:53:40.636300Z 9f25579 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 9f255796c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant