Skip to content

Add Hunyuan 3D 2.1 Support#8714

Merged
comfyanonymous merged 27 commits intoComfy-Org:masterfrom
yousef-rafat:yousef
Sep 5, 2025
Merged

Add Hunyuan 3D 2.1 Support#8714
comfyanonymous merged 27 commits intoComfy-Org:masterfrom
yousef-rafat:yousef

Conversation

@yousef-rafat
Copy link
Contributor

I have created the reimplementation of the VAE. The main contributions are in rewriting/avoiding the use of unnecessary libraries and modularizing the code by removing code redundancy and better structuring of the code.

The implemented VAE is faster by approximately 5 seconds in the encoding process and 2 seconds in the decoding process.

The fps.py file contains the implementation of Farthest Point Sampling, avoiding using torch_cluster. The preprocess.py contains the Volume Decoder, Surface Extractor, and Trimesh exporting. The point_attention.py contains the code for the encoder. The transformer.py contains the code for the Transformer model that is used in the geo decoder of the VAE and the Self-Attention in the encoder. The vae.py contains the VAE code along with a test example.

fixed not returning y in the forward method of MoEBlock
@yousef-rafat yousef-rafat changed the title Implementation of VAE for Hunyuan 3D 2.1 Add Hunyuan 3D 2.1 Support Jul 5, 2025
@zapan-669
Copy link

please do it

@comfyanonymous comfyanonymous merged commit 261421e into Comfy-Org:master Sep 5, 2025
9 checks passed
@comfyui-wiki
Copy link
Member

@yousef-rafat can you share the hunyuan3d 2.1 workflow with me? I tried hunyuan3d 2.0 workflow ,but sometime the output doesen't seem to right.

image image

@yousef-rafat
Copy link
Contributor Author

@comfyui-wiki
Screenshot 2025-07-22 200209
Screenshot 2025-07-22 200532

@guillaumeparra
Copy link

guillaumeparra commented Sep 14, 2025

hi @yousef-rafat ,

Not sure I'm doing the right thing here, it doesn't work for me.

I get this error when executing the graph. I downloaded the model from here and renamed it hunyuan3d-dit-v2-1.ckpt :

https://huggingface.co/tencent/Hunyuan3D-2.1/tree/main/hunyuan3d-dit-v2-1

Here is the error message :

`got prompt
Warning, This is not a checkpoint file, trying to load it as a diffusion model only.
!!! Exception during processing !!! 'collections.OrderedDict' object has no attribute 'nelement'
Traceback (most recent call last):
File "/apps/comfyui/execution.py", line 496, in execute
output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/comfyui/execution.py", line 315, in get_output_data
return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, hidden_inputs=hidden_inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/comfyui/execution.py", line 289, in _async_map_node_over_list
await process_inputs(input_dict, i)
File "/apps/comfyui/execution.py", line 277, in process_inputs
result = f(**inputs)
^^^^^^^^^^^
File "/apps/comfyui/comfy_extras/nodes_video_model.py", line 22, in load_checkpoint
out = comfy.sd.load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=False, output_clipvision=True, embedding_directory=folder_paths.get_folder_paths("embeddings"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/comfyui/comfy/sd.py", line 1076, in load_checkpoint_guess_config
out = load_state_dict_guess_config(sd, output_vae, output_clip, output_clipvision, embedding_directory, output_model, model_options, te_model_options=te_model_options, metadata=metadata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/comfyui/comfy/sd.py", line 1096, in load_state_dict_guess_config
diffusion_model = load_diffusion_model_state_dict(sd, model_options={})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/comfyui/comfy/sd.py", line 1192, in load_diffusion_model_state_dict
parameters = comfy.utils.calculate_parameters(sd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/comfyui/comfy/utils.py", line 109, in calculate_parameters
params += w.nelement()
^^^^^^^^^^
AttributeError: 'collections.OrderedDict' object has no attribute 'nelement'

Prompt executed in 2.58 seconds`

Thanks for your help !

hunyuan3d-v2.1-mesh-generation.json

@comfyui-wiki
Copy link
Member

@guillaumeparra Use this workflow, I will add it to the template soon
hunyuan3d-v2.1.json

toxicwind pushed a commit to toxicwind/ComfyUI that referenced this pull request Oct 12, 2025
adlerfaulkner pushed a commit to LucaLabsInc/ComfyUI that referenced this pull request Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants