Repository navigation
Expand file tree
/
Copy path__init__.py
More file actions
61 lines (51 loc) · 2.07 KB
/
Copy path__init__.py
File metadata and controls
61 lines (51 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
ComfyUI Custom Node: FP8 MPS Metal Support
This custom node automatically installs patches to enable FP8 (Float8_e4m3fn)
support on Apple Silicon MPS backend for ComfyUI.
Installation:
Copy this entire repository to ComfyUI/custom_nodes/fp8-mps-metal/
The patch will be automatically installed when ComfyUI loads this custom node.
"""
import sys
import os
# Add current directory to path so we can import fp8_mps_patch
current_dir = os.path.dirname(os.path.abspath(__file__))
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
# Import and install the patch
try:
import fp8_mps_patch
# Install the patch automatically
if not fp8_mps_patch.is_installed():
fp8_mps_patch.install()
print("\n" + "=" * 70)
print("✓ FP8 MPS Metal patch installed successfully!")
print("=" * 70)
print("Float8_e4m3fn operations on MPS are now supported.")
print("This enables:")
print(" • FP8 model weight loading (FLUX/SD3.5)")
print(" • FP8 quantization on MPS")
print(" • FP8 stochastic rounding (.copy_() operations)")
print(" • FP8 matrix multiplication via Metal kernels")
print(" • Large VAE tensor handling (automatic CPU fallback)")
print(" • MPS fallback for unsupported operations")
print("=" * 70 + "\n")
else:
print("[fp8-mps-metal] Patch already installed")
except Exception as e:
print("\n" + "!" * 70)
print("⚠ WARNING: Failed to install FP8 MPS Metal patch")
print("!" * 70)
print(f"Error: {e}")
print("FP8 operations on MPS will not work without this patch.")
print("Please report this issue at:")
print("https://github.com/audiohacking/fp8-mps-metal/issues")
print("!" * 70 + "\n")
import traceback
traceback.print_exc()
# ComfyUI requires NODE_CLASS_MAPPINGS to recognize this as a custom node
# We don't add any nodes, just install the patch
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
# Export for ComfyUI
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']