How to use underlying representation for a new task with different input/output dimensions? #148
-
This code and project are awesome! Thanks a lot. In terms of building upon this, I wonder how to access, edit and train the underlying hash+NN representation for a new task. For example, let's say I have a task with different number of input or output coordinates, e.g. some special video++ like representation which should be directly fitted like the image is done in the demo (e.g. 3 input coordinates (x,y,t) and 5 output coordinates (r,g,b,a,b)). Do I have access through this code (ideally python bindings, but if not then some c code), to edit the number of input and output coordinates, to provide my own training data which fits with these input/output coordinates, and train your hash+NN representation on a new task? If this is possible with the code, then pointers on how to do this would be very much appreciated. I'm currently very lost with how to expose this ability in your code base. Making this easier to do (e.g. easy python bindings), I'm sure would be greatly appreciated by the research community, in order to be able to build upon this awesome work as easily as possible. Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 15 comments
-
30 minutes more of digging: an attempt to answer my own question (my current understanding, please correct if I am wrong):
Please let me know if this is correct? Also I would LOVE to see either: Will leave open until confirming what I have said above is correct. |
Beta Was this translation helpful? Give feedback.
-
Correct!
a) colleagues of ours have internally built a functional (but not quite ready) PyTorch wrapper around tiny-cuda-nn (both the encoding and the MLPs), which we hope to release soonish. Based on experience so far, there will be a slowdown compared to the native C++ API, but still significantly faster than Python-native MLPs. b) I actually made one of those ages ago and found it difficult to get good performance -- to the point where the hash encoding was much slower than the frequency encoding in these frameworks. The dynamic indexing required by the hash table lookups really does not play to the strengths of these tensor-based frameworks. Plus, these frameworks don't (to my knowledge) expose good primitives to write cache-local / shmem-based fused kernel code. Loads of wasted bandwidth going back and forth to GPU RAM. That said, I am not a PyTorch/TF wizard by any stretch, so maybe somebody else can cook something up. I'd welcome it for sure! But ultimately, I think the easier way forward is to go with a proper wrapper as we plan. |
Beta Was this translation helpful? Give feedback.
-
Re (b): what was the issue you were seeing around dynamic indexing? I'd imagine you were probably using Do you recall around how long it was taking? I'm interested in applications of the hash encoding technique that might not be quite so latency sensitive as instant rendering. :) |
Beta Was this translation helpful? Give feedback.
-
Pretty much! My "quick and dirty" implementation used I'm hesitant to share too many details because it has been so long, the hyperparameters of the hash tables were very different then, and the experiments were anything but systematic. What I feel comfortable saying:
But I feel it's important to clarify that I don't want to discourage TF/PyTorch implementations of the encoding at all! As you say, the perf vs. quality tradeoff may still be favorable -- even if slower than a dedicated op/kernel -- especially since the encoding takes just a couple dozen lines of code to implement in Python. What I mostly wanted to convey above was that I feel like a custom op will give most people a more favorable trade-off between performance and hackability. |
Beta Was this translation helpful? Give feedback.
-
Makes a lot of sense. I think there's a lot of room for further exploration of the hash encoding method, so standalone ops for using it in existing frameworks would be very useful, esp. since CUDA wizardry is a rare talent. Also, thank you, this is some incredible work y'all have done. |
Beta Was this translation helpful? Give feedback.
-
Just to hop back on the Pytorch wrapper of tiny-cuda-nn, would soon-ish be somewhere in the realm of next quarter, or beyond? |
Beta Was this translation helpful? Give feedback.
-
Definitely in the next quarter. Probably much sooner (~month scale) |
Beta Was this translation helpful? Give feedback.
-
I made a pytorch binding of the hashgrid encoder here, but the native MLP in pytorch is still the major time bottleneck. Looking forward to the official implementation :) |
Beta Was this translation helpful? Give feedback.
-
I just pushed a first version (call it "beta") for a PyTorch extension of tiny-cuda-nn. See this section of the README for installation/usage instructions and please do report problems you encounter along the way. :) |
Beta Was this translation helpful? Give feedback.
-
Amazing! Will spend today playing this this and let you know how it goes! |
Beta Was this translation helpful? Give feedback.
-
So I played with this today and here are the results: 1.) Installing and running the 2D (image reconstruction) demo: 2.) Trying to incorporate into a NeRF framework (steps to reproduce below): Below I detail exactly how to reproduce these results so that if someone else is interested they can build upon this and try to make it work, and let me know what I am doing wrong. Steps:
|
Beta Was this translation helpful? Give feedback.
-
I can't spend any more time on this. So if someone can get this to work properly, and let me know would be super. Especially if anyone finds the code above helpful :) |
Beta Was this translation helpful? Give feedback.
-
If people want to contribute to this, we're building this code open source together here: |
Beta Was this translation helpful? Give feedback.
-
Perhaps it's worth trying to use (You'll need to pull the latest tiny-cuda-nn to get fp32 encoding support.) |
Beta Was this translation helpful? Give feedback.
-
Thanks for the detailed address! @Tom94 |
Beta Was this translation helpful? Give feedback.
I just pushed a first version (call it "beta") for a PyTorch extension of tiny-cuda-nn. See this section of the README for installation/usage instructions and please do report problems you encounter along the way. :)