-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Fix dist error with lr decay layer #9489
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
Merged
gongweibao
merged 9 commits into
PaddlePaddle:develop
from
Yancey0623:fix_dist_with_lr_decay
Mar 30, 2018
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b92aeae
Fix dist error with lr decay layer
Yancey0623 ce2e0a8
update
Yancey0623 c2fcbf7
analyse lr ops in transpiler
Yancey0623 c8eca6b
revert optimize.py
Yancey0623 1dda42a
Merge branch 'develop' of github.com:PaddlePaddle/Paddle into fix_dis…
Yancey0623 1b07d06
update
Yancey0623 633a8b2
update comments
Yancey0623 05d5e26
use self.program instead of default_main_program
Yancey0623 b7ffd5d
fix ci
Yancey0623 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 |
|---|---|---|
|
|
@@ -338,15 +338,24 @@ def __append_optimize_op__(op, block): | |
| else: | ||
| self._append_pserver_non_opt_ops(block, op) | ||
|
|
||
| append_block = optimize_block | ||
| # append lr decay ops to the child block if exits | ||
| lr_ops = self._get_lr_ops() | ||
| if len(lr_ops) > 0: | ||
| for _, op in enumerate(lr_ops): | ||
| self._append_pserver_non_opt_ops(append_block, op) | ||
|
|
||
| append_block = pserver_program.create_block(append_block.idx) | ||
|
|
||
| # append op to the current block | ||
| per_opt_block = optimize_block | ||
| per_opt_block = append_block | ||
| for _, opt_op in enumerate(opt_op_on_pserver): | ||
| for _, op in enumerate(self.optimize_ops): | ||
| # optimizer is connected to itself | ||
| if ufind.is_connected(op, opt_op) and \ | ||
| op not in global_ops: | ||
| __append_optimize_op__(op, per_opt_block) | ||
| per_opt_block = pserver_program.create_block(0) | ||
| per_opt_block = pserver_program.create_block(append_block.idx) | ||
|
|
||
| # append global ops | ||
| for glb_op in global_ops: | ||
|
|
@@ -786,3 +795,32 @@ def _get_output_map_from_op(self, varmap, op): | |
| else: | ||
| iomap[key] = vars | ||
| return iomap | ||
|
|
||
| def _get_lr_ops(self): | ||
| lr_ops = [] | ||
| # find lr variables by optimize op | ||
| lr_vars = set() | ||
| for op in self.optimize_ops: | ||
| if self._is_opt_op(op): | ||
| lr_vars.add(op.input("LearningRate")[0]) | ||
|
|
||
| find_ops = [] | ||
| # find ops which output is lr var | ||
| # make a union-find struct by all ops | ||
| block = default_main_program().global_block() | ||
|
||
| for op in block.ops: | ||
| if set(op.output_arg_names) & lr_vars: | ||
| find_ops.append(op) | ||
| # make a union find struct by default_main_program | ||
| ufind = UnionFind(block.ops) | ||
| for op1 in block.ops: | ||
| for op2 in block.ops: | ||
| if op1 != op2 and self._is_op_connected(op1, op2) and \ | ||
| not self._is_opt_op(op1) and not self._is_opt_op(op2): | ||
| ufind.union(op1, op2) | ||
| # find all ops which related lr var | ||
| for op1 in block.ops: | ||
| for op2 in find_ops: | ||
| if ufind.is_connected(op1, op2): | ||
| lr_ops.append(op1) | ||
| return lr_ops | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's smart.