forked from apache/mxnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving documentation and error messages for Async distributed trai…
…ning with Gluon (apache#11910) * Add description about update on kvstore * add async check for gluon * only raise error if user set update_on_kvstore * fix condition * add async nightly test * fix case when no kvstore * add example for trainer creation in doc
- Loading branch information
1 parent
98b8e23
commit c950c06
Showing
3 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python | ||
|
||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# pylint: skip-file | ||
import sys | ||
sys.path.insert(0, "../../python/") | ||
import mxnet as mx | ||
|
||
kv = mx.kv.create('dist_async') | ||
my_rank = kv.rank | ||
nworker = kv.num_workers | ||
|
||
def test_gluon_trainer_type(): | ||
def check_trainer_kv_update(update_on_kv): | ||
params = mx.gluon.ParameterDict() | ||
x = params.get('x', shape=(10,1), lr_mult=1.0) | ||
params.initialize(ctx=[mx.cpu(0), mx.cpu(1)], init='zeros') | ||
try: | ||
trainer = mx.gluon.Trainer(params, 'sgd', {'learning_rate': 0.1}, kvstore=kv, update_on_kvstore=update_on_kv) | ||
trainer._init_kvstore() | ||
assert trainer._kv_initialized | ||
assert trainer._update_on_kvstore is True | ||
except ValueError: | ||
assert update_on_kv is False | ||
|
||
check_trainer_kv_update(False) | ||
check_trainer_kv_update(True) | ||
check_trainer_kv_update(None) | ||
print('worker ' + str(my_rank) + ' passed test_gluon_trainer_type') | ||
|
||
if __name__ == "__main__": | ||
test_gluon_trainer_type() |