gemma4 (LTX-2.5) text encoder crashes with hipErrorProfilerNotInitialized on gfx1151 / ROCm 10.1 - all SDPA backends
Describe the bug
The LTX-2.5 text encoder (gemma4-12b, gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors) crashes the GPU path on AMD gfx1151 (Ryzen AI MAX+ 395 / Radeon 8060S) + ROCm 10.1 + torch 2.14.0+rocm10.1.0 (stable) with:
CUDA error: profiler is not initialized
Search for `hipErrorProfilerNotInitialized' in https://rocm.docs.amd.com/projects/HIP/en/latest/index.html
The crash occurs ~4s after queueing, during the encoder's first forward pass (GTT +4.5GB at death), in comfy/text_encoders/gemma4.py's optimized_attention_for_device(device, mask=..., small_input=True) → attention_pytorch (SDPA) path.
Verified NOT backend-specific — crashes identically under all three configurations:
--use-pytorch-cross-attention+TORCH_ROCM_FA_PREFER_CK=1(CK)--use-pytorch-cross-attention+TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1(AOTriton)- Pure default env (both vars removed)
Only the gemma4 encoder is affected — qwen3vl-8b (Qwen-Image-2.1), MiniMax-H3 and the LTX-2.5 DiT itself run fine on the same stack. The flash-attn package is not installed (CDNA-only; gfx1151 cannot build it), so attention_pytorch here means torch SDPA dispatch.
Workarounds that work
CLIPLoader.device = "cpu"— CPU encoding (cold ~107s incl. load, warm ~30-60s).- Route gemma4's
small_inputattention to ComfyUI's built-in math implementation — a custom node that patchescomfy.text_encoders.gemma4.optimized_attention_for_deviceto returnattention_basicwhensmall_input=True(identical signature incl.skip_reshape/scale/enable_gqa). GPU stays resident; run completes. Warm-run cost: math attention is ~12% slower than the CPU-encode path, cold-run is ~2x faster.
To reproduce
Environment: ComfyUI v0.41.1, bare-metal venv, systemd service, env HSA_USE_SVM=0, HSA_ENABLE_SDMA=0, COMFYUI_ENABLE_MIOPEN=1. Workflow: LTX-2.5 t2v (official video_ltx2_5_t2v.json graph), CLIPLoader type ltxv with device left default, 97 frames. Deterministic: crashes 4/4 attempts across the three env configurations above.
Expected behavior
Either the SDPA small-input path should work for gemma4 GQA/skip_reshape shapes on gfx1151/ROCm 10.1, or ComfyUI could route encoder small_input attention to attention_basic on this platform.
Happy to run any diagnostic (rocminfo/torch builds/profiler traces) on request — we have a clean 5-minute repro harness.
I've been investigating this on another Radeon 8060S / gfx1151 system as part of a CUDA→AMD compatibility diagnostic project.
We prepared an opt-in, Gemma4-only source candidate that selects ComfyUI's existing attention_basic for small_input=True on ROCm gfx1151, preserving the default behaviour elsewhere. So far:
- 13/13 isolated source-level routing tests pass.
- 9/9 real GPU math-attention numerical tests (FP16/BF16/FP32) pass against a separate float64 CPU reference.
- An isolated SDPA vs math comparison also passes 9/9 on Windows, PyTorch 2.9.1, ROCm 7.2; largest observed absolute difference is ~0.000977.
This is not a reproduction or confirmed fix for your issue: your failing environment is Linux ROCm 10.1 / PyTorch 2.14, and we did not run LTX-2.5 end-to-end. PyTorch's backend warnings in our test also do not establish which SDPA kernel was selected.
Would you be able to share a minimal, model-weight-free capture from the Gemma4 attention call immediately before the error, containing:
- Q/K/V shapes, dtypes, strides and device; mask shape/dtype (or
None),skip_reshape,scale, andenable_gqa. - The fresh-process error/stack and backend-selection/environment flags (CK/AOTriton/default).
- If possible, a same-tensor comparison of the failing original SDPA route versus
attention_basicwithtorch.cuda.synchronize()after each, recording success/error separately.
The already reported successful math fallback is encouraging. These details would let us test the exact failing configuration and assess a narrowly scoped upstream-compatible change without claiming an unverified fix. No model weights or private prompts are needed.