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

Utilities for deterministic unit tests #497

Closed

Conversation

ebsmothers
Copy link
Contributor

Summary:
A longstanding pain point of ours has been writing unit tests that

(a) are nontrivial enough to catch any regressions, and
(b) don't break every time we add a new test case, change model initialization order, or perform other superficial refactors.

Random initialization usually passes (a) but fails (b), while deterministic initialization (e.g.) does the opposite.

This diff introduces a utility for constructing deterministic but nontrivial tensors of any shape, with flexibility so the user can determine the tensor's range. As an easy extension, we also add a utility to initialize nn.Module parameters in the same way.

Differential Revision: D50251029

@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 Oct 18, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D50251029

ebsmothers added a commit to ebsmothers/multimodal that referenced this pull request Oct 18, 2023
Summary:

A longstanding pain point of ours has been writing unit tests that

(a) are nontrivial enough to catch any regressions, and
(b) don't break every time we add a new test case, change model initialization order, or perform other superficial refactors.

Random initialization usually passes (a) but fails (b), while deterministic initialization ([e.g.](https://github.com/facebookresearch/multimodal/blob/2ddb8cdb205f2035e88e4fafb7e88cccb7b99705/tests/test_utils.py#L192)) does the opposite.

This diff introduces a utility for constructing deterministic but nontrivial tensors of any shape, with flexibility so the user can determine the tensor's range. As an easy extension, we also add a utility to initialize nn.Module parameters in the same way.

Differential Revision: D50251029
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D50251029

Summary:

A longstanding pain point of ours has been writing unit tests that

(a) are nontrivial enough to catch any regressions, and
(b) don't break every time we add a new test case, change model initialization order, or perform other superficial refactors.

Random initialization usually passes (a) but fails (b), while deterministic initialization ([e.g.](https://github.com/facebookresearch/multimodal/blob/2ddb8cdb205f2035e88e4fafb7e88cccb7b99705/tests/test_utils.py#L192)) does the opposite.

This diff introduces a utility for constructing deterministic but nontrivial tensors of any shape, with flexibility so the user can determine the tensor's range. As an easy extension, we also add a utility to initialize nn.Module parameters in the same way.

Differential Revision: D50251029
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D50251029

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in dfe59a5.

@ebsmothers ebsmothers deleted the export-D50251029 branch October 19, 2023 03:00
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. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants