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

Better floating point support #816

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

PerhapsS44
Copy link

Added target data dtype as command argument --data_dtype float16 or --data_dtype float32
This data dtype affects only how the original images are stored in memory, as these occupy the most memory. In comparison, all the other objects related to an image are very small in comparison (<20 numbers to be stored / object, ~12 objects in total)
The gaussian rasterizer does not support operations with data types other than float32, so converting these small objects to any other data type reduces the memory occupied, but increases the number of operations, as we have to convert back to float32 when rasterizing. Because these objects are so small, we do not care about them.

the original image is used only to calculate the loss, in the optimization step, and experimentally i found out that computing the loss between 2 float16 images is a lot faster than computing the loss between 2 float32 images, but may lead to an increased number of iterations necessary, since the loss is of type float16.

Lastly, to further decrease the memory usage, I added a new command argument --store_images_as_uint8, that, if set, will keep all the original images stored in memory as uint8, and will convert them to the target data type on demand. This increases the number of operations a bit, since we access the image more than once in the desired data type, but we save memory as all but one image are saved as uint8. Also, when transferring images to the GPU, we transfer 1 byte for uint8, instead of 4 bytes for float32, so this can be a speedup for the case when a user uses data_device=cpu.

TLDR:

--data_dtype float16 - converts original images to float16, memory halved and runtime decreased if compared to float32
--store_images_as_uint8 - converts to data_dtype on demand, memory used is minimal

Users may want to reduce their memory consumption by using fp16.
However, in my tests, such attempts will result in lower quality renders.
Some data type conversions did not have any impact, so I removed them completely.
Images are now loaded on the target device as uint8s.
Then they are converted to the target data type (eg. fp32 or fp16).
This speeds up the loading time.

Also, users can opt to store the image as uint8 or as target data type.
This will further reduce memory usage.
-> removing debug commentaries
-> removing unused proposed code
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.

None yet

2 participants