[ROCm] Intermittent HIP error at the first dtype cast on a cold process — LongCat Avatar INT8, RX 7800 XT

Open
#18,055 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python, pytorch

Research direction

Start with the reported tensor copy in comfy/model_base.py (_apply_model and convert_tensor) and the weight cast path in comfy/ops.py (forward_comfy_cast_weights, cast_bias_weight, and cast_to). Compare a failing first run in a fresh process with a successful later run, capturing HIP traces and logs as requested in the issue. Done means isolating whether the first large GPU transfers fail in ComfyUI or ROCm/HIP; the issue provides no confirmed cause.

Written by the indexing model from the issue text.

Description

Summary

Running a merged single-file build of LongCat-Video-Avatar 1.6 (INT8 ConvRot) on the official ComfyUI AMD portable build, the process intermittently dies with a HIP error right at the start of sampling, at the first dtype cast. The failure only strikes the first run of a fresh process; the second and later runs in the same process pass.

We are posting this as a case report for triage, not as a confirmed bug in ComfyUI: the root cause is undetermined, and we could not isolate whether it sits on the ComfyUI side or the ROCm/HIP side. We are hoping for pointers on how to narrow it down.

Environment

  • GPU: Radeon RX 7800 XT (16GB VRAM)
  • CPU: Ryzen 7 7700 / RAM: 32GB
  • OS: Windows
  • ComfyUI v0.45.0, official AMD portable build
  • torch 2.9.1+rocm7.2.1
  • Adrenalin 26.11.2 (driver 32.0.32029.2010)

Model

  • LongCat-Video-Avatar 1.6 (upstream: MIT License, Meituan), merged with its DMD distillation LoRA and quantized to INT8 ConvRot as a single .safetensors file, loaded in ComfyUI as-is.

Symptom

  • The crash happens immediately after sampling starts, at the first dtype cast (cast_to family; the first observed instance was audio_embeds, fp32→bf16, ~11.9MB).
  • The failure surfaces as torch.AcceleratorError: HIP error: invalid argument (hipErrorInvalidValue), raised from a tensor copy inside cast_to_device called by convert_tensor in comfy/model_base.py (_apply_model, line 242), at the very start of sampling on the first run of a fresh process. Instrumented runs identified the failing operation as the process's first dtype conversion: the audio_embeds conditioning tensor (fp32, [1, 93, 5, 5, 1280], 11.9 MB) cast to bf16. The identical conversion succeeds on every subsequent run in the same process.
  • A second form of the same exception occurs on the weight-cast path (comfy/ops.py, forward_comfy_cast_weights → cast_bias_weight → cast_to), and this one kills the server process itself: the server log ends with a ROCm CLR line ("Memobj map does not have ptr"), and Windows records Application Error (Id 1000) for python.exe — faulting module amdhip64_7.dll, exception code 0xc0000409 (fail-fast abort); WER (Id 1001) reports BEX64, subcode 7.
  • Similar failures were also observed at other copy points within the same start-of-sampling window; the failing copy differs per run, but all belong to the first large GPU transfers right after sampling starts.
  • It only occurs on the first run of a new process. If the first run survives, subsequent runs in the same process are stable.
  • A related observation: around model unload, the commit charge can surge sharply (one captured case: +13.5GB within seconds after a step completed, also recorded in Windows Event 2004). With the pagefile fixed at 80GB (commit limit 111.09GB) this class of death largely disappeared; an explicit /free between runs brings commit back down (measured 66.46GB → 40.03GB within 15 seconds).

Statistics (measured over several weeks of testing)

  • Cold first run of a fresh process: crashed in 14 of 26 attempts.
  • Second run in the same process: passed 22 of 23.
  • After adopting a workaround routine — start a fresh process, run one dummy generation with identical inputs first (it takes the fall if there is one), wait, then run the real job — warm entries completed 22 of 22.

What we ruled out

Each of the following was tested and did not fix the entry crash on its own:

  • Synchronous dtype conversion
  • Switching the allocator backend (cudaMallocAsync) — froze silently instead
  • expandable_segments
  • Adjusting memory occupancy / reservation levels
  • Any single transfer type in isolation

The failures cluster on one call family (cast_to), but we could not distinguish a ComfyUI-side cause from a ROCm/HIP-side cause with the measurements available to us.

What we are asking

  1. Does this signature (first-run-only HIP error at the first cast, stable afterwards) match any known issue?
  2. Any pointers on where to look next for isolating the layer at fault?
  3. If there are specific logs or traces (HIP traces, etc.) we should capture on the next occurrence, please tell us what to collect — we can reproduce the setup and gather them.

Thank you for reading. We are happy to run additional tests on this hardware.

Dominant language
Python
Stars
150k
Forks
17.9k
Avg merge
1d 1h
Merged PRs (30d)
181

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Comfy-Org/ComfyUI

All issues in Comfy-Org/ComfyUI

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.