This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
Optimizer MXKVStoreUpdater bug fix in serializeState method #14337
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.
PR Fixes #14265
Description
Currently there is a bug in the way Optimizer is trying to serialize state which fails when trying to deserialize Optimizer that has no
states
(like SGD without momentum).Issue
Currently the way serialize is being done is as below: (pasting Optimizer.serailizeState())
When an Optimizer without
states
like SGD with momentum set as0
is being used. Thestates
map (Map[Int, AnyRef]
) contains a (key, value) pair as (some integer index
,null
).The above serialize method does not write
k
as the value ofkey
and0
as the value ofstateBytes
, due to the null checkif (v != null)
Now while deserializing: (Pasting code from Optimizer.deserializeState())
In the
foreach
loop, the key is being read (which wasn't serialized previously) hence, this would cause anjava.io.EOFException
.Solution.
Get rid of
if (v != null)
check and retain the rest.