Skip to content

Commit

Permalink
Allow FP16 accumulation with --fast
Browse files Browse the repository at this point in the history
Currently only applies to PyTorch nightly releases. (>=20250112)
  • Loading branch information
catboxanon committed Jan 13, 2025
1 parent 1f1c7b7 commit 6789f3d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions comfy/model_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ def is_amd():
torch.backends.cuda.enable_flash_sdp(True)
torch.backends.cuda.enable_mem_efficient_sdp(True)

try:
if is_nvidia() and args.fast:
torch.backends.cuda.matmul.allow_fp16_accumulation = True
except:
pass

try:
if int(torch_version[0]) == 2 and int(torch_version[2]) >= 5:
torch.backends.cuda.allow_fp16_bf16_reduction_math_sdp(True)
Expand Down

0 comments on commit 6789f3d

Please sign in to comment.