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

[WIP] torch.compile applied to ray sampling #2133

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

Conversation

jkulhanek
Copy link
Contributor

@jkulhanek jkulhanek commented Jun 26, 2023

This PR applies torch.compile to pixel sampling and ray generation.

We could theoretically see some speedup.

NOTE: I haven't tested all configurations.

@jkulhanek jkulhanek marked this pull request as draft June 26, 2023 10:17
@jkulhanek
Copy link
Contributor Author

On a simple scene without camera distortions, I am getting 166 train rays/s with torch compile vs 160 rays/s without -> roughly 4% speedup overall.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are any of the changes here necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, but tracing at the latter steps is a good idea. Should I undo the changes?

@@ -526,15 +517,28 @@ def setup_eval(self):
num_workers=self.world_size * 4,
)

@torch.compile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use from nerfstudio.utils.misc import torch_compile?

batch = self.train_pixel_sampler.sample(image_batch)
return self._next_train_compiled(image_batch)

@torch.compile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

torch_compile

nerfstudio/utils/tensor_dataclass.py Outdated Show resolved Hide resolved
@jkulhanek
Copy link
Contributor Author

Note: this is currently not ready for merging for the following reason:
When typeguard is enabled, the torch.compile fails for some reason (str has no _module attribute). This has to be resolved first.

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