Repository navigation
Conversation
Pin NanoVDB to 71ae97d42, the head of openvdb's develop/nanovdb branch, which adds the batch-capable TopologyBuilder (AcademySoftwareFoundation/openvdb#2336) that fvdb's batched topology construction will move onto (openvdb#785). The pin crosses 23 NanoVDB commits; three of them need changes here, because fvdb builds with -Werror: - AcademySoftwareFoundation/openvdb#2373 deprecates memory resources without operator==. TorchResource is stateless, so any two instances compare equal. Two TorchDeviceResources compare equal when they share a device type: torch's CUDA allocator frees a block on whichever device holds it, and PrivateUse1 memory frees only through the PrivateUse1 allocator. - AcademySoftwareFoundation/openvdb#2378 deprecates cuda::detail::HandleFactory, which already forwarded to GridHandle::adopt and GridHandle::metaData. Call those directly in GridStorage.cu and DeviceGridHandleUtils.cuh; behavior is unchanged. - AcademySoftwareFoundation/openvdb#2207 made the Vec3 constructor constexpr, so nvcc now reports the unused `half` variable in primalVoxelTransformForSizeAndOrigin as error 177-D. Remove it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
Replace the sort-based batched topology engine from openvdb#757 with NanoVDB's batch-capable tools::cuda::TopologyBuilder (AcademySoftwareFoundation/openvdb#2336), as planned in openvdb#785. The API (TopologyPassSpec, batchedTopologyStorage) and every call site are unchanged; the emit/sort/dedup engine is removed. Each pass reads every source grid's upper-node bounding boxes back with one host wait and derives each output grid's speculative root tiles the way NanoVDB's RefineGrid, CoarsenGrid and DilateGrid do. One launch over all source leaves fills the builder's densified child masks, through NanoVDB's Refine/Coarsen functors or fvdb's BoxDilate marking; the builder counts nodes and writes every node; a second launch writes the leaf value masks. BoxDilate runs one work item per (source leaf, target leaf offset) pair. The builder densifies about 16.5 MiB of lower-node masks per speculative root tile, so a pass splits the batch into chunks of at most FVDB_TOPOLOGY_MAX_TILES tiles (default 64). Chained passes read their sources across chunks; the last pass's chunks are assembled with assembleGridStorage, or adopted when there is one. The builder is cached per stream so its pinned staging is allocated once. Tests add a fixture spread over many root tiles and a check that a chunked build matches an unchunked one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
This was referenced Oct 22, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #785. Stacked on #834 (NanoVDB pin bump). Until #834 merges, this PR also shows that commit. Review only the commits after
1b79f2fd:2268751e(the engine) and737eabca(comment cleanup).Summary
This PR replaces the sort-based batched topology engine from #757 with NanoVDB's batch-capable
tools::cuda::TopologyBuilder(AcademySoftwareFoundation/openvdb#2336). After it lands,TopologyBuilderis fvdb's only batched topology engine. A reference copy of the sort engine lives onswahtz:reference/sort-engine.The API (
TopologyPassSpec,batchedTopologyStorage) and every call site stay the same. Refine, coarsen and box dilation produce the same topology as before, bit for bit.How a pass runs
RefineGrid,CoarsenGridandDilateGriddo.Chunking
TopologyBuilderallocates about 16.5 MiB of dense lower-node masks for each speculative root tile.FVDB_TOPOLOGY_MAX_TILEStiles (default 64). That caps scratch at about 1.06 GiB.assembleGridStorage(Builders produce GridStorage; one grid assembler (#770 step 5) #788). Batch NanoVDB's TopologyBuilder upstream and make it fvdb's batched topology engine #785 planned a newconcatenateGridBuffershelper here, butassembleGridStoragealready does the job.cudaFreeHostsynchronizes the device.Benchmark
The table compares this PR with main's sort engine. Times are medians over 20 runs. Peak is the extra device memory one call allocates.
conv_transpose_grid(2, 2)for refine,conv_grid(2, 2)for coarsen,conv_grid(3, 1)for dilate.corner64shifts eachshell64grid so it touches ijk = 0. A k3s1 dilation then reaches ijk = -1, which adds 7 more root tiles per grid.Refine and coarsen on
corner64matchshell64, so the table leaves those rows out for B=1 and B=16. Every output matched main's ijk and offsets exactly.Other changes
BuildCoarseGridFromFine.cuandBuildFineGridFromCoarse.cunow say "two host waits per pass" instead of one stream synchronization.BatchedTopologyBuilder.cuhnow compile in 71-73 s each, down from 113-116 s on main.Test plan
./build.sh wheel(CUDA 13.4, sm_120)cd tests && pytest -q unit/test_batched_topology_builder.py unit/test_conv_default.py unit/test_conv_ground_truth.py unit/test_conv_semantics.py unit/test_conv_semantics_integration.py unit/test_conv_transpose_default.py unit/test_conv_transpose_ground_truth.pygives 349 passedcd tests && pytest unit -qgives 3115 passed, 85 skippedwide_bboxfixture: 3 grids, each with 12 clusters spread over [-12000, 12000)³, so each grid spans many root tilestest_chunked_build_matches_unchunked: refine x4, coarsen x4, conv k3s1, conv k5s1 and convT k3s2 withFVDB_TOPOLOGY_MAX_TILES=1, compared with the unchunked buildclang-format-18 --style=file --dry-runandruff check --select I/ruff format --checkreport nothing on the changed files🤖 Generated with Claude Code