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

Add support for masking jacobians of zero weights in the batch #398

Merged
merged 9 commits into from
Jan 13, 2023

Conversation

luisenp
Copy link
Contributor

@luisenp luisenp commented Dec 8, 2022

With this feature, the vectorizer is able to compute errors and jacobians only over batch indices that are known to be greater than zero. Preliminary tests on a simple problem indicate savings of ~18% compute time both in CPU and GPU.

For now I made the feature only applicable inside vectorization, although it might be safe to turn off in general.

@luisenp luisenp added the enhancement New feature or request label Dec 8, 2022
@luisenp luisenp self-assigned this Dec 8, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 8, 2022
Copy link
Contributor

@fantaosha fantaosha left a comment

Choose a reason for hiding this comment

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

LGTM. But I have some concerns about whether it is reasonable to ignore small non-zero cost weights.

theseus/core/cost_weight.py Outdated Show resolved Hide resolved
theseus/core/cost_weight.py Outdated Show resolved Hide resolved
theseus/core/cost_function.py Show resolved Hide resolved
Copy link
Member

@mhmukadam mhmukadam left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@fantaosha fantaosha left a comment

Choose a reason for hiding this comment

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

LGTM.

@luisenp luisenp merged commit f77c30c into main Jan 13, 2023
@luisenp luisenp deleted the lep.mask_jacobians branch January 13, 2023 21:44
bamos pushed a commit that referenced this pull request Jan 15, 2023
* Added CostWeight.is_zero() method.

* Add a masked_variable context for temporarily mask variables' tensors.

* Add logic to skip jacobians computation for zero weights in batch.

* Enable masked jacobians in vectorization.

* Detached zero mask computation and using smaller EPS.

* Added is_zero for GPCostWeight.

* Changed scale and diagonal weight is_zero to use == 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants