Hey @ph0123
I was referring to Python global vars, sth like:
import torch
import torch.distributed.rpc as rpc
import torch.multiprocessing as mp
import os


_local_dict = {}


def intersect_dict(dict1):
    ret = {}
    for key in _local_dict:
        if key in dict1:
            ret[key] = dict1[key]

    return ret


def run(dst):
    intersect = rpc.rpc_sync(dst, intersect_dict, args=(_local_dict,))
    print(intersect)


def run_worker(rank, world_size):
    os.environ['MASTER_ADDR'] = '127.0.0.1'
    os.environ['MASTER_PORT'] = '29500'
    if rank == 0:
        _local_dict.update({1:'a', 3:'c', 4:'d'})
        rpc.init_rpc("worker0", rank=rank, world_size=world_size)
        run("worker1")
    else:
        _local_dict.update({1:'a', 2:'b', 3:'c'})
        rpc.init_rpc("worker1", rank=rank, world_size=world_size)

    rpc.shutdown()


if __name__=="__main__":
    world_size = 2
    mp.spawn(run_worker, args=(world_size, ), nprocs=world_size, join=True)