# Conflicts: # studio/backend/core/inference/diffusion.py # studio/frontend/src/features/images/images-page.tsx
4.1 KiB
4.1 KiB
- Decision: shipped compile path uses
transformer.compile_repeated_blocks(fullgraph = True, dynamic = True), which forwards totorch.compile; effective settings arefullgraph=True,dynamic=True, and defaultmode. This was chosen because Studio can vary resolution/batch/steps without excessive recompiles. - Decision: CUDA graphs are not enabled in the shipped path. Per
https://docs.pytorch.org/docs/stable/generated/torch.compile.html, CUDA graphs come frommode="reduce-overhead"ormode="max-autotune", while default mode gives Inductor fusion without graph capture. - Decision:
dynamic=Trueconflicts with CUDA graphs because graph capture expects static shapes. Switching to CUDA graphs would requiredynamic=Falseand recompilation for new shapes. - Decision: after ablation,
defaultmode +dynamic=Trueremained the correct shipped choice because it was essentially as fast as autotune, much faster to compile, robust to shape changes, and avoided CUDA-graph runtime crashes. - Decision:
max-autotune-no-cudagraphsworked but was not worth enabling as default:0.78 svs0.80 swas within run-to-run noise, while compile time increased from5.7 sto66.2 sand requireddynamic=False. - Decision: CUDA graph modes were rejected because they crashed in this pipeline, not merely because they were theoretically fragile.
- Clarification made: since
fullgraph=Truesucceeds, there is no Dynamo graph break in the block; GGUF dequant is compile-traceable. The remaining inefficiency is Inductor declining codegen for Z-Image complex-valued ops:"does not support code generation for complex operators". - File context mentioned but not edited in this span:
diffusion_speed.pycontains the shipped compile call. - File context mentioned but not edited in this span:
compile_probe.pyalready has a--modeflag and was used for mode ablation. - Command run:
LOG=logs/compile_modes_$(date +%Y%m%d_%H%M%S).log; echo "COMPILE MODES LOG: $LOG"; { for spec in "default:--mode default --dynamic" "maxautotune-nocg:--mode max-autotune-no-cudagraphs" "reduce-overhead:--mode reduce-overhead" "max-autotune:--mode max-autotune"; do ...to ablate torch compile modes including CUDA graphs on GPU 6. - Command status: background task
b01iys6fycompleted with exit code0. - Command output file:
/home/ubuntu/CLAUDE_CODE_TMPDIR/claude-1000/-mnt-disks-unslothai-ubuntu-workspace-81/8723b9e3-2ab1-49e9-a4b1-d030954eb94a/tasks/b01iys6fy.output. - Command run:
cat "$(ls -t /mnt/disks/unslothai/ubuntu/workspace_81/unsloth/logs/compile_modes_*.log | head -1)"to read the latest compile-mode ablation log. - Key result:
defaultwith--mode default --dynamicgave eager1.82s/gen, compiled0.80s/gen,+56.3% vs eager, PSNR37.7 dB, compile time5.7s, verdictCOMPILE-WORKS FASTER. - Key result:
max-autotune-no-cudagraphswithdynamic=Falsegave eager1.83s/gen, compiled0.78 s,+57.2%, PSNR37.3 dB, compile time66.2 s, and worked. - Key result:
reduce-overheadwith CUDA graphs anddynamic=Falsefailed. - Key result:
max-autotunewith CUDA graphs anddynamic=Falsefailed. - Error encountered: both CUDA graph modes raised
RuntimeError: accessing tensor output of CUDAGraphs that has been overwritten by a subsequent runattransformer_z_image.py:271, in forward. - Error analysis: likely caused by regional compile plus CUDA graph output buffer reuse; denoiser calls the same compiled block repeatedly and Z-Image carries an output across calls, so the static CUDA graph output buffer is overwritten before a later read.
- Error resolution: resolved by keeping CUDA graphs disabled; no code changes were made to try manual
cudagraph_mark_step_begin()or output cloning. - Completed: answered why CUDA graphs were not being used and measured
default,max-autotune-no-cudagraphs,reduce-overhead, andmax-autotune. - Completed: reported mode-by-mode speed, PSNR, compile time, and failure status.
- Pending: optional follow-up offered to wire
mode="max-autotune-no-cudagraphs"into the opt-inmaxtier as a gated one-line change, leaving default unchanged.