Skip to content

Commit

Permalink
update simulator to processes
Browse files Browse the repository at this point in the history
  • Loading branch information
SYangster committed Feb 1, 2024
1 parent 9239266 commit dc2ed9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/flare_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Built for productivity
FLARE is designed for maximum productivity, providing a range of tools to enhance user experience and research efficiency at different stages of the development process:

- **FLARE Client API:** Enables users to transition seamlessly from ML/DL to FL with just a few lines of code changes.
- **Simulator CLI:** Allows users to simulate federated learning or computing jobs in multi-thread settings within a single computer, offering quick response and debugging. The same job can be deployed directly to production.
- **Simulator CLI:** Allows users to simulate federated learning or computing jobs in multi-process settings within a single computer, offering quick response and debugging. The same job can be deployed directly to production.
- **POC CLI:** Facilitates the simulation of federated learning or computing jobs in multi-process settings within one computer. Different processes represent server, clients, and an admin console, providing users with a realistic sense of the federated network. It also allows users to simulate project deployment on a single host.
- **Job CLI:** Permits users to create and submit jobs directly in POC or production environments.
- **FLARE API:** Enables users to run jobs directly from Python code or notebooks.
Expand Down
32 changes: 17 additions & 15 deletions docs/user_guide/nvflare_cli/fl_simulator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Command examples
Run a single NVFlare app
========================

This command will run the same ``hello-numpy-sag`` app on the server and 8 clients using 1 thread. The client names will be site-1, site-2, ... , site-8:
This command will run the same ``hello-numpy-sag`` app on the server and 8 clients using 1 process. The client names will be site-1, site-2, ... , site-8:

.. code-block:: python
Expand Down Expand Up @@ -829,27 +829,29 @@ application run.
status = run_simulator(args)
sys.exit(status)
****************************
Threads, Clients, and Events
****************************
******************************
Processes, Clients, and Events
******************************

Specifying threads
==================
The simulator ``-t`` option provides the ability to specify how many threads to run the simulator with.
Specifying number of processes
==============================
The simulator ``-t`` option provides the ability to specify how many processes to run the simulator with.

.. note::

We use the term threads for simplicity, however technically each client actually runs in a separate process.
This difference will not affect the user experience.
The ``-t`` and ``--threads`` option for simulator was originally due to clients running in separate threads.
However each client now actually runs in a separate process. This distinction will not affect the user experience.

When you run the simulator with ``-t 1``, there is only one client active and running at a time, and the clients will be running in
turn. This is to enable the simulation of large number of clients using a single machine with limited resources.
- N = number of clients (``-n``)
- T = number of processes (``-t``)

Note that if you have fewer threads than the number of clients, ClientRunner/learner object will go thorugh setup and
teardown in every round.
When running the simulator with fewer processes than clients (T < N)
the simulator will need to swap-in/out the clients for the processes, resulting in some of the clients running sequentially as processes are available.
This also will cause the ClientRunner/learner objects to go through setup and teardown in every round.
Using T < N is only needed when trying to simulate of large number of clients using a single machine with limited resources.

With ``-t=num_client``, the simulator will run the number of clients in separate threads at the same time. Each
client will always be running in memory with no swap_in / swap_out, but it will require more resources available.
In most cases, run the simulator with the same number of processes as clients (T = N). The simulator will run the number of clients in separate processes at the same time. Each
client will always be running in memory with no swap-in/out, but it will require more resources available.

For the dataset / tensorboard initialization, you could make use of EventType.SWAP_IN and EventType.SWAP_OUT
in the application.
Expand Down

0 comments on commit dc2ed9f

Please sign in to comment.