invoke-ai / invoke-ai/InvokeAI
[bug]: Z-Image Base tensor size mismatch when using FLUX.2 Klein Qwen3 8B Encoder
- Dominant language
- Python
- Stars
- 28.2k
- Forks
- 3k
- Avg merge
- 6d 5h
- Merged PRs (30d)
- 19
Description
### Is there an existing issue for this problem?
- [x] I have searched the existing issues
### Install method
Invoke's Launcher
### Operating system
Windows
### GPU vendor
Nvidia (CUDA)
### GPU model
RTX 4080 Laptop
### GPU VRAM
12GB
### Version number
v6.14.0-rc2
### Browser
Vivaldi 8.1.4087.70 / Chromium 150.0.7871.253
### System Information
_No response_
### What happened
When trying to generate an image (1024 x 1280 px) using a Z-Image Base model ([Juggernaut Z v1 FP8](https://civitai.red/models/2600510/juggernaut-z?modelVersionId=2921151) in this case) while also selecting the **FLUX.2 Klein Qwen3 8B Encoder** (from the starters models list) as the encoder, the following error is being returned:
_RuntimeError: The size of tensor a (4096) must match the size of tensor b (2560) at non-singleton dimension 1_
Switching back to the standard "Z-Image Qwen3 4B" encoder works, though. The full error message is as follows:
```
[2026-08-22 18:36:13,353]::[InvokeAI]::ERROR --> Error while invoking session d86c3e07-d000-43ab-bca8-9e80baa3a9a5, invocation 63274441-f061-4ff0-8779-1990af4233c0 (z_image_denoise): The size of tensor a (4096) must match the siz
e of tensor b (2560) at non-singleton dimension 1
[2026-08-22 18:36:13,353]::[InvokeAI]::ERROR --> Traceback (most recent call last):
File "D:\InvokeAI\.venv\Lib\site-packages\invokeai\app\services\session_processor\session_processor_default.py", line 167, in run_node
output = invocation.invoke_internal(context=context, services=self._services)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\invokeai\app\invocations\baseinvocation.py", line 248, in invoke_internal
output = self.invoke(context)
^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\invokeai\app\invocations\z_image_denoise.py", line 130, in invoke
latents = self._run_diffusion(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\invokeai\app\invocations\z_image_denoise.py", line 722, in _run_diffusion
model_output = transformer(
^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\torch\nn\modules\module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\torch\nn\modules\module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\diffusers\models\transformers\transformer_z_image.py", line 996, in forward
cap_feats = self.cap_embedder(torch.cat(cap_feats, dim=0)) # embed
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\torch\nn\modules\module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\torch\nn\modules\module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\torch\nn\modules\container.py", line 240, in forward
input = module(input)
^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\torch\nn\modules\module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\torch\nn\modules\module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\invokeai\backend\model_manager\load\model_cache\torch_module_autocast\custom_modules\custom_diffusers_rms_norm.py", line 38, in forward
return self._autocast_forward(hidden_states)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\InvokeAI\.venv\Lib\site-packages\invokeai\backend\model_manager\load\model_cache\torch_module_autocast\custom_modules\custom_diffusers_rms_norm.py", line 25, in _autocast_forward
hidden_states = hidden_states * weight
~~~~~~~~~~~~~~^~~~~~~~
RuntimeError: The size of tensor a (4096) must match the size of tensor b (2560) at non-singleton dimension 1
```
### What you expected to happen
Either successfully using other and larger encoders (e.g. Qwen3 8B) than the standard Z-Image 4B one or a restriction to not being able to select any other in the UI.
### How to reproduce the problem
1. Select a Z-Image Base (maybe Turbo as well, couldn't test it) model like **Juggernaut Z v1 FP8**, **FLUX.1-schnell_ae** as the VAE and **FLUX.2 Klein Qwen3 8B Encoder** as the Qwen3 Encoder.
2. Add a prompt, select any scheduler and hit "Invoke".
### Additional context
_No response_
### Discord username
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.