Skip to content

Share persistent values among processes#486

Merged
muupan merged 16 commits intochainer:masterfrom
muupan:share-persistent-values
Nov 7, 2019
Merged

Share persistent values among processes#486
muupan merged 16 commits intochainer:masterfrom
muupan:share-persistent-values

Conversation

@muupan
Copy link
Member

@muupan muupan commented Jun 18, 2019

so that BatchNormalization etc can be safely shared among processes. This is required by #477

I'll remove [WIP] once I confirm that this enables training with batch normalization.

  • Add chainerrl.misc.namedpersistent, a function that mimics Add namedpersistent chainer#6788
  • Modify chainerrl.misc.async_.extract_params_as_shared_arrays and chainerrl.misc.async_.set_shared_params so that not only parameters but also persistent values are shared among processes.
  • Add code that checks if all the extracted values are used, and fix a bug in test found by the check.

@muupan muupan changed the title [WIP] Share persistent values among processes Share persistent values among processes Jun 19, 2019
@muupan muupan changed the title Share persistent values among processes [WIP] Share persistent values among processes Jun 19, 2019
@muupan muupan changed the title [WIP] Share persistent values among processes Share persistent values among processes Jun 21, 2019
@muupan
Copy link
Member Author

muupan commented Jun 21, 2019

I confirmed that this enabled training with batch normalization and actor-learner parallelism, so I removed [WIP].

@toslunar toslunar self-assigned this Sep 19, 2019
@toslunar toslunar self-requested a review September 19, 2019 05:01
for idx, link in enumerate(link._children):
prefix = '/{}'.format(idx)
for path, persistent in namedpersistent(link):
yield prefix + path, persistent
Copy link
Member

Choose a reason for hiding this comment

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

def _namedchildren(link):
    ...
    elif isinstance(link, chainer.ChainList):
        for idx, child in enumerate(link._children):
            yield str(idx), child

could avoid repeating the recursion logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure how. Can you give me some more detail? chainer/chainer#6788 is also implemented with recursion, and I don't think we need to deviate from it.

Copy link
Member

Choose a reason for hiding this comment

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

Probably I meant that a mutual recursion between namedpersistent and _namedchildren looks cleaner. It can be a matter of taste. Sorry that my previous comment is not readable (to me neither at first sight).

Copy link
Member Author

Choose a reason for hiding this comment

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

Understood, thanks! I modified accordingly, so can you check again?

@muupan muupan requested a review from toslunar November 6, 2019 14:09
@muupan
Copy link
Member Author

muupan commented Nov 7, 2019

/test

@pfn-ci-bot
Copy link
Collaborator

Successfully created a job for commit 4aaf766:

Copy link
Member

@toslunar toslunar left a comment

Choose a reason for hiding this comment

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

LGTM

@muupan
Copy link
Member Author

muupan commented Nov 7, 2019

/test

@pfn-ci-bot
Copy link
Collaborator

Successfully created a job for commit b82b710:

@muupan muupan merged commit 4151087 into chainer:master Nov 7, 2019
@muupan muupan deleted the share-persistent-values branch November 7, 2019 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants