-
Notifications
You must be signed in to change notification settings - Fork 53
Add warning for batched mode when a sub objective has rev mode #2284
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
Open
dpanici
wants to merge
10
commits into
master
Choose a base branch
from
dp/rev-mode-batched-warn
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+31
−4
Open
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f8a5efb
add warning for batched mode when a sub objective has rev mode
dpanici f3830f8
update warning to include warning that sub-objective may not support …
dpanici 61b868d
make message clearer, add printout of which objectives use rev mode, …
dpanici 66b9318
tweak message
dpanici 4c67fef
Merge branch 'master' into dp/rev-mode-batched-warn
YigitElma f83d694
Merge branch 'master' into dp/rev-mode-batched-warn
YigitElma f163f9b
update changelog
YigitElma 03390d9
Merge branch 'master' into dp/rev-mode-batched-warn
YigitElma 064e0ff
Merge branch 'master' into dp/rev-mode-batched-warn
YigitElma 20fcec1
Merge branch 'master' into dp/rev-mode-batched-warn
YigitElma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -435,7 +435,7 @@ def _unjit(self): | |||||
| pass | ||||||
|
|
||||||
| @execute_on_cpu | ||||||
| def build(self, use_jit=None, verbose=1): | ||||||
| def build(self, use_jit=None, verbose=1): # noqa: C901 | ||||||
| """Build the objective. | ||||||
|
|
||||||
| Parameters | ||||||
|
|
@@ -511,6 +511,21 @@ def build(self, use_jit=None, verbose=1): | |||||
| else: | ||||||
| self._deriv_mode = "blocked" | ||||||
|
|
||||||
| rev_objs = [ | ||||||
| o.__class__.__name__ for o in self.objectives if o._deriv_mode == "rev" | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ] | ||||||
| warnif( | ||||||
| len(rev_objs) > 0 and self._deriv_mode == "batched", | ||||||
| UserWarning, | ||||||
| "'batched' deriv_mode differentiates the whole ObjectiveFunction in " | ||||||
| "forward mode, but these sub-objectives are set to use reverse mode " | ||||||
| "(either automatically, from their input/output sizes, or by user): " | ||||||
| f"{rev_objs}. \n" | ||||||
| "In forward mode these may under-perform, or they may not " | ||||||
| "support forward mode. Consider 'blocked' deriv_mode. See the " | ||||||
| "sub-objective docstrings for details.", | ||||||
| ) | ||||||
|
|
||||||
| errorif( | ||||||
| isposint(self._jac_chunk_size) and self._deriv_mode in ["blocked"], | ||||||
| ValueError, | ||||||
|
|
@@ -546,6 +561,12 @@ def build(self, use_jit=None, verbose=1): | |||||
|
|
||||||
| timer.stop("Objective build") | ||||||
| if verbose > 1: | ||||||
| print(f"{self.name} deriv_mode : {self._deriv_mode}") | ||||||
| if self._deriv_mode == "batched": | ||||||
| print(f"{self.name} jac_chunk_size: {self._jac_chunk_size}") | ||||||
| else: | ||||||
| for o in self.objectives: | ||||||
| print(f"{o.name} jac_chunk_size: {o._jac_chunk_size}") | ||||||
| timer.disp("Objective build") | ||||||
|
|
||||||
| def _set_things(self, things=None): | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.