kohya-ss / kohya-ss/sd-scripts
Some flux fp8 models is returning an error, others don't why? Error "Cannot copy out of meta tensor..."
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.2k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
Just some fp8 quants return the error:
"Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device."
But others not, the problem is that the new dev2pro fp8 is giving the error too, I'm posting this with the hope that you understand the difference between 2 fp8 quantizations and try to identify what is causing the error and making training impossible.
FP8 Models that return the error:
https://huggingface.co/Kijai/flux-dev2pro-fp8
https://huggingface.co/XLabs-AI/flux-dev-fp8/tree/main
FP8 Models that works fine:
https://huggingface.co/Kijai/flux-fp8
Error sample:
```
Traceback (most recent call last):
File "G:\AI\kohya\sd-scripts\flux_train_network.py", line 446, in
trainer.train(args)
File "G:\AI\kohya\sd-scripts\train_network.py", line 344, in train
model_version, text_encoder, vae, unet = self.load_target_model(args, weight_dtype, accelerator)
File "G:\AI\kohya\sd-scripts\flux_train_network.py", line 83, in load_target_model
model = self.prepare_split_model(model, weight_dtype, accelerator)
File "G:\AI\kohya\sd-scripts\flux_train_network.py", line 116, in prepare_split_model
flux_upper.to(accelerator.device, dtype=target_dtype)
File "G:\AI\kohya\sd-scripts\venv\lib\site-packages\torch\nn\modules\module.py", line 1174, in to
return self._apply(convert)
File "G:\AI\kohya\sd-scripts\venv\lib\site-packages\torch\nn\modules\module.py", line 780, in _apply
module._apply(fn)
File "G:\AI\kohya\sd-scripts\venv\lib\site-packages\torch\nn\modules\module.py", line 805, in _apply
param_applied = fn(param)
File "G:\AI\kohya\sd-scripts\venv\lib\site-packages\torch\nn\modules\module.py", line 1167, in convert
raise NotImplementedError(
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device.
Traceback (most recent call last):
File "C:\Users\Rafa\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Rafa\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "G:\AI\kohya\sd-scripts\venv\Scripts\accelerate.exe\__main__.py", line 7, in
File "G:\AI\kohya\sd-scripts\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 48, in main
args.func(args)
File "G:\AI\kohya\sd-scripts\venv\lib\site-packages\accelerate\commands\launch.py", line 1097, in launch_command
simple_launcher(args)
File "G:\AI\kohya\sd-scripts\venv\lib\site-packages\accelerate\commands\launch.py", line 703, in simple_launcher
raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
subprocess.CalledProcessError: Command '['G:\\AI\\kohya\\sd-scripts\\venv\\Scripts\\python.exe', 'flux_train_network.py', '--config_file', 'config.toml', '--fp8_base', '--network_module', 'networks.lora_flux', '--network_args', 'train_blocks=single', '--output_dir', './/loras//styl1z3d_44_poly_2_1e2', '--output_name', 'styl1z3d_44_poly_2_1e2', '--learning_rate', '1e-1', '--network_dim', '16', '--network_alpha', '16', '--sample_prompt', 'prompt.txt', '--lr_scheduler', 'polynomial', '--lr_scheduler_power', '2']' returned non-zero exit status 1.```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with flux_train_network.py at load_target_model and prepare_split_model, then inspect train_network.py where the target model is loaded. Reproduce the error with the listed failing FP8 models and compare that path with Kijai/flux-fp8. Done means identifying the loading difference and allowing the affected models to proceed without the meta-tensor error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100