Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hashgrid PyTorch implementation #132

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

alvaro-budria
Copy link
Contributor

@alvaro-budria alvaro-budria commented Mar 22, 2023

The current PyTorch implementation of the hash grid interpolation in wisp is not correct. I modified it and tested it by executing

WISP_HEADLESS=1 python3 app/nerf/main_nerf.py --config app/nerf/configs/nerf_hash.yaml --dataset-path ../V8_/ --dataset-num-workers 2

It seems it's producing the same results as the default CUDA implementation after training for 50 epochs:

Implementation Loss PSNR time/it
CUDA $1.213 \cdot 10^{-2}$ 27.34 ~1 min/it
PyTorch $1.194 \cdot 10^{-2}$ 27.22 ~7 min/it

I noticed that in the original implementation in wisp, the coordinates are hashed by rolling the prime on the dimension index:

cc[...,0] * PRIMES[(i*3+0)%len(PRIMES)]

but in https://github.com/NVlabs/tiny-cuda-nn/blob/master/include/tiny-cuda-nn/encodings/grid.h, function lcg_hash, they just keep each prime fixed to a dimension, which is what I do here.

This PR resolves this issue.

@alvaro-budria alvaro-budria marked this pull request as ready for review March 22, 2023 12:05
@orperel
Copy link
Collaborator

orperel commented Mar 23, 2023

Looks great, thanks for fixing this @alvaro-budria ! :)

@orperel orperel closed this Mar 23, 2023
@orperel orperel reopened this Mar 23, 2023
@orperel orperel merged commit fc2d451 into NVIDIAGameWorks:main Mar 23, 2023
orperel pushed a commit to AvivSham/kaolin-wisp that referenced this pull request May 30, 2023
The current PyTorch reference implementation of the hash grid interpolation in
`wisp` is not correct (incorrect prime, and code out of date). 
This PR resolves: NVIDIAGameWorks#129).
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.

Naive PyTorch Hashgrid implementation is incorrect
2 participants