Update nodes.py

This commit is contained in:
kijai
2024-08-09 18:36:11 +03:00
parent 9867db2724
commit e2905be4c3
+8 -1
View File
@@ -31,6 +31,11 @@ class DownloadAndLoadLLaVAOneVisionModel:
{
"default": 'fp16'
}),
"attention": (
[ 'flash_attention_2', 'sdpa', 'eager'],
{
"default": 'sdpa'
}),
},
}
@@ -40,12 +45,13 @@ class DownloadAndLoadLLaVAOneVisionModel:
FUNCTION = "loadmodel"
CATEGORY = "LLaVA-OneVision"
def loadmodel(self, model, device, precision):
def loadmodel(self, model, device, precision, attention):
if precision != 'fp32' and device == 'cpu':
raise ValueError("fp16 and bf16 are not supported on cpu")
dtype = {"bf16": torch.bfloat16, "fp16": torch.float16, "fp32": torch.float32}[precision]
device = {"cuda": torch.device("cuda"), "cpu": torch.device("cpu"), "mps": torch.device("mps")}[device]
print(f"using {attention} for attention")
model_name = model.split('/')[-1]
download_path = os.path.join(folder_paths.models_dir, "LLM", "LLaVA-OneVision", model_name)
@@ -63,6 +69,7 @@ class DownloadAndLoadLLaVAOneVisionModel:
model,
None,
model_name="llava_qwen",
attn_implementation=attention,
load_8bit=False,
load_4bit=False
)