Skip to content
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

golang pserver use OptimizerConfig.proto #3358

Merged

Conversation

typhoonzero
Copy link
Contributor

Fix #3328

New golang pserver use OptimizerConfig.proto to configure pserver side.

This enables using both "old" configs using "TrainerConfig.proto" and new optimizer config using "OptimizerConfig.proto", ParameterConfig settings will overwrite the global config for variant parameter configuation

Copy link
Contributor

@dzhwinter dzhwinter left a comment

Choose a reason for hiding this comment

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

nice speed!
LGTM++

// NOTE: convert V1 OptimizatioinConfig proto to OptimizerConfig if
// OptimizerConfig not set. This makes golang pserver compatible with
// handy V1 demos. Support SGD only.
// TODO: Remove these lines when golang pserver is production ready
Copy link
Contributor

Choose a reason for hiding this comment

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

we really need to simplify this mess in the future. sgdConfigV2 , optimizerConfigNew_ , almost a nightmare to maintain.


# create new optimizer with proto config, add new optimizer here
self.__opt_conf_new__ = OptimizerConfig()
dict_to_protobuf(kwargs, self.__opt_conf_new__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the manually parsed optimizer configuration protobuf message human readable?
how about replacing them with built-in python API text_format?
https://stackoverflow.com/questions/33557965/print-human-friendly-protobuf-message
It can be printed in a pretty format, facilitate the future debug.

Copy link
Contributor

@helinwang helinwang left a comment

Choose a reason for hiding this comment

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

Please consider not adding a new API to the Python interface. Maybe it's hard, we can discuss more on this :)

for (int i = 0; i < parameterSize(); ++i) {
OptimizerConfig optConfigPerParameter;
Copy link
Contributor

@helinwang helinwang Aug 9, 2017

Choose a reason for hiding this comment

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

Sorry that you have to write this...
It's hard to maintain two version of the same thing. We added config V2 because V1 is a giant proto file which contains everything, which is too hard to understand and blocks the pserver optimizer implementation.

@@ -31,6 +31,13 @@ def main():

# create optimizer of new remote updater to pserver
optimizer = paddle.optimizer.Momentum(momentum=0, learning_rate=1e-3)
optimizer.set_remote_optimizer_config(
Copy link
Contributor

@helinwang helinwang Aug 9, 2017

Choose a reason for hiding this comment

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

I think we should not add a new API to the Python interface. The new API seems created because there are some implementation difficulties that we have. But from the user's perspective, a single optimizer concept seems to suffice. We probably should not introduce two concepts: remote optimizer and local optimizer to the user.

Curious how hard would it be if we keep the current Python interface, but convert the parsed V1 proto to V2 proto internally? (seems you have already written most of the code to do so).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, converting V1 config to V2 may lose some of the configuration fields, but it's still possible. We always intend to keep the user interface simple, will add the conversions.

But I think we still should keep set_remote_optimizer_config or rename to set_optimizer_config for detailed optimizer configs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In OptimizerConfig, each "parameter" object have a single configuration details, each "parameter" can have different algorithm like "SGD" or "Adagrad".

In V1 TrainerConfig.proto configs the global optimization algorithm for all parameters, and in ParameterConfig.proto set config for each "parameter", but only learning_rate, decay_rate and momentum values.

Copy link
Contributor

@helinwang helinwang Aug 11, 2017

Choose a reason for hiding this comment

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

I see, thanks for clarifying! Now I understand that V1 proto is not as capable as V2 proto.
Sorry for insisting on this, but I think we should not have an graph configuration API that work only for cloud training but not for local training. I am open for discussion, but I think the graph configuration API needs to be consistent: works both locally and on cloud.
Maybe when the times come that we need the capability of v2 proto (e.g., different optimizer on different parameters), we should make it work locally as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Does "graph configuration" means the V2 proto configuration python API?
  2. V2 config python API only work when using the new pserver. I think we can just remove the python API for just less confusing, and in most cases people always config a "global" optimizer algorithm for all parameters(layers), and do specific configuration for only some of the parameters.

Do you agree with removing python API only?

Copy link
Contributor

@helinwang helinwang Aug 11, 2017

Choose a reason for hiding this comment

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

Sorry by V2 proto I meant OptimizerConfig.proto, V1 proto I meant TrainerConfig.proto and ParameterConfig.proto.

  1. I meant V2 API that we released earlier this year, not the V2 parameter config (OptimizerConfig.proto) .
  2. Just for clarity, I think the V2 API work with the old parameter server as well. Yes, OptimizerConfig.proto only works for the new pserver. (Sorry too much different V2 here...)

Yes agree on removing Python API only, for less confusion.

Copy link
Contributor

@helinwang helinwang left a comment

Choose a reason for hiding this comment

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

Some minor comments, LGTM++!

parameterClient_ =
paddle_new_etcd_pserver_client((char *)pserverSpec_.c_str());
parameterClient_ = paddle_new_etcd_pserver_client(
(char *)pserverSpec_.c_str(), FLAGS_trainer_id == 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you rebase / pull with latest develop? paddle_new_etcd_pserver_client now only takes one argument.

__all__ = [
'Momentum', 'Adam', 'Adamax', 'AdaGrad', 'DecayedAdaGrad', 'AdaDelta',
'RMSProp', 'ModelAverage', 'L2Regularization'
'RMSProp', 'ModelAverage', 'L2Regularization', 'OptimizerConfig'
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the import and OptimizerConfig in this line still necessary?

@@ -27,6 +40,7 @@ def __impl__():
__impl__)
self.__opt_conf__ = swig_api.OptimizationConfig.createFromProto(
self.__opt_conf_proto__)
self.__opt_conf_new__ = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this variable still necessary?

@typhoonzero typhoonzero merged commit 886e66a into PaddlePaddle:develop Aug 11, 2017
@typhoonzero typhoonzero deleted the new_pserver_updater_proto branch August 11, 2017 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants