Skip to content

[Feat] Support Hunyuan3D-2#18170

Merged
mickqian merged 100 commits intosgl-project:mainfrom
Prozac614:hunyuan3d2
Mar 2, 2026
Merged

[Feat] Support Hunyuan3D-2#18170
mickqian merged 100 commits intosgl-project:mainfrom
Prozac614:hunyuan3d2

Conversation

@Prozac614
Copy link
Copy Markdown
Contributor

@Prozac614 Prozac614 commented Feb 3, 2026

Motivation

Support Hunyuan3D-2 (2.0)

Modifications

Serve

  • Added mesh_api.py: exposes /v1/meshes create/list/retrieve/delete and mesh content download.

Pipeline Config

  • Added Hunyuan3D2PipelineConfig (task_type=I2M): shape/paint/delight subfolders and related hyperparameters; DiT/VAE config references.
  • Added configs/models/dits/hunyuan3d.py, configs/models/vaes/hunyuan3d.py, and configs/sample/hunyuan3d.py (Hunyuan3DSamplingParams).
  • base.py: added ModelTaskType.I2M, data_type() returns DataType.MESH.

Model Architecture

  • DiT: runtime/models/dits/hunyuan3d.py (Hunyuan3DShapeModel, Basic2p5DTransformerBlock, etc.).
  • VAE: runtime/models/vaes/hunyuan3d_vae.py (Hunyuan3DShapeVAE).
  • Encoder: runtime/models/encoders/hunyuan3d.py (Hunyuan3DShapeConditioner, Hunyuan3DShapeImageProcessor, etc.).
  • Scheduler: runtime/models/schedulers/hunyuan3d_scheduler.py.
  • Mesh utilities and rendering: runtime/models/mesh3d_utils.py; csrc/render/hunyuan3d_rasterizer, csrc/render/mesh_processor (C++/CUDA).

Pipeline Stages

  • Shape: hunyuan3d_shape.py — BeforeDenoising → Denoising → Export → Save.
  • Paint: hunyuan3d_paint.py — Preprocess → TexGen → Postprocess.
  • Main pipeline: hunyuan3d_pipeline.pyHunyuan3D2Pipeline composes the above stages and uses _resolve_class / resolve_hunyuan3d_tool to resolve non-diffusers components.

Model Loading Flow

  • Replace the “multiple files + diffusers layout” flow with “single checkpoint + prefix-based splitting + YAML config”; the DiT is still built via meta instantiation and weight loading with load_model_from_full_model_state_dict and an optional param_names_mapping.

Attention Backend Adaptation

  • Hunyuan3D DiT: DiT uses SGLang’s LocalAttention (with FA/TORCH_SDPA);
  • UNet 2.5D replaces Diffusers’ attention with SGLangAttentionWrapper, which calls the same backends via get_attn_backend().

Accuracy Tests

Align with Hunyuan3D 2.0

How to Use

sglang generate   --model-path tencent/Hunyuan3D-2   --image-path demo.png --save-output --output-path outputs

TP

sglang generate   --model-path tencent/Hunyuan3D-2  --image-path demo.png  --save-output  --output-path outputs --tp-size 2 --num-gpus 2

Example

Open glb file in https://gltf-viewer.donmccurdy.com/

1

input

demo

output

screenshot
截屏2026-02-19 19 53 43
1 gpu

https://github.com/Prozac614/Hunyuan3D-example/blob/main/1/1gpu.glb

tp 2

https://github.com/Prozac614/Hunyuan3D-example/blob/main/1/tp.glb

2

input

004

output

screenshot
截屏2026-02-19 19 52 30
1 gpu

https://github.com/Prozac614/Hunyuan3D-example/blob/main/2/1gpu.glb

tp 2

https://github.com/Prozac614/Hunyuan3D-example/blob/main/2/tp2.glb

3

input

052

output

screenshot
截屏2026-02-19 23 58 11
1gpu

https://github.com/Prozac614/Hunyuan3D-example/blob/main/3/1gpu.glb

tp 2

https://github.com/Prozac614/Hunyuan3D-example/blob/main/3/output_20260219-153808.glb

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

@Prozac614
Copy link
Copy Markdown
Contributor Author

still some errors in CI

Fixed

@yhyang201
Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

@mickqian
Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

@mickqian
Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

@mickqian
Copy link
Copy Markdown
Collaborator

mickqian commented Mar 1, 2026

/rerun-failed-ci

1 similar comment
@yhyang201
Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

@mickqian mickqian merged commit 57c5c34 into sgl-project:main Mar 2, 2026
388 of 440 checks passed
@mickqian
Copy link
Copy Markdown
Collaborator

mickqian commented Mar 2, 2026

since this is a huge PR, please keep monitoring the model correctness and code quality. Cheers 🙂

@Prozac614
Copy link
Copy Markdown
Contributor Author

since this is a huge PR, please keep monitoring the model correctness and code quality. Cheers 🙂

Yes, sir

Kangyan-Zhou pushed a commit to Kangyan-Zhou/sglang that referenced this pull request Mar 4, 2026
Co-authored-by: yingluosanqian <yingluosanqian@gmail.com>
Co-authored-by: daiweitao <dwti614707404@163.com>
Co-authored-by: Mick <mickjagger19@icloud.com>
magicYang1573 pushed a commit to magicYang1573/sglang that referenced this pull request Mar 9, 2026
Co-authored-by: yingluosanqian <yingluosanqian@gmail.com>
Co-authored-by: daiweitao <dwti614707404@163.com>
Co-authored-by: Mick <mickjagger19@icloud.com>
Wangzheee pushed a commit to Wangzheee/sglang that referenced this pull request Mar 21, 2026
Co-authored-by: yingluosanqian <yingluosanqian@gmail.com>
Co-authored-by: daiweitao <dwti614707404@163.com>
Co-authored-by: Mick <mickjagger19@icloud.com>
JustinTong0323 pushed a commit to JustinTong0323/sglang that referenced this pull request Apr 7, 2026
Co-authored-by: yingluosanqian <yingluosanqian@gmail.com>
Co-authored-by: daiweitao <dwti614707404@163.com>
Co-authored-by: Mick <mickjagger19@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file diffusion SGLang Diffusion npu run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants