Open
【11月贡献大赛-缺陷修复】docs(diffusers-ascend-adaptation): 纠正 bf16 与黑图归因,更新 FLUX 显存口径 #7330
【11月贡献大赛-缺陷修复】docs(diffusers-ascend-adaptation): 纠正 bf16 与黑图归因,更新 FLUX 显存口径 #7330
Open
饼酥Add on 7 hours ago
Total: 1 files changed+5-3
@@ -276,10 +276,12 @@ hardware: NPU
276| `AttributeError: module 'diffusers' has no attribute 'Flux2KleinPipeline'` | diffusers version too old | Upgrade diffusers >= 0.38.0 | Reinstall dependencies |276| `AttributeError: module 'diffusers' has no attribute 'Flux2KleinPipeline'` | diffusers version too old | Upgrade diffusers >= 0.38.0 | Reinstall dependencies |
277| `KeyError` in `model_index.json` loading | Corrupt checkpoint or missing shards | Re-download weights | Verify file manifest |277| `KeyError` in `model_index.json` loading | Corrupt checkpoint or missing shards | Re-download weights | Verify file manifest |
278| RuntimeError on `scaled_dot_product_attention` | torch_npu sdpa incompatibility | Export `TORCH_NPU_SDT_FA_ENABLE=0` | Environment variable toggle |278| RuntimeError on `scaled_dot_product_attention` | torch_npu sdpa incompatibility | Export `TORCH_NPU_SDT_FA_ENABLE=0` | Environment variable toggle |
279-| Output is pure noise / black image | bfloat16 unsupported on NPU | Switch to `torch.float16` | Dtype fallback |279+| Output is pure noise / black image | VAE 精度不足(fp16/bf16 溢出),不是 bf16 本身不支持 | VAE 保持 fp32,并在 decode 前把 latents cast 到 VAE dtype | 仍异常时把整条 pipeline 降到 fp32 复测 |
280| `ImportError: cannot import name 'Qwen3ForCausalLM'` | transformers < 4.57.0 | Upgrade transformers | Reinstall dependencies |280| `ImportError: cannot import name 'Qwen3ForCausalLM'` | transformers < 4.57.0 | Upgrade transformers | Reinstall dependencies |
281| Pipeline loads but NPU inference hangs | CANN driver / runtime mismatch | Check CANN version >= 8.0 | Reinstall CANN toolkit |281| Pipeline loads but NPU inference hangs | CANN driver / runtime mismatch | Check CANN version >= 8.0 | Reinstall CANN toolkit |
282 282 
283+> 实测(Ascend910_9362 / CANN 9.2.1 / diffusers 0.35.1):FLUX.1-schnell 在 bfloat16 下可正常出图,1024×1024 峰值 36.34 GB;VAE 换 bf16 后峰值 33.80 GB,同 seed 对比 PSNR 53.18 dB。黑图来自 VAE 精度不足,而不是 bf16 不受支持。
284+ 
283### Resolution & Memory Bounds285### Resolution & Memory Bounds
284 286 
285| Resolution | Approx. Peak Memory | Status |287| Resolution | Approx. Peak Memory | Status |
@@ -307,7 +309,7 @@ When inference fails, follow this ordered approach:
307 ↓309 ↓
3083. Reduce num_inference_steps to 10 to isolate stepwise failures3103. Reduce num_inference_steps to 10 to isolate stepwise failures
309 ↓311 ↓
310-4. Use torch.float16 instead of bfloat16 for dtype compatibility312+4. Keep the transformer in bfloat16 (supported on Ascend 910) and check the VAE separately: keep VAE in float32 and cast latents before decode
311 ↓313 ↓
3125. Set torch.npu.set_per_process_memory_fraction(0.8) to limit memory3145. Set torch.npu.set_per_process_memory_fraction(0.8) to limit memory
313 ↓315 ↓
@@ -322,7 +324,7 @@ When inference fails, follow this ordered approach:
322 324 
323| Model Family | Pipeline Class | Key Component | Typical Memory |325| Model Family | Pipeline Class | Key Component | Typical Memory |
324| ------------ | --------------------------------- | ----------------------- | -------------- |326| ------------ | --------------------------------- | ----------------------- | -------------- |
325-| FLUX.1/2 | FluxPipeline / Flux2KleinPipeline | Flux2Transformer2DModel | ~15 GB (bf16) |327+| FLUX.1/2 | FluxPipeline / Flux2KleinPipeline | Flux2Transformer2DModel | ~32-36 GB (bf16, 1024×1024) |
326| SD 1.5 | StableDiffusionPipeline | UNet2DConditionModel | ~4-6 GB (fp16) |328| SD 1.5 | StableDiffusionPipeline | UNet2DConditionModel | ~4-6 GB (fp16) |
327| SDXL | StableDiffusionXLPipeline | UNet2DConditionModel | ~6-8 GB (fp16) |329| SDXL | StableDiffusionXLPipeline | UNet2DConditionModel | ~6-8 GB (fp16) |
328 330