Skip to content

island discovery: dfs discovery with flood fill#1102

Open
thowell wants to merge 7 commits intogoogle-deepmind:mainfrom
thowell:dfs_discovery
Open

island discovery: dfs discovery with flood fill#1102
thowell wants to merge 7 commits intogoogle-deepmind:mainfrom
thowell:dfs_discovery

Conversation

@thowell
Copy link
Collaborator

@thowell thowell commented Jan 31, 2026

depends on #1100 and #1101

Model fields:
- ntree: number of kinematic trees
- tree_dofadr: start address of tree's DOFs (ntree,)
- tree_dofnum: number of DOFs in tree (ntree,)
- tree_bodynum: number of bodies in tree (ntree,)
- body_treeid: id of body's tree; -1 for static (nbody,)
- dof_treeid: id of dof's tree (nv,)

All fields are imported directly from mjModel via the dataclass field
matching pattern in put_model().

Test: test_tree_structure_fields verifies all fields match MuJoCo.
- _find_tree_edges kernel scans Jacobian for tree-tree connections
- On-device deduplication using radix sort and prefix sum compaction
- Helper kernels: _compute_edge_keys, _init_indices, _mark_unique_edges, _compact_edges
- find_tree_edges host function orchestrates the full pipeline
- 5 tests: single edge, self-edge, chain, deduplication, no constraints
@thowell thowell linked an issue Jan 31, 2026 that may be closed by this pull request
@thowell thowell mentioned this pull request Jan 31, 2026
matches MuJoCo's mj_floodFill() approach. This directly assigns
island IDs during traversal without needing iterative label updates.

Key changes:
- Add _flood_fill kernel that performs sequential DFS per world
- Each thread handles one world, using a stack for traversal
- Directly assigns island IDs to tree_island array
- Remove unused kernels (_init_labels, _compact_island_ids, _mark_roots)
@thowell thowell added this to the Islands milestone Feb 6, 2026
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.

sleeping islands

1 participant