lllyasviel / lllyasviel/stable-diffusion-webui-forge
macOS Sequoia 15.1.1 (intel, AMD) - with MPS and PyTorch (BFloat16 Unsupported)
- Dominant language
- Python
- Stars
- 13k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
**Models Used, check screenshot below**
**Main Error**
TypeError: BFloat16 is not supported on MPS
BFloat16 is not supported on MPS
**Log details**
stable-diffusion-webui-forge % ./webui.sh
################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye), Fedora 34+ and openSUSE Leap 15.4 or newer.
################################################################
################################################################
Running on user
################################################################
################################################################
Repo already cloned, using it as install directory
################################################################
################################################################
Create and activate python venv
################################################################
################################################################
Launching launch.py...
################################################################
Python 3.10.12 (main, Jul 5 2023, 15:34:07) [Clang 14.0.6 ]
Version: f2.0.1v1.10.1-previous-626-ga332f7cc
Commit hash: a332f7cca35989412c7add36040d78694398b64b
Installing requirements
Legacy Preprocessor init warning: Unable to install insightface automatically. Please try run `pip install insightface` manually.
Launching Web UI with arguments: --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate
You are using PyTorch below version 2.3. Some optimizations will be disabled.
Total VRAM 32768 MB, total RAM 32768 MB
pytorch version: 2.1.2
Set vram state to: SHARED
Device: mps
VAE dtype preferences: [torch.float32] -> torch.float32
CUDA Using Stream: False
Using sub quadratic optimization for cross attention
Using split attention for VAE
Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled
==============================================================================
You are running torch 2.1.2.
The program is tested to work with torch 2.3.1.
To reinstall the desired version, run with commandline flag --reinstall-torch.
Beware that this will cause a lot of large files to be downloaded, as well as
there are reports of issues with training tab on the latest version.
Use --skip-version-check commandline argument to disable this check.
==============================================================================
ControlNet preprocessor location: /Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/models/ControlNetPreprocessor
Loading additional modules ... done.
2024-11-30 20:22:53,592 - ControlNet - INFO - ControlNet UI callback registered.
Model selected: {'checkpoint_info': {'filename': '/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/models/Stable-diffusion/flux1-dev-Q4_0.gguf', 'hash': '3f6d9145'}, 'additional_modules': ['/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/models/text_encoder/clip_l.safetensors', '/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/models/VAE/flux_vae.safetensors', '/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/models/text_encoder/t5xxl_fp8_e4m3fn.safetensors'], 'unet_storage_dtype': None}
Using online LoRAs in FP16: False
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Startup time: 54.9s (prepare environment: 4.9s, launcher: 0.7s, import torch: 24.6s, initialize shared: 0.3s, other imports: 5.6s, load scripts: 2.1s, initialize google blockly: 12.4s, create ui: 2.3s, gradio launch: 1.7s).
Environment vars changed: {'stream': False, 'inference_memory': 1024.0, 'pin_shared_memory': False}
[GPU Setting] You will use 96.88% GPU memory (31744.00 MB) to load weights, and use 3.12% GPU memory (1024.00 MB) to do matrix computation.
Environment vars changed: {'stream': False, 'inference_memory': 1024.0, 'pin_shared_memory': True}
[GPU Setting] You will use 96.88% GPU memory (31744.00 MB) to load weights, and use 3.12% GPU memory (1024.00 MB) to do matrix computation.
Loading Model: {'checkpoint_info': {'filename': '/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/models/Stable-diffusion/flux1-dev-Q4_0.gguf', 'hash': '3f6d9145'}, 'additional_modules': ['/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/models/text_encoder/clip_l.safetensors', '/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/models/VAE/flux_vae.safetensors', '/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/models/text_encoder/t5xxl_fp8_e4m3fn.safetensors'], 'unet_storage_dtype': None}
[Unload] Trying to free all memory for mps with 0 models keep loaded ... Done.
StateDict Keys: {'transformer': 780, 'vae': 244, 'text_encoder': 196, 'text_encoder_2': 220, 'ignore': 0}
Using Detected T5 Data Type: torch.float8_e4m3fn
Using Detected UNet Type: gguf
Using pre-quant state dict!
GGUF state dict: {'Q4_0': 304}
Working with z of shape (1, 16, 32, 32) = 16384 dimensions.
K-Model Created: {'storage_dtype': 'gguf', 'computation_dtype': torch.bfloat16}
Model loaded in 18.2s (unload existing model: 0.3s, forge model load: 17.9s).
Skipping unconditional conditioning when CFG = 1. Negative Prompts are ignored.
All loaded to GPU.
Moving model(s) has taken 0.01 seconds
Distilled CFG Scale: 3.5
[Unload] Trying to free 11745.91 MB for mps with 0 models keep loaded ... Current free memory is 15741.84 MB ... Done.
All loaded to GPU.
Traceback (most recent call last):
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/modules_forge/main_thread.py", line 30, in work
self.result = self.func(*self.args, **self.kwargs)
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/modules/txt2img.py", line 131, in txt2img_function
processed = processing.process_images(p)
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/modules/processing.py", line 842, in process_images
res = process_images_inner(p)
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/modules/processing.py", line 990, in process_images_inner
samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts)
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/modules/processing.py", line 1387, in sample
samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x))
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/modules/sd_samplers_kdiffusion.py", line 198, in sample
sampling_prepare(self.model_wrap.inner_model.forge_objects.unet, x=x)
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/backend/sampling/sampling_function.py", line 383, in sampling_prepare
memory_management.load_models_gpu(
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/backend/memory_management.py", line 684, in load_models_gpu
loaded_model.model_load(model_gpu_memory_when_using_cpu_swap)
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/backend/memory_management.py", line 516, in model_load
bake_gguf_model(self.real_model)
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/backend/memory_management.py", line 347, in bake_gguf_model
gguf_cls.bake(p)
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/packages_3rdparty/gguf/quants.py", line 152, in bake
cls.bake_inner(parameter)
File "/Volumes/Spidy/GitHub/AI/stable-diffusion-webui-forge/packages_3rdparty/gguf/quants.py", line 310, in bake_inner
d = d.view(torch.float16).to(parameter.computation_dtype).view(torch.uint8)
TypeError: BFloat16 is not supported on MPS
BFloat16 is not supported on MPS
Environment vars changed: {'stream': False, 'inference_memory': 1024.0, 'pin_shared_memory': False}
[GPU Setting] You will use 96.88% GPU memory (31744.00 MB) to load weights, and use 3.12% GPU memory (1024.00 MB) to do matrix computation.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the traceback in packages_3rdparty/gguf/quants.py at bake_inner and follow its call from backend/memory_management.py. Reproduce txt2img with the listed GGUF model and MPS environment, then verify that model loading and sampling no longer fail with the BFloat16-on-MPS error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, python, pytorch
- Domain
- machine-learning, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100