Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable automatic eviction of diskcache at aggregation #419

Merged
merged 1 commit into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def _aggregate_weights(self, tag: str) -> None:
tres = TrainResult(weights, count, version)
# save training result from trainer in a disk cache
self.cache[end] = tres
logger.debug(f"received {len(self.cache)} trainer updates in cache")

self._agg_goal_weights = self.optimizer.do(
self._agg_goal_weights, self.cache, total=count, version=self._round
Expand Down
1 change: 1 addition & 0 deletions lib/python/flame/mode/horizontal/asyncfl/top_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def _aggregate_weights(self, tag: str) -> None:
tres = TrainResult(weights, count, version)
# save training result from trainer in a disk cache
self.cache[end] = tres
logger.debug(f"received {len(self.cache)} trainer updates in cache")

self._agg_goal_weights = self.optimizer.do(
self._agg_goal_weights, self.cache, total=count, version=self._round
Expand Down
2 changes: 2 additions & 0 deletions lib/python/flame/mode/horizontal/feddyn/top_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def _aggregate_weights(self, tag: str) -> None:
# save training result from trainer in a disk cache
self.cache[end] = tres

logger.debug(f"received {len(self.cache)} trainer updates in cache")

# optimizer conducts optimization (in this case, aggregation)
global_weights = self.optimizer.do(
deepcopy(self.cld_weights),
Expand Down
2 changes: 2 additions & 0 deletions lib/python/flame/mode/horizontal/oort/top_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def _aggregate_weights(self, tag: str) -> None:
if received_end_count == aggr_num:
break

logger.debug(f"received {len(self.cache)} trainer updates in cache")

# optimizer conducts optimization (in this case, aggregation)
global_weights = self.optimizer.do(
deepcopy(self.weights), self.cache, total=total
Expand Down
7 changes: 7 additions & 0 deletions lib/python/flame/mode/horizontal/syncfl/middle_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ def internal_init(self) -> None:
self._round = 1
self._work_done = False

# disk cache is used for saving memory in case model is large
# automatic eviction of disk cache is disabled with cull_limit 0
self.cache = Cache()
self.cache.reset("size_limit", 1e15)
self.cache.reset("cull_limit", 0)

self.dataset_size = 0

# save distribute tag in an instance variable
Expand Down Expand Up @@ -182,6 +187,8 @@ def _aggregate_weights(self, tag: str) -> None:
# save training result from trainer in a disk cache
self.cache[end] = tres

logger.debug(f"received {len(self.cache)} trainer updates in cache")

# optimizer conducts optimization (in this case, aggregation)
global_weights = self.optimizer.do(
deepcopy(self.weights), self.cache, total=total
Expand Down
6 changes: 6 additions & 0 deletions lib/python/flame/mode/horizontal/syncfl/top_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ def internal_init(self) -> None:
self.metrics = dict()

# disk cache is used for saving memory in case model is large
# automatic eviction of disk cache is disabled with cull_limit 0
self.cache = Cache()
self.cache.reset('size_limit', 1e15)
self.cache.reset('cull_limit', 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the only place we have to change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. Applied changes to where it should be.


self.optimizer = optimizer_provider.get(
self.config.optimizer.sort, **self.config.optimizer.kwargs
)
Expand Down Expand Up @@ -157,6 +161,8 @@ def _aggregate_weights(self, tag: str) -> None:
# save training result from trainer in a disk cache
self.cache[end] = tres

logger.debug(f"received {len(self.cache)} trainer updates in cache")

# optimizer conducts optimization (in this case, aggregation)
global_weights = self.optimizer.do(
deepcopy(self.weights),
Expand Down