RES4LYF res_2s crash when sigma list is empty (IndexError + CUDA illegal memory access)
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
# RES4LYF `res_2s` sampler crashes when scheduler returns zero-length sigmas
## Issue
- **Title**: RES4LYF `res_2s` sampler raises `IndexError` / CUDA illegal memory access when `sigmas` is empty
- **Evidence**: `comfyui.service` logs around `2026-04-07 10:48` show:
- `IndexError: index -1 is out of bounds for dimension 0 with size 0` inside `custom_nodes/RES4LYF/beta/rk_noise_sampler_beta.py:820`.
- cascading `torch.AcceleratorError: CUDA error: an illegal memory access was encountered` after the sampler catches the error and `torch.cuda.synchronize()` runs.
- `systemctl status comfyui.service` reports `NRestarts=3`.
- **Repro**: open `/home/tools/ComfyUI_next/user/default/workflows/ComfyUI_temp_sdjcl_00001_.json`, run the workflow that uses `KSampler` with `res_2s` + scheduler `beta57`, and the crash happens before sampling begins.
- **Expect**: `prepare_sigmas` should guard against zero-length tensors or fail with a controlled exception so we don’t hit the GPU kernel and the service can keep running.
## PR
- **Changes**:
- in `beta/rk_noise_sampler_beta.py`, ensure `sigmas` never stays empty (fallback to `[SIGMA_MIN]`) and limit `sigmas[-1]`/`sigmas[-2]` access to when at least two elements exist.
- the existing logic that trims/extends `sigmas` otherwise remains untouched so other samplers behave identically.
- **Results**: service restarts cleanly, same workflow can run past scheduler setup, and logs no longer display the illegal memory access.
Contributor guide
Assessment
This issue has not been assessed yet.