[PR #232] [MERGED] Add 3D mesh operations for remeshing (CORE-560) #241

Closed
opened 2026-10-26 22:21:56 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-kitchen/pull/232
Author: @kijai
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @comfyanonymous

Base: main ← Head: mesh-ops


📝 Commits (6)

  • b443aab Add delaunay3d, mesh_bvh, connected_components, edge_collapse_checks and min_cut CUDA ops
  • 172365b Fix unused unpacked variables in test_delaunay3d
  • 0fcdd3c Drop numpy from test_edge_collapse
  • 2166482 Fixes for reviewer
  • f07199f Small fix
  • 0359264 Validate shapes, device and cutoff in mesh BVH and Delaunay ops

📊 Changes

15 files changed (+2677 additions, -0 deletions)

View changed files

📝 README.md (+6 -0)
📝 comfy_kitchen/__init__.py (+97 -0)
📝 comfy_kitchen/backends/cuda/CMakeLists.txt (+5 -0)
📝 comfy_kitchen/backends/cuda/__init__.py (+360 -0)
📝 comfy_kitchen/backends/cuda/dlpack_bindings.cpp (+223 -0)
➕ comfy_kitchen/backends/cuda/ops/connected_components.cu (+90 -0)
➕ comfy_kitchen/backends/cuda/ops/delaunay3d.cu (+562 -0)
➕ comfy_kitchen/backends/cuda/ops/edge_collapse.cu (+154 -0)
➕ comfy_kitchen/backends/cuda/ops/mesh_bvh.cu (+278 -0)
➕ comfy_kitchen/backends/cuda/ops/min_cut.cu (+230 -0)
➕ tests/test_connected_components.py (+73 -0)
➕ tests/test_delaunay3d.py (+128 -0)
➕ tests/test_edge_collapse.py (+165 -0)
➕ tests/test_mesh_bvh.py (+134 -0)
➕ tests/test_min_cut.py (+172 -0)

📄 Description

Add CUDA geometry ops for mesh processing

ComfyUI's mesh post-processing (solid remesh, decimation, repair) needs a few geometry primitives on the GPU.

On a 1536-grid remesh, scipy's Delaunay takes 37 s and a torch push-relabel 18 s, versus 0.3 s and 0.5 s with these kernels.

Five CUDA-only ops in plain CUDA C++

  • delaunay3d(points) — gDel3D-style parallel insertion + 2-3/3-2 flips; the bounding
    tet's vertices are kept so callers can tell outside tets; float64 orientation predicates
    with a double-double fallback.
  • mesh_bvh(tris) / closest_point_on_mesh(bvh, points, max_dist) — Karras LBVH, exact
    closest point; distance, point and face per query.
  • connected_components(edges, n) — ECL-CC lock-free union-find, min-index labels.
  • edge_collapse_checks(vertices, faces, edges, positions, cos_threshold) — flip / skinny /
    link-condition checks per candidate collapse over an in-kernel CSR fan; deterministic.
  • min_cut(nbr, cap, s_cap, t_cap) — push-relabel min s-t cut on bounded-degree graphs
    without float atomics (thread-order independent); returns the maximal source side.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-kitchen/pull/232 **Author:** [@kijai](https://github.com/kijai) **Created:** 10/5/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@comfyanonymous](https://github.com/comfyanonymous) **Base:** `main` ← **Head:** `mesh-ops` --- ### 📝 Commits (6) - [`b443aab`](https://github.com/Comfy-Org/comfy-kitchen/commit/b443aab66ab0a15d8d31f9d5bb9ba7defcf3c262) Add delaunay3d, mesh_bvh, connected_components, edge_collapse_checks and min_cut CUDA ops - [`172365b`](https://github.com/Comfy-Org/comfy-kitchen/commit/172365b70373ab72105c72e1b5697528900d0409) Fix unused unpacked variables in test_delaunay3d - [`0fcdd3c`](https://github.com/Comfy-Org/comfy-kitchen/commit/0fcdd3c958c600d0c887bbeb7e4a00365b7def3b) Drop numpy from test_edge_collapse - [`2166482`](https://github.com/Comfy-Org/comfy-kitchen/commit/216648298fd684b7b99ac1bcadb36a21957d4a07) Fixes for reviewer - [`f07199f`](https://github.com/Comfy-Org/comfy-kitchen/commit/f07199fecabee3a4ba039686d21efd63d9c1f4a1) Small fix - [`0359264`](https://github.com/Comfy-Org/comfy-kitchen/commit/03592649cb8b597498ddbb7905d3b7310d2dedba) Validate shapes, device and cutoff in mesh BVH and Delaunay ops ### 📊 Changes **15 files changed** (+2677 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+6 -0) 📝 `comfy_kitchen/__init__.py` (+97 -0) 📝 `comfy_kitchen/backends/cuda/CMakeLists.txt` (+5 -0) 📝 `comfy_kitchen/backends/cuda/__init__.py` (+360 -0) 📝 `comfy_kitchen/backends/cuda/dlpack_bindings.cpp` (+223 -0) ➕ `comfy_kitchen/backends/cuda/ops/connected_components.cu` (+90 -0) ➕ `comfy_kitchen/backends/cuda/ops/delaunay3d.cu` (+562 -0) ➕ `comfy_kitchen/backends/cuda/ops/edge_collapse.cu` (+154 -0) ➕ `comfy_kitchen/backends/cuda/ops/mesh_bvh.cu` (+278 -0) ➕ `comfy_kitchen/backends/cuda/ops/min_cut.cu` (+230 -0) ➕ `tests/test_connected_components.py` (+73 -0) ➕ `tests/test_delaunay3d.py` (+128 -0) ➕ `tests/test_edge_collapse.py` (+165 -0) ➕ `tests/test_mesh_bvh.py` (+134 -0) ➕ `tests/test_min_cut.py` (+172 -0) </details> ### 📄 Description ## Add CUDA geometry ops for mesh processing ComfyUI's mesh post-processing (solid remesh, decimation, repair) needs a few geometry primitives on the GPU. On a 1536-grid remesh, scipy's Delaunay takes 37 s and a torch push-relabel 18 s, versus 0.3 s and 0.5 s with these kernels. Five CUDA-only ops in plain CUDA C++ - `delaunay3d(points)` — gDel3D-style parallel insertion + 2-3/3-2 flips; the bounding tet's vertices are kept so callers can tell outside tets; float64 orientation predicates with a double-double fallback. - `mesh_bvh(tris)` / `closest_point_on_mesh(bvh, points, max_dist)` — Karras LBVH, exact closest point; distance, point and face per query. - `connected_components(edges, n)` — ECL-CC lock-free union-find, min-index labels. - `edge_collapse_checks(vertices, faces, edges, positions, cos_threshold)` — flip / skinny / link-condition checks per candidate collapse over an in-kernel CSR fan; deterministic. - `min_cut(nbr, cap, s_cap, t_cap)` — push-relabel min s-t cut on bounded-degree graphs without float atomics (thread-order independent); returns the maximal source side. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 22:21:56 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-kitchen#241
No description provided.