torchnative
Guide가이드

Federated learning연합학습

Devices train locally and share updates, not data. Federated averaging is collective communication, so it is built on torch.distributed rather than beside it.

기기는 로컬에서 학습하고 데이터가 아니라 업데이트를 공유합니다. 연합 평균은 곧 집합 통신이므로 torch.distributed 옆이 아니라 그 위에 지었습니다.

One round한 라운드

import torch.distributed as dist
from torchnative import adapt
from torchnative.nn import federated

dist.init_process_group(backend="local", init_method="tcp://127.0.0.1:29500",
                        rank=rank, world_size=world)
engine = federated.Engine(model, method=adapt.Tent(), aggregator=federated.FedAvg())
report = engine.participate(batches, weight=n_local_samples)   # local steps, then a delta

Each rank adapts locally, contributes its delta, and comes back holding the group's weighted average. The acceptance check is equality with the same average computed centrally on upstream torch, torch.equal, not a tolerance.

각 랭크는 로컬에서 적응하고 델타를 내고, 그룹의 가중 평균을 들고 돌아옵니다. 판정 기준은 upstream torch 로 중앙에서 계산한 같은 평균과의 동일성 (허용오차가 아니라 torch.equal) 입니다.

What it refuses거부하는 것

A world of one is refused at every door, because averaging one delta is the identity and would pass any test. Secure aggregation, differential privacy and point-to-point send/recv refuse by name. A rank that does not arrive makes the round raise; it never produces a partial average silently.

월드 크기 1 은 모든 입구에서 거부됩니다. 델타 하나의 평균은 항등이라 어떤 테스트든 통과하기 때문입니다. 보안 집계, 차분 프라이버시, 점대점 send/recv 는 이름으로 거부됩니다. 도착하지 않은 랭크가 있으면 라운드가 예외를 내며, 조용히 부분 평균을 내지 않습니다.