Skip to content

[Bug] LongCat-Image-Edit: crash (GPU+offload), mosaic output (CPU) #1788

Description

@Jared-D

Git commit

commit c00a9e9, release master-778
Using prebuilt sd-master-c00a9e9-bin-Linux-Ubuntu-24.04-x86_64-rocm-7.2.1.zip

Operating System & Version

Fedora 44 Linux, x86_64

GGML backends

HIP, CPU

Command-line arguments used

~/stable-diff/sd-cli \
 --diffusion-model ./models/LongCat-Image-GGUF/LongCat-Image-Edit-Q8_0.gguf \
 --vae ./models/LongCat-Image-GGUF/vae/diffusion_pytorch_model.safetensors \
 --llm ./models/Qwen2.5-VL-7B-Instruct-GGUF/Qwen2.5-VL-7B-Instruct.Q8_0.gguf \
 --llm_vision ./models/Qwen2.5-VL-7B-Instruct-GGUF/Qwen2.5-VL-7B-Instruct.mmproj-Q8_0.gguf \
 --offload-to-cpu \
 --max-vram -1 \
 --diffusion-fa \
 -o ./output_edited_image-$(date '+%s').png \
 -p "Change to photo realistic style" \
 --ref-image ./city-512.png \
 --sampling-method euler \
 --flow-shift 3 \
 --cfg-scale 5.0 \
 --steps 20 \
 -v \
 -W 512 -H 512

Steps to reproduce

Run CLI as above.

Crash and stacktrace (full log available below):

[INFO ] conditioner.hpp:2360 - LongCatEditPipeline
[DEBUG] conditioner.hpp:2393 - resize conditioner ref image 0 from 512x512 to 504x504
/home/runner/work/stable-diffusion.cpp/stable-diffusion.cpp/ggml/src/ggml-impl.h:318: fatal error
/opt/working-dir/stable-diff/libggml-base.so.0(+0x1c1ab) [0x7f1af4ec81ab]
/opt/working-dir/stable-diff/libggml-base.so.0(ggml_print_backtrace+0x21c) [0x7f1af4ec862c]
/opt/working-dir/stable-diff/libggml-base.so.0(ggml_abort+0x15b) [0x7f1af4ec880b]
/opt/working-dir/stable-diff/libggml-base.so.0(+0x31364) [0x7f1af4edd364]
/opt/working-dir/stable-diff/libggml-base.so.0(ggml_gallocr_reserve_n_size+0x1b) [0x7f1af4eddf6b]
/opt/working-dir/stable-diff/libstable-diffusion.so(_ZN2sd14ggml_graph_cut30measure_segment_compute_bufferEP12ggml_backendP11ggml_cgraphRKNS0_7SegmentEPKc+0x266) [0x7f1af580fd66]
/opt/working-dir/stable-diff/libstable-diffusion.so(+0x18bb04) [0x7f1af5811b04]
/opt/working-dir/stable-diff/libstable-diffusion.so(_ZN2sd14ggml_graph_cut10build_planEP12ggml_backendP11ggml_cgraphRKSt13unordered_setIPK11ggml_tensorSt4hashIS8_ESt8equal_toIS8_ESaIS8_EEPKc+0x11a0) [0x7f1af5813f70]
/opt/working-dir/stable-diff/libstable-diffusion.so(_ZN2sd14ggml_graph_cut12resolve_planEP12ggml_backendP11ggml_cgraphPNS0_9PlanCacheEmRKSt13unordered_setIPK11ggml_tensorSt4hashISA_ESt8equal_toISA_ESaISA_EEPKc+0xfd) [0x7f1af581579d]
/opt/working-dir/stable-diff/libstable-diffusion.so(_ZN10GGMLRunner22resolve_graph_cut_planEP11ggml_cgraphPN2sd14ggml_graph_cut4PlanEPm+0xdc) [0x7f1af5839ecc]
/opt/working-dir/stable-diff/libstable-diffusion.so(_ZN10GGMLRunner7computeIfEESt8optionalIN2sd6TensorIT_EEESt8functionIFP11ggml_cgraphvEEibbbb+0x4c2) [0x7f1af5862d62]
/opt/working-dir/stable-diff/libstable-diffusion.so(_ZN3LLM9LLMRunner12encode_imageEiRKN2sd6TensorIfEEbbb+0x63) [0x7f1af5a94853]
/opt/working-dir/stable-diff/libstable-diffusion.so(_ZN11LLMEmbedder21get_learned_conditionEiRK17ConditionerParams+0x1aa2) [0x7f1af5abe312]
/opt/working-dir/stable-diff/libstable-diffusion.so(generate_image+0xffe) [0x7f1af591ffbe]
/opt/working-dir/stable-diff/sd-cli(+0x28b1a) [0x557e24be5b1a]
/lib64/libc.so.6(+0x3681) [0x7f1af4f89681]
/lib64/libc.so.6(__libc_start_main+0x88) [0x7f1af4f89798]
/opt/working-dir/stable-diff/sd-cli(+0x29235) [0x557e24be6235]

Reproduces identically (same stack trace) with both --diffusion-model as GGUF Q8_0 and as bf16 safetensors.
Adjusting the following parameters did not seem to fix the crash: without width or height specified, with or without --diffusion-fa, different --flow-shift, different --cfg-scale, different --steps.

For comparison the (non-edit) base LongCat-Image model generated a good text-to-image without mosaic noise (on GPU with --offload-to-cpu), sharing the same VAE and LLM files. So the crash seems specific to LongCat-Image-Edit, not LongCat-Image.

LongCat-Image text to image cli ``` ~/stable-diff/sd-cli \ --diffusion-model ./models/LongCat-Image-GGUF/LongCat-Image-BF16.gguf \ --vae ./models/LongCat-Image-GGUF/vae/diffusion_pytorch_model.safetensors \ --llm ./models/Qwen2.5-VL-7B-Instruct-GGUF/Qwen2.5-VL-7B-Instruct.Q8_0.gguf \ -o ./text2image-test-$(date '+%s').png \ -p "A photo of a city street" \ --sampling-method euler \ --flow-shift 3 \ --cfg-scale 5.0 \ --steps 20 \ -v \ -W 1024 -H 1024 \ --max-vram -1 \ --offload-to-cpu ```

What you expected to happen

To run, not crash, and produce an edited output image.

What actually happened

A crash.

Logs / error messages / stack trace

LongCat-Image-Edit-with-GPU.log

Additional context / environment details

Workaround: --backend cpu avoids the crash.

Secondary issue: mosaic output on --backend cpu

With the crash avoided via --backend cpu, output shows the reference image's overall shape but is covered in mosaic/scrambled block artifacts. A few different image resolutions were tried but with the same scrambled problem.

Command:

~/stable-diff/sd-cli \
 --diffusion-model ./models/LongCat-Image-GGUF/LongCat-Image-Edit-Q8_0.gguf \
 --vae ./models/LongCat-Image-GGUF/vae/diffusion_pytorch_model.safetensors \
 --llm ./models/Qwen2.5-VL-7B-Instruct-GGUF/Qwen2.5-VL-7B-Instruct.Q8_0.gguf \
 --llm_vision ./models/Qwen2.5-VL-7B-Instruct-GGUF/Qwen2.5-VL-7B-Instruct.mmproj-Q8_0.gguf \
 -o ./out.png \
 -p "Change to photo realistic style" \
 --ref-image ./city-512.png \
 --sampling-method euler \
 --flow-shift 3 \
 --cfg-scale 5.0 \
 --steps 5 \
 -v \
 -W 512 -H 512 \
 --backend cpu

Log:
cpu-run.log

Output image:
Image

Reference image:
Image

Running the same sort of edit task using a different (FLUX.1-Kontext-dev) "edit" model does work successfully.

FLUX.1-Kontext-dev image edit cli ``` ~/stable-diff/sd-cli \ --diffusion-model ./models/FLUX.1-Kontext-dev-GGUF/flux1-kontext-dev-Q5_K_M.gguf \ --vae ./models/FLUX.1-dev/ae.safetensors \ --clip_l ./models/flux_text_encoders/clip_l.safetensors \ --t5xxl ./models/flux_text_encoders/t5xxl_fp16.safetensors \ --offload-to-cpu \ --max-vram -1 \ --diffusion-fa \ -o ./output_edited_image-$(date '+%s').png \ -p "Change to photo realistic style" \ --ref-image ./city-512.png \ --sampling-method euler \ --clip-on-cpu \ --cfg-scale 1.0 \ -v \ --steps 20 ```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions