SamplerCustomAdvanced 'Linear' object has no attribute 'weight'
Hello!
I'm trying to run your workflows. It successfully creates the first frame head swap, but eventually fails with this error message:
# ComfyUI Error Report
## Error Details
- **Node ID:** 81
- **Node Type:** SamplerCustomAdvanced
- **Exception Type:** AttributeError
- **Exception Message:** 'Linear' object has no attribute 'weight'
This happens with both workflow_ltx2_head_swap_drag_and_drop_v1.1.json and workflow_ltx2_head_swap_drag_and_drop_v2.0.json. I tried updating ComfyUI (comfyui 0.16.3), but no luck.
If it matters: I installed the models using the download-models-head-swap-ltx2.sh script.
Any ideas?
Thanks a lot!
I had a similar error in another node, replacing DualCLIPLoaderGGUF with gemma_3_12B_it_fp4_mixed(.safetensors) with the .GGUF version (gemma-3-12b-it-Q5_K_M.gguf) helped.
And the second one:
After updating ComfyUI, I encountered the same issue you had. (81 node)
I managed to figure out that the problem lies in the get_key_weight function. The line weight = getattr(op, op_keys[1]) strictly requires the layer to have a .weight attribute. If it doesn't (as is the case with custom or quantized layers), the script crashes.
Here's how you need to modify the get_key_weight function in the model_patcher.py file (...\ComfyUI\comfy):
def get_key_weight(model, key):
set_func = None
convert_func = None
op_keys = key.rsplit('.', 1)
if len(op_keys) < 2:
try:
weight = comfy.utils.get_attr(model, key)
except AttributeError:
weight = None
else:
op = comfy.utils.get_attr(model, op_keys[0])
try:
set_func = getattr(op, "set_{}".format(op_keys[1]))
except AttributeError:
pass
try:
convert_func = getattr(op, "convert_{}".format(op_keys[1]))
except AttributeError:
pass
# --- MODIFIED PART ---
# Using safe attribute access (will return None if it doesn't exist, instead of crashing)
weight = getattr(op, op_keys[1], None)
if convert_func is not None:
try:
weight = comfy.utils.get_attr(model, key)
except AttributeError:
pass
# ---------------------
return weight, set_func, convert_func