alibaba / alibaba/FederatedScope
Issue in _calculate_model_delta() in federatedscope/core/workers /client.py
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 261
- PR merge metrics
- No merged PRs in 30d
Description
The `_calculate_model_delta()` may need to be modified to the code below to satisfy running pFL, since the `updated_model` is a subset of the `init_model`:
```
def _calculate_model_delta(self, init_model, updated_model):
if not isinstance(init_model, list):
init_model = [init_model]
updated_model = [updated_model]
model_deltas = list()
for model_index in range(len(init_model)):
# model_delta = copy.deepcopy(init_model[model_index])
# for key in init_model[model_index].keys():
# model_delta[key] = updated_model[model_index][
# key] - init_model[model_index][key]
# added by me, for pFL
model_delta = copy.deepcopy(updated_model[model_index])
for key in updated_model[model_index].keys():
model_delta[key] = updated_model[model_index][
key] - init_model[model_index][key]
model_deltas.append(model_delta)
if len(model_deltas) > 1:
return model_deltas
else:
return model_deltas[0]
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in federatedscope/core/workers/client.py at _calculate_model_delta() and review how init_model and updated_model are normalized and iterated. Verify the behavior against the pFL scenario described in the issue, including subset models, and confirm that the resulting deltas match the updated model keys without breaking the existing return shape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems, machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100