Replacing a Text Encoder in ComfyUI: Verification and Troubleshooting

    This guide explains how to replace a text encoder in ComfyUI in a fixed order: record your environment, back up your files, install the custom node, verify the weight hash and encoder-adapter pairing, and check the generated images. It includes expected results for each step, a troubleshooting table for common errors such as import failures, size mismatches, and CUDA out-of-memory errors, and a rollback procedure.

    Replacing a Text Encoder in ComfyUI: Verification and Troubleshooting

    When you replace the text encoder in ComfyUI, three failure causes are common: the plugin is in the wrong directory, the weights and adapter do not match, or VRAM usage exceeds what the device can provide. This guide follows a fixed sequence. First, record your environment and back up your files. Next, install the plugin. Then verify the weight hash and the encoder-adapter pairing. Finally, check the generated images. Each step states its expected result. If a problem occurs, use the troubleshooting table to locate the cause. You can also return to the previous working state at any time.

    1. Scope and Assumptions

    This guide uses ComfyUI as the example. Replace the placeholders below with your actual values:

    • <plugin repository URL>: The Git address of the plugin, in the form https://github.com/<author>/<repository>.git. Copy it from the plugin’s README.
    • <plugin folder name>: The name of the plugin folder under custom_nodes. It is recommended to match the repository name.
    • <weight file name>: The file name of the encoder or adapter. Use the name shown on the model card page.

    Check the following assumptions in your own environment:

    • The plugin dependencies may be listed in requirements.txt or in pyproject.toml. Follow the plugin README to confirm which one applies. Section 4 explains the commands for both cases.
    • The plugin author publishes the pairing between encoders and adapters. This guide does not provide a version compatibility table. Check the pairing instructions from the author.
    • VRAM requirements depend on encoder precision, batch size, and resolution. This guide does not provide fixed values. It explains how to measure VRAM instead.

    2. Record the Current Environment and Check Resources

    Record your environment before you start. If a problem occurs later, these records help you identify the cause. For example, if the plugin fails after an update, comparing against your records can show whether the Python version changed or the driver version does not match.

    Component What to record How to check
    ComfyUI Git commit or release version Run git log -1 in the ComfyUI directory. If you use the portable version without Git, record the download date and version name.
    Python Major version Run python --version. For the Windows portable version, run python_embeded\python.exe --version.
    PyTorch and CUDA torch version and CUDA version Run python -c "import torch; print(torch.__version__, torch.version.cuda)". For the portable version, use python_embeded\python.exe instead.
    GPU driver Driver version Run nvidia-smi.
    Plugin Tag or commit Check the Releases page of the plugin repository, or run git log -1 in the plugin directory.
    Encoder Model name and quantization format Model card page
    Adapter Version number Pairing table in the plugin README

    Disk Space

    First, calculate the total size of the weight files. Then reserve 1.2 times that size for temporary download files and extraction.

    On Linux, run:

    1. du -sh ComfyUI/models/text_encoders

    In Windows PowerShell, run:

    1. (Get-ChildItem ComfyUI_windows_portable\ComfyUI\models\text_encoders -Recurse | Measure-Object Length -Sum).Sum / 1GB

    Measure VRAM

    Measure VRAM usage instead of estimating it from experience. Open a separate terminal and sample VRAM usage continuously:

    1. nvidia-smi --query-gpu=memory.used,memory.total --format=csv -l 1

    On the Windows command line, use the same command. To measure:

    1. Start ComfyUI without loading the encoder. Once the sampled values stabilize, record the idle VRAM.
    2. Load the encoder and generate one image. Record the highest memory.used value shown during sampling. This is the peak VRAM.
    3. Enter the results in the table below.
    Encoder precision Batch size Resolution Idle VRAM Peak VRAM after loading Usable?
    Fill in Fill in Fill in Fill in Fill in Fill in

    nvidia-smi reports usage at the driver level, which includes memory cached by PyTorch. The reported value can therefore be slightly higher than the memory that tensors actually use.

    Apply these rules:

    • If the peak VRAM is higher than the idle VRAM, an out-of-memory (OOM) error usually appears unless CPU offloading or shared GPU memory is available. In that case, lower the precision, switch to a quantized version, or enable CPU offloading, then measure again.
    • If the peak VRAM is lower than the idle VRAM but the margin is small, test first with batch size 1 and a lower resolution.
    • Keep part of the VRAM free for the system and other programs. You decide how much headroom to keep based on your situation.

    The measurement table makes every change traceable. If the output quality gets worse after a replacement, compare the precision, plugin version, and VRAM data in the table to find which step caused the problem.

    3. Back Up First, Then Make Changes

    Replacing the encoder changes the plugin and model directories. Back up your files first so you do not overwrite a working setup. Back up the following:

    • The custom_nodes directory, which contains your existing plugins.
    • The models/text_encoders directory, which contains your existing encoders.
    • extra_model_paths.yaml, if it exists. It stores your model path settings.
    • Your frequently used workflow JSON files.

    On Linux, run:

    1. mkdir -p ~/backup/comfyui_2026-11-24
    2. cp -a ComfyUI/custom_nodes ~/backup/comfyui_2026-11-24/
    3. cp -a ComfyUI/models/text_encoders ~/backup/comfyui_2026-11-24/
    4. cp -a ComfyUI/extra_model_paths.yaml ~/backup/comfyui_2026-11-24/ 2>/dev/null

    For the Windows portable version, run these commands in PowerShell:

    1. robocopy ComfyUI_windows_portable\ComfyUI\custom_nodes D:\backup\comfyui_2026-11-24\custom_nodes /E
    2. robocopy ComfyUI_windows_portable\ComfyUI\models\text_encoders D:\backup\comfyui_2026-11-24\text_encoders /E
    3. copy ComfyUI_windows_portable\ComfyUI\extra_model_paths.yaml D:\backup\comfyui_2026-11-24\

    A robocopy exit code from 0 to 7 indicates success.

    After the backup, verify that it is complete. On Linux, use diff to compare the directories:

    1. diff -rq ComfyUI/models/text_encoders ~/backup/comfyui_2026-11-24/text_encoders && echo "Backup matches"

    If the command prints nothing and shows “Backup matches,” the two directories have identical contents. On Windows, run the following commands to check the file count and total size of each directory. The two results should match:

    1. (Get-ChildItem D:\backup\comfyui_2026-11-24\text_encoders -Recurse | Measure-Object Length -Sum).Sum
    2. (Get-ChildItem ComfyUI_windows_portable\ComfyUI\models\text_encoders -Recurse | Measure-Object Length -Sum).Sum

    Finally, create a file named version_notes.txt in the backup directory. Record the ComfyUI version from Section 2, the plugin version, and the backup date. When you roll back, this file shows which versions the backup corresponds to.

    4. Install the Plugin

    4.1 Check the Dependency Method in the README

    Plugins install their dependencies in one of two ways. Follow the plugin README to determine which applies:

    Dependency file Install command (run in the plugin directory)
    requirements.txt pip install -r requirements.txt
    pyproject.toml pip install .

    If the README gives a different command, follow the README.

    4.2 Linux Source Installation

    Go to the custom_nodes directory and clone the plugin:

    1. cd ComfyUI/custom_nodes
    2. git clone <plugin repository URL> <plugin folder name>
    3. cd <plugin folder name>

    If ComfyUI uses a virtual environment, activate it before installing the dependencies. Assuming the virtual environment is at ComfyUI/venv, run:

    1. source ../../venv/bin/activate
    2. pip install -r requirements.txt

    If the dependencies are in pyproject.toml, replace the last step with pip install .. This step matters. If you install the dependencies into the system Python, ComfyUI cannot find these packages.

    Expected result: When git clone finishes, you see a message such as done.. The last line of pip install reads something like Successfully installed ..., or each item shows Requirement already satisfied.

    4.3 Windows Portable Version

    The Windows portable version includes its own Python. Do not use the pip installed on your system. Open a command prompt in the parent directory of ComfyUI_windows_portable.

    If Git is installed on your computer, run:

    1. cd ComfyUI_windows_portable\ComfyUI\custom_nodes
    2. git clone <plugin repository URL> <plugin folder name>
    3. cd <plugin folder name>
    4. ..\..\..\python_embeded\python.exe -m pip install -r requirements.txt

    If the dependencies are in pyproject.toml, replace the last step with ..\..\..\python_embeded\python.exe -m pip install ..

    If Git is not installed on your computer, follow these steps:

    1. Open the plugin’s repository page. Click Code, then select Download ZIP. If the plugin provides Releases, you can also download the source archive for a specific version.
    2. Extract the archive to ComfyUI_windows_portable\ComfyUI\custom_nodes\<plugin folder name>. After extraction, the ZIP often contains an extra folder, such as <repository name>-main. Move the files inside that folder directly into <plugin folder name>, or rename the folder to <plugin folder name>.
    3. Install the dependencies in the plugin directory:
    1. cd ComfyUI_windows_portable\ComfyUI\custom_nodes\<plugin folder name>
    2. ..\..\..\python_embeded\python.exe -m pip install -r requirements.txt

    4.4 Check After Startup

    Restart ComfyUI and check the console output:

    • The console shows no errors from the plugin. If the plugin fails to load, the console usually shows IMPORT FAILED with the plugin name.
    • Double-click the canvas to open node search. Enter a node name provided by the plugin. The node appears in the results.

    Proceed to the next step only when both checks pass.

    5. Verify the Weight Hash and Pairing

    Step 1: Get the Official Hash

    Open the model card page and copy the SHA256 value of the weight file. If the page does not provide a hash, use the download source page instead. If neither page lists a hash, you cannot complete the verification. Pause the replacement.

    Step 2: Calculate the Local Hash

    On Linux, run:

    1. sha256sum ComfyUI/models/text_encoders/<weight file name>

    In Windows PowerShell, run:

    1. Get-FileHash -Algorithm SHA256 ComfyUI_windows_portable\ComfyUI\models\text_encoders\<weight file name>

    On the Windows command line, you can use certutil:

    1. certutil -hashfile ComfyUI_windows_portable\ComfyUI\models\text_encoders\<weight file name> SHA256

    The second line of the certutil output is the hash value.

    Step 3: Compare the Results

    Use the file only if the two hash values match exactly. Letter case does not affect the comparison. If the hashes do not match, move the file to a temporary directory, download it again, and verify it once more. Do not use a file whose hash does not match.

    Step 4: Confirm the Pairing

    A matching hash confirms that the file is complete. It does not confirm that the encoder and adapter are paired correctly. Check the pairing table in the plugin README to confirm that the encoder name, quantization format, and adapter version correspond to each other. Record the result in the table in Section 2.

    6. Verify the Output

    Before you replace anything, generate a baseline set of images with fixed settings. After each replacement, generate images with the same settings and compare them to the baseline.

    Set up the verification as follows:

    1. Fix the prompt, negative prompt, resolution, sampler, steps, and CFG value.
    2. Set the random seed to a fixed number, and set Control after generate to fixed. With these settings, the same configuration produces the same output each time, which makes comparison possible.
    3. Generate images with the same workflow before and after the replacement. Save them to the same directory.
    4. Check each image for these points: whether the main subject matches the prompt, whether there is any obvious deviation, and whether the image contains any artifacts.

    Record each verification in the table below:

    Date Encoder Adapter version Seed Resolution Result Conclusion
    Fill in Fill in Fill in Fill in Fill in Fill in Fill in

    If the output deviates clearly from the expected result, check the pairing first, then check the precision settings. Change only one item at a time. Otherwise, you cannot tell which change caused the problem.

    7. Rollback

    Rollback renames the current files instead of deleting them. This way, you can still inspect the original files if something went wrong.

    Close ComfyUI before you roll back.

    On Linux, run:

    1. mv ComfyUI/custom_nodes/<plugin folder name> ComfyUI/custom_nodes/<plugin folder name>.bad
    2. cp -a ~/backup/comfyui_2026-11-24/custom_nodes/<plugin folder name> ComfyUI/custom_nodes/

    Handle the encoder directory the same way. If you replaced the encoder, rename ComfyUI/models/text_encoders to text_encoders.bad, then copy the backup directory back.

    For the Windows portable version, run:

    1. ren ComfyUI_windows_portable\ComfyUI\custom_nodes\<plugin folder name> <plugin folder name>.bad
    2. robocopy D:\backup\comfyui_2026-11-24\custom_nodes\<plugin folder name> ComfyUI_windows_portable\ComfyUI\custom_nodes\<plugin folder name> /E

    After the rollback, restart ComfyUI. Generate one image with the baseline settings from Section 6, and confirm that the result matches the output from before the replacement. After you confirm the result, decide whether to delete the .bad directory.

    8. Troubleshooting

    Symptom Possible cause Solution
    The console shows IMPORT FAILED, and the node does not appear The plugin is in the wrong directory, or the dependencies were installed into a Python that ComfyUI does not use Confirm that the plugin is located under custom_nodes. Reinstall the dependencies in the environment that ComfyUI actually uses.
    The Windows portable version shows No module named pip The embedded Python does not include pip Install pip by following the ComfyUI portable version instructions, then try again.
    size mismatch or missing keys appears The encoder and adapter are not paired Check the pairing table in the plugin README, and switch to the matching version.
    The hash does not match the model card The download is incomplete, or the file was modified Move the file to a temporary directory, download it again, and verify it once more.
    CUDA out of memory appears Peak VRAM exceeds the available VRAM Lower the precision, switch to a quantized version, reduce the resolution or batch size, or enable CPU offloading.
    The image deviates from the prompt The encoder and adapter are mispaired, or a precision setting changed Check the pairing first. Then restore the settings one by one against the baseline images.
    torch or CUDA errors appear after startup Plugin dependencies overwrote the installed PyTorch Reinstall the PyTorch version recorded in Section 2. Check whether the dependency file brought in another torch version.
    git clone fails The repository address is wrong, or the network is unavailable Check the repository address, or use the Download ZIP method instead.

    If you see an error that is not in this table, read the full error message in the console first. Then compare it with your environment records from Section 2. Most problems can be traced by comparing the versions, pairings, and VRAM data.