we166488/LongCat-Image-Edit-Turbo
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

LongCat-Image-Edit-Turbo NPU Adaptation Report

Model Information

ItemValue
ModelLongCat-Image-Edit-Turbo
Sourcemeituan-longcat/LongCat-Image-Edit-Turbo (ModelScope)
TaskImage-to-Image Editing
PipelineLongCatImageEditPipeline (diffusers)
Base ModelDiffusers-based distilled editing model
NFEs8 (optimized for low latency)

Environment

ComponentVersion
HardwareAscend910_9362
NPU Count2
CANN8.5.1
Python3.11.14
torch2.9.0+cpu
torch_npu2.9.0.post1
diffusersinstalled from source (git+https://github.com/huggingface/diffusers)
transformers>= 4.45.0

Files

FileDescription
inference.pyNPU inference script with CLI args
evaluate_perf.pyPerformance benchmark script
evaluate_accuracy.pyAccuracy validation script
output_npu.pngSample output from NPU inference
perf_results.txtPerformance benchmark results
accuracy_outputs/Accuracy evaluation outputs and metrics

Usage

Basic NPU Inference

python inference.py \
  --model_path /path/to/model \
  --image_path /path/to/image.png \
  --prompt "将猫变成狗" \
  --output_path output.png \
  --dtype bfloat16 \
  --device npu

Performance Benchmark

python evaluate_perf.py \
  --dtype bfloat16 \
  --warmup_iters 3 \
  --bench_iters 10

Accuracy Validation

python evaluate_accuracy.py

Performance Results

Configuration: NPU bfloat16, 8 inference steps, seed=43

MetricValue
Model Load Time~14.1s
Average Latency6.232s
Min Latency6.229s
Max Latency6.235s
P50 Latency6.233s
P90 Latency6.235s
StdDev0.002s
Throughput0.16 images/sec

Note: Throughput measured with single-image generation (num_images_per_prompt=1).

Accuracy Results

Test 1: Determinism (bfloat16, same seed)

MetricValue
MSE0.000000
MAE0.000000
PSNRinf dB
Relative Error0.0000%
StatusPASS

Interpretation: Two consecutive NPU bfloat16 runs with identical seed produce pixel-perfect identical outputs. NPU inference is fully deterministic and reproducible.

Test 2: Cross-Precision (float16 vs bfloat16)

MetricValue
MSE14550.84
MAE102.35
PSNR6.50 dB
Relative Error40.14%
StatusFAIL

Interpretation: float16 inference produces invalid/corrupted output (invalid value encountered in cast warning during image post-processing). This indicates float16 numerical instability in this model architecture (likely due to the Qwen2.5-VL language model component). bfloat16 is the recommended dtype for NPU deployment.

Baseline Note

CPU float32 baseline was omitted due to excessive memory requirements (>64 GB RAM estimated) and impractical runtime. NPU self-consistency (determinism) and cross-precision checks serve as the practical accuracy validation methodology for this hardware configuration.

Key Findings

  1. NPU bfloat16 inference is fully functional and deterministic. The model runs successfully on Ascend910_9362 with consistent, reproducible outputs.
  2. float16 is not recommended. The model exhibits numerical instability under float16, producing corrupted images. Use bfloat16 for all production deployments.
  3. Latency is stable. P90 latency is within 0.05% of average, indicating consistent performance without significant tail latency.
  4. 8-step Turbo mode works as advertised. The distilled pipeline completes inference in ~6.2s per image on a single NPU.

Recommendations

  • Always use torch.bfloat16 for this model on Ascend NPU.
  • Set generator=torch.Generator(device="npu").manual_seed(seed) for reproducible results.
  • For text rendering tasks, enclose target text in quotation marks as per the official model documentation.
  • Consider model CPU offloading (pipe.enable_model_cpu_offload()) if running on devices with limited NPU memory.