Repository navigation
Conversation
`torch.cdist` selects a matrix-multiply distance formula when there are more than 25 points. Its subtraction of large squared world coordinates suffers catastrophic cancellation. For 32 points spaced one unit apart, translating all coordinates by 10000 changes initialized nearest-neighbour scale from 1 to 1e-7.
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.
torch.cdist switches to a matrix-multiply distance identity for larger point sets. Subtracting large squared world coordinates loses the small relative distances: translating 32 unit-spaced points by 10,000 can change initialized neighbor scales from 1 to 1e-7.
Use direct Euclidean differences in each existing chunk, mask each query's actual self index and select its k nearest other points. Chunking and the log-scale/epsilon contract remain unchanged.
Validation on Python 3.12.14 / PyTorch 2.8.0+cpu, with native full-package imports and the repository pytest configuration:
The direct distance mode trades throughput for numerical stability. A bounded single-thread CPU microbenchmark (k=3, chunk=256, five measured repetitions) gave median 2.01→2.73 ms for 512 points and 21.28→34.13 ms for 2,048 points. These are local observations, not a GPU or complete-training performance estimate. CUDA, full reconstruction/rendering and large-scene memory benchmarks were not run.