Comfy-Org / Comfy-Org/ComfyUI

LTX-AV text encoder crashes on RTX 5090 Blackwell - Fix: torch.neg in llama.py line 440

Open
#13,977 0 comments 0 reactions 0 assignees View on GitHub
Potential Bug
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

### Custom Node Testing

- [ ] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)

### Expected Behavior

LTX-AV workflow runs successfully using the Gemma3 text encoder on RTX 5090

### Actual Behavior

Text encoder crashes during CLIPTextEncode. With older drivers:
torch.AcceleratorError CUDA unknown error. With newer drivers: Windows fatal
exception access violation. Both originate from the same line in llama.py.

### Steps to Reproduce

1. RTX 5090 (Blackwell) on Windows with PyTorch cu130
2. Run any LTX-AV workflow that uses the Gemma3 12B text encoder
3. Workflow crashes immediately during text encoding

### Debug Logs

```powershell
Exception Type: torch.AcceleratorError
Exception Message: CUDA error: unknown error

File "L:\ComfyUI_windows_portable\ComfyUI\comfy\text_encoders\llama.py", line 834, in forward
return self.model(input_ids, *args, **kwargs)
File "L:\ComfyUI_windows_portable\ComfyUI\comfy\text_encoders\llama.py", line 720, in forward
freqs_cis = self.compute_freqs_cis(position_ids, x.device)
File "L:\ComfyUI_windows_portable\ComfyUI\comfy\text_encoders\llama.py", line 698, in compute_freqs_cis
return precompute_freqs_cis(...)
File "L:\ComfyUI_windows_portable\ComfyUI\comfy\text_encoders\llama.py", line 440, in precompute_freqs_cis
out.append((cos, sin[..., : sin_split], -sin[..., sin_split :]))
torch.AcceleratorError: CUDA error: unknown error

System: Windows, RTX 5090, PyTorch 2.12.0+cu130, ComfyUI 0.21.1
```

### Other

Root cause: comfy/text_encoders/llama.py line 440

Broken:
out.append((cos, sin[..., : sin_split], -sin[..., sin_split :]))

Fix:
out.append((cos, sin[..., : sin_split], torch.neg(sin[..., sin_split :])))

The unary minus operator on a CUDA tensor breaks on Blackwell/cu130 during
RoPE (rotary position embedding) computation for the Gemma3 text encoder.
Replacing with torch.neg() resolves it completely.

Note: This crash also triggers cascading DynamicVRAM/RAM exhaustion as a
secondary effect, which causes people to misdiagnose it as a memory issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.