From 1e0f512ccbde9988459ecff173c80aaf51a0b4fa Mon Sep 17 00:00:00 2001 From: Disty0 Date: Wed, 19 Mar 2025 15:42:36 +0300 Subject: [PATCH] ROCm disable FP16 for gfx1102 --- CHANGELOG.md | 5 ++++- modules/devices.py | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca168767f..7a12b6492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,12 +51,15 @@ Support for [CogView 4](https://huggingface.co/THUDM/CogView4-6B), new CLiP mode - update `diffusers` and other requirements - rename vae, unet and text-encoder settings *None* to *Default* to avoid confusion - **IPEX** - - add `--upgrade` to torch_command when using `--use-nightly` for *ipex* and *rocm* + - add `--upgrade` to torch_command when using `--use-nightly` - add xpu to profiler - fix untyped_storage, torch.eye and torch.cuda.device ops - fix torch 2.7 compatibility - fix performance with balanced offload - fix triton and torch.compile +- **ROCm** + - add `--upgrade` to torch_command when using `--use-nightly` + - disable fp16 for gfx1102 (rx 7600 and rx 7500 series) gpus - **Fixes** - fix installer not starting when older version of `rich` is installed - fix circular imports when debug flags are enabled diff --git a/modules/devices.py b/modules/devices.py index caa544652..bd84ff7d4 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -319,9 +319,18 @@ def test_fp16(): global fp16_ok # pylint: disable=global-statement if fp16_ok is not None: return fp16_ok - if sys.platform == "darwin" or backend == 'openvino': # override - fp16_ok = False - return fp16_ok + if opts.cuda_dtype != 'FP16': # don't override if the user sets it + if sys.platform == "darwin" or backend == 'openvino': # override + fp16_ok = False + return fp16_ok + elif backend == 'rocm': + # gfx1102 (RX 7600, 7500, 7650 and 7700S) causes segfaults with fp16 + # agent can be overriden to gfx1100 to get gfx1102 working with ROCm so check the gpu name as well + agent = getattr(torch.cuda.get_device_properties(device), "gcnArchName", "gfx0000") + agent_name = getattr(torch.cuda.get_device_properties(device), "name", "AMD Radeon RX 0000") + if agent == "gfx1102" or (agent == "gfx1100" and any(i in agent_name for i in ("7600", "7500", "7650", "7700S"))): + fp16_ok = False + return fp16_ok try: x = torch.tensor([[1.5,.0,.0,.0]]).to(device=device, dtype=torch.float16) layerNorm = torch.nn.LayerNorm(4, eps=0.00001, elementwise_affine=True, dtype=torch.float16, device=device)