CivArchive
    ← All articles
    Published March 13, 2026by mnemic

    Z-Image Turbo LoRA Fixing Tool

    254 views8 reactions0 comments on CivitAI2 collected
    tool guidez-image turbozit

    ZiTLoRAFix

    https://github.com/MNeMoNiCuZ/ZiTLoRAFix/tree/main

    Fixes LoRA .safetensors files that contain unsupported attention tensors for certain diffusion models. Specifically targets:

    diffusion_model.layers.*.attention.*.lora_A.weight
    diffusion_model.layers.*.attention.*.lora_B.weight

    These keys cause errors in some loaders. The script can mute them (zero out the weights) or prune them (remove the keys entirely), and can do both in a single run producing separate output files.

    Example / Comparison

    The unmodified version often produces undesirable results.

    Requirements

    • Python 3.12.3 (tested)

    • PyTorch (manual install required — see below)

    • safetensors

    1. Create the virtual environment

    Run the included helper script and follow the prompts:

    venv_create.bat

    It will let you pick your Python version, create a venv/, optionally upgrade pip, and install from requirements.txt.

    2. Install PyTorch manually

    PyTorch is not included in requirements.txt because the right build depends on your CUDA version. Install it manually into the venv before running the script.

    Tested with:

    torch             2.10.0+cu130
    torchaudio        2.10.0+cu130
    torchvision       0.25.0+cu130

    Visit https://pytorch.org/get-started/locally/ to get the correct install command for your system and CUDA version.

    3. Install remaining dependencies

    pip install -r requirements.txt

    Quick Start

    1. Drop your .safetensors files into the input/ folder (or list paths in list.txt)

    2. Edit config.json to choose which mode(s) to run and set your prefix/suffix

    3. Activate the venv (use the generated venv_activate.bat on Windows) and run:

    python convert.py

    Output files are written to output/ by default.

    Modes

    Mute

    Keeps all tensor keys but replaces the targeted tensors with zeros. The LoRA is structurally intact — the attention layers are simply neutralized. Recommended if you need broad compatibility or want to keep the file structure.

    Prune

    Removes the targeted tensor keys entirely from the output file. Results in a smaller file. May be preferred if the loader rejects the keys outright rather than mishandling their values.

    Both modes can run in a single pass. Each produces its own output file using its own prefix/suffix, so you can compare or distribute both variants without running the script twice.

    Configuration

    Settings are resolved in this order (later steps override earlier ones):

    1. Hardcoded defaults inside convert.py

    2. config.json (auto-loaded if present next to the script)

    3. CLI arguments

    config.json

    Edit config.json to set your defaults without touching the script:

    {
      "input_dir":   "input",
      "list_file":   "list.txt",
      "output_dir":  "output",
      "verbose_keys": false,
    
      "mute": {
        "enabled": true,
        "prefix":  "",
        "suffix":  "_mute"
      },
    
      "prune": {
        "enabled": false,
        "prefix":  "",
        "suffix":  "_prune"
      }
    }

    Key Type Description input_dir string Directory scanned for .safetensors files when no list file is used list_file string Path to a text file with one .safetensors path per line output_dir string Directory where output files are written verbose_keys bool Print every tensor key as it is processed mute.enabled bool Run mute mode mute.prefix string Prefix added to output filename (e.g. "fixed_") mute.suffix string Suffix added before extension (e.g. "_mute") prune.enabled bool Run prune mode prune.prefix string Prefix added to output filename prune.suffix string Suffix added before extension (e.g. "_prune")

    Input: list file vs directory

    • If list.txt exists and is non-empty, those paths are used directly.

    • Otherwise the script scans input_dir recursively for .safetensors files.

    Output naming

    For an input file my_lora.safetensors with default suffixes:

    Mode Output filename Mute my_lora_mute.safetensors Prune my_lora_prune.safetensors

    CLI Reference

    All CLI arguments override config.json values. Run python convert.py --help for a full listing.

    python convert.py --help
    
    usage: convert.py [-h] [--config PATH] [--list-file PATH] [--input-dir DIR]
                      [--output-dir DIR] [--verbose-keys]
                      [--mute | --no-mute] [--mute-prefix STR] [--mute-suffix STR]
                      [--prune | --no-prune] [--prune-prefix STR] [--prune-suffix STR]

    Common examples

    Run with defaults from config.json:

    python convert.py

    Use a different config file:

    python convert.py --config my_settings.json

    Run only mute mode from the CLI, output to a custom folder:

    python convert.py --mute --no-prune --output-dir ./fixed

    Run both modes, override suffixes:

    python convert.py --mute --mute-suffix _zeroed --prune --prune-suffix _stripped

    Process a specific list of files:

    python convert.py --list-file my_batch.txt

    Enable verbose key logging:

    python convert.py --verbose-keys