{"record":{"id":"a4fa42084ca1e05a","repo":"AUTOMATIC1111/stable-diffusion-webui","slug":"could-not-find-a-module-type-out-of-join-x","errorCode":null,"errorMessage":"Could not find a module type (out of {', '.join([x.__class__.__name__ for x in module_types])}) that would accept those keys: {', '.join(weights.w)}","messagePattern":"Could not find a module type \\(out of (.+?)\\) that would accept those keys: (.+?)","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"extensions-builtin/Lora/networks.py","lineNumber":254,"sourceCode":"\r\n        if sd_module is None:\r\n            keys_failed_to_match[key_network] = key\r\n            continue\r\n\r\n        if key not in matched_networks:\r\n            matched_networks[key] = network.NetworkWeights(network_key=key_network, sd_key=key, w={}, sd_module=sd_module)\r\n\r\n        matched_networks[key].w[network_part] = weight\r\n\r\n    for key, weights in matched_networks.items():\r\n        net_module = None\r\n        for nettype in module_types:\r\n            net_module = nettype.create_module(net, weights)\r\n            if net_module is not None:\r\n                break\r\n\r\n        if net_module is None:\r\n            raise AssertionError(f\"Could not find a module type (out of {', '.join([x.__class__.__name__ for x in module_types])}) that would accept those keys: {', '.join(weights.w)}\")\r\n\r\n        net.modules[key] = net_module\r\n\r\n    embeddings = {}\r\n    for emb_name, data in bundle_embeddings.items():\r\n        embedding = textual_inversion.create_embedding_from_data(data, emb_name, filename=network_on_disk.filename + \"/\" + emb_name)\r\n        embedding.loaded = None\r\n        embedding.shorthash = BundledTIHash(name)\r\n        embeddings[emb_name] = embedding\r\n\r\n    net.bundle_embeddings = embeddings\r\n\r\n    if keys_failed_to_match:\r\n        logging.debug(f\"Network {network_on_disk.filename} didn't match keys: {keys_failed_to_match}\")\r\n\r\n    return net\r\n\r\n\r","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/extensions-builtin/Lora/networks.py#L236-L272","documentation":"Raised in networks.py when, after grouping a LoRA file's weight keys by target sd module, no registered network module type (NetworkModuleLoRA, NetworkModuleHada, NetworkModuleFull, IA3, LoHa/LoKr, etc.) accepts the key set. Each module type's create_module inspects weights.w and returns None if the expected key patterns (lora_down.weight, hada_w1_a, lora_mid.weight, etc.) are absent; if every candidate refuses, the bundle is unloadable.","triggerScenarios":"A LoRA file with partially corrupt or truncated key sets, e.g. lora_up.weight present but lora_down.weight missing so every module type returns None; keys for exotic algorithms (e.g. LoCon variants, DyLoRA 'dyn_up'/'dyn_down') from a newer/older trainer than the webui understands; a file where extra non-standard suffix keys got grouped with the LoRA keys.","commonSituations":"Downloading a LoRA produced by a newer trainer (kohya-ss with new algorithms like LoRA-FA,dora components) while running an older webui; interrupted downloads leaving half-written safetensors; merging tools that emit non-standard key names; mismatches after webui extension updates.","solutions":["Update the webui (and built-in Lora extension) to the latest version so newer key formats are recognized","Verify the file integrity: re-download the LoRA and check its sha256 if published; open it with a safetensors metadata viewer and confirm each lora_down.weight has a matching lora_up.weight","Re-export/re-merge the LoRA with kohya's scripts so key names follow the standard '<prefix>.lora_down.weight' convention","If you control the file, strip foreign keys (optimizer states, 'alpha' mismatches) leaving only recognized pairs"],"exampleFix":"# before: incomplete key set in file: model.diff_model.x.lora_up.weight without lora_down.weight\n\n# after: sanitize the safetensors so every lora_up has its lora_down pair\nfrom safetensors.torch import load_file, save_file\nsd = load_file('bad.safetensors')\nclean = {k: v for k, v in sd.items() if '.lora_down.weight' in k or '.lora_up.weight' in k or 'alpha' in k}\nups = {k.rsplit('.lora_up.weight',1)[0] for k in clean if '.lora_up.weight' in k}\ndowns = {k.rsplit('.lora_down.weight',1)[0] for k in clean if '.lora_down.weight' in k}\nclean = {k: v for k, v in clean.items() if k.rsplit('.',2)[0] in (ups & downs) or 'alpha' in k}\nsave_file(clean, 'clean.safetensors')","handlingStrategy":"try-catch","validationCode":"# pre-check the file's key set before load\nfrom safetensors import safe_open\nSUFFIX_SETS = [('lora_down.weight','lora_up.weight'), ('hada_w1_a','hada_w1_b','hada_w2_a','hada_w2_b')]\ndef lora_keys_plausible(path):\n    keys = []\n    with safe_open(path, framework='pt') as f:\n        keys = list(f.keys())\n    for down, up in SUFFIX_SETS:\n        if any(k.endswith(down) for k in keys) and any(k.endswith(up) for k in keys):\n            return True\n    return False","typeGuard":null,"tryCatchPattern":"try:\n    net = networks.load_networks(shared.sd_model, [network_on_disk])\nexcept AssertionError as e:\n    if 'Could not find a module type' in str(e):\n        quarantine(corrupt_lora_path)  # move aside, notify user, continue batch\n    else:\n        raise","preventionTips":["Re-download LoRAs from the original source rather than trusting cached files","Validate safetensors integrity (hash) before adding to the models/LoRA folder","Update webui when adopting LoRAs from new trainer versions"],"tags":["lora","safetensors","model-loading","stable-diffusion-webui"],"backgroundTag":null,"analyzedSha":"82a973c04367123ae98bd9abdf80d9eda9b910e2","analyzedAt":"2026-08-14T16:46:43.225Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}