Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Conversation

@ptrendx
Copy link
Member

@ptrendx ptrendx commented Aug 29, 2017

No description provided.

@ptrendx ptrendx mentioned this pull request Sep 24, 2017
@ptrendx ptrendx force-pushed the fp32_weight_master_copy branch from 936e2bd to 5becd3d Compare September 25, 2017 18:19
"""
weight_master_copy = None
if self.multi_precision and weight.dtype == numpy.float16:
weight_master_copy = array(weight, ctx=weight.context, dtype=numpy.float32)
Copy link
Contributor

Choose a reason for hiding this comment

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

weight.astype(float32)

# Wrapper for mixed precision
weight_master_copy = state[0]
original_state = state[1]
grad32 = array(grad, ctx=grad.context, dtype=numpy.float32)
Copy link
Contributor

Choose a reason for hiding this comment

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

grad.astype

original_state = state[1]
grad32 = array(grad, ctx=grad.context, dtype=numpy.float32)
self.update(index, weight_master_copy, grad32, original_state)
weight[:] = weight_master_copy.astype(weight.dtype)
Copy link
Contributor

Choose a reason for hiding this comment

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

nd.cast(weight, dtype=weight.dtype, out=weight) to avoid a copy

The state associated with the weight.
"""

def create_mp_state(self, index, weight):
Copy link
Contributor

Choose a reason for hiding this comment

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

Use full name create_state_multi_precision

"""

def create_mp_state(self, index, weight):
"""Creates auxiliary state for a given weight, including FP32 master
Copy link
Contributor

Choose a reason for hiding this comment

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

including FP32 master copy if necessary.
->
including fp32 high precision copy if original weight is fp16

"""
raise NotImplementedError()

def update_mp(self, index, weight, grad, state):
Copy link
Contributor

Choose a reason for hiding this comment

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

update_multi_precision

return momentum

def update(self, index, weight, grad, state):
def create_state(self, index, weight):
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be a _create_state_impl function that both create_mp_state and create_state use. And create_state should keep the original behavior (always multi_precision=False)

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 don't think _create_state_impl is necessary, since this is basically create_state.

rg_options = [{}, {'rescale_grad': 0.14}, {'rescale_grad': 0.8}]
wd_options = [{}, {'wd': 0.03}, {'wd': 0.05}, {'wd': 0.07}]
mp_options = [{}, {'multi_precision': False}, {'multi_precision': True}]
for dtype in [np.float16, np.float32]:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is exploding exponentially...

Copy link
Member Author

Choose a reason for hiding this comment

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

And that is fine - previously there was a list of test cases where it was really hard to make sure that all possible combinations of parameters are tested (and all possible combinations should be tested). This design guarantees that.

@ptrendx ptrendx force-pushed the fp32_weight_master_copy branch from 6bd2368 to df3c841 Compare October 3, 2017 21:39
@ptrendx ptrendx force-pushed the fp32_weight_master_copy branch from df3c841 to 9cab44a Compare October 5, 2017 22:09
@piiswrong
Copy link
Contributor

I think you need to merge in master

@ptrendx
Copy link
Member Author

ptrendx commented Oct 6, 2017

I did (and it fixed a lot of errors) but I still got an unrelated segfault :-(.

@ptrendx
Copy link
Member Author

ptrendx commented Oct 6, 2017

@piiswrong Passed!

@piiswrong piiswrong merged commit ee97715 into apache:master Oct 8, 2017
@piiswrong
Copy link
Contributor

Thanks

mbaijal pushed a commit to mbaijal/incubator-mxnet that referenced this pull request Oct 9, 2017
* Making mixed precision work with all optimizers

* Restart CI

* Restart CI
mbaijal pushed a commit to mbaijal/incubator-mxnet that referenced this pull request Oct 12, 2017
* Making mixed precision work with all optimizers

* Restart CI

* Restart CI
crazy-cat pushed a commit to crazy-cat/incubator-mxnet that referenced this pull request Oct 26, 2017
* Making mixed precision work with all optimizers

* Restart CI

* Restart CI
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants