From bdc548680414ff2453efc997506202fa28cc1b28 Mon Sep 17 00:00:00 2001
From: Giri Anantharaman <giriman@learnfair6000.h2.fair>
Date: Wed, 3 Feb 2021 04:48:27 -0800
Subject: [PATCH] Adding initialization for `num_pipelines_per_node` (#1599)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Summary:
…hod` to avoid unbounded local error.

# Before submitting

- [ ] Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
- [ ] Did you read the [contributor guideline](https://github.com/pytorch/fairseq/blob/master/CONTRIBUTING.md)?
- [ ] Did you make sure to update the docs?
- [ ] Did you write any new necessary tests?

## What does this PR do?
Adding initialization for `num_pipelines_per_node` in `infer_init_method` in `distributed/utils.py`

## PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

## Did you have fun?
Make sure you had fun coding �

Pull Request resolved: https://github.com/fairinternal/fairseq-py/pull/1599

Reviewed By: myleott

Differential Revision: D26208044

Pulled By: girifb

fbshipit-source-id: 98d3c0b70b59a5e0abb027850baa3bc44d9c3c78
---
 fairseq/distributed/utils.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fairseq/distributed/utils.py b/fairseq/distributed/utils.py
index c39dc6d912..e3d8e1e0d3 100644
--- a/fairseq/distributed/utils.py
+++ b/fairseq/distributed/utils.py
@@ -47,6 +47,7 @@ def infer_init_method(cfg: DistributedTrainingConfig, force_distributed=False):
     if cfg.distributed_init_method is not None or cfg.tpu:
         return
 
+    num_pipelines_per_node = None
     if cfg.pipeline_model_parallel:
         num_pipeline_devices, num_pipelines_per_node = _pipeline_parallel_pre_init(cfg)