initialize.rst 1.2 KB
Newer Older
Jeff Rasley's avatar
Jeff Rasley committed
1
2
Training Setup
==============
3

Jeff Rasley's avatar
Jeff Rasley committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
.. _deepspeed-args:

Argument Parsing
----------------
DeepSpeed uses the `argparse <https://docs.python.org/3/library/argparse.html>`_ library to
supply commandline configuration to the DeepSpeed runtime. Use ``deepspeed.add_config_arguments()``
to add DeepSpeed's builtin arguments to your application's parser.

.. code-block:: python

    parser = argparse.ArgumentParser(description='My training script.')
    parser.add_argument('--local_rank', type=int, default=-1,
                        help='local rank passed from distributed launcher')
    # Include DeepSpeed configuration arguments
    parser = deepspeed.add_config_arguments(parser)
    cmd_args = parser.parse_args()

.. autofunction:: deepspeed.add_config_arguments


.. _deepspeed-init:

Training Initialization
-----------------------
28
29
30
31
32
33
34
35
36
37
38
The entrypoint for all training with DeepSpeed is ``deepspeed.initialize()``.

Example usage:

.. code-block:: python

    model_engine, optimizer, _, _ = deepspeed.initialize(args=cmd_args,
                                                         model=net,
                                                         model_parameters=net.parameters())

.. autofunction:: deepspeed.initialize