-
Notifications
You must be signed in to change notification settings - Fork 0
Update private attributes for ray backend #21
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
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: Ishant Thakare <ishantrog752@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds state synchronization for aggregator and collaborators when using the Ray backend.
- Stores references to aggregator and collaborator objects for later state syncing
- Introduces
get_stateon participants to retrieve internal state - Implements
_sync_participants_stateand invokes it after aggregation tasks in Ray mode
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| openfl/experimental/workflow/runtime/local_runtime.py | Store object references, add state sync method, call it in execute_task |
| openfl/experimental/workflow/interface/participants.py | Add get_state method returning participant’s __dict__ |
Comments suppressed due to low confidence (4)
openfl/experimental/workflow/runtime/local_runtime.py:401
- [nitpick] Using double underscores leads to name mangling and may complicate access in subclasses. Consider using a single leading underscore (e.g.,
_aggregator_reference) for a private attribute.
self.__aggregator_reference = aggregator
openfl/experimental/workflow/runtime/local_runtime.py:492
- The
ray_group_assigncall is no longer guarded by abackend == "ray"check, so it will run for any backend other than single_process. Reintroduce a conditional to restrict Ray-specific code to the Ray backend.
collaborator_ray_refs = ray_group_assign(collaborators, num_actors=self.num_actors)
openfl/experimental/workflow/runtime/local_runtime.py:676
- [nitpick] The new
_sync_participants_statelogic isn't covered by existing tests. Add unit tests to verify that aggregator and collaborator states are correctly synchronized when using the Ray backend.
if self.backend == "ray":
openfl/experimental/workflow/runtime/local_runtime.py:549
- In
_sync_participants_state,self._aggregatoris undefined and will raise an AttributeError. It should referenceself.__aggregator_referenceinstead ofself._aggregator.
self.__aggregator_reference.__dict__.update(ray.get(self._aggregator.get_state.remote()))
| Returns: | ||
| Dict[str, Any]: The state of the participant. | ||
| """ | ||
| return self.__dict__ |
Copilot
AI
May 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Returning __dict__ exposes all internal attributes, including private ones. Consider returning only the necessary state fields to avoid leaking internal implementation details.
| return self.__dict__ | |
| return { | |
| "private_attributes": self.private_attributes, | |
| "name": self._name | |
| } |
Signed-off-by: Ishant Thakare <ishantrog752@gmail.com>
SummaryWorkflow API allows for the specification of private attributes for participants in a Federation. These private attributes represent confidential information that should not be shared with other participants. Currently, in LocalRuntime, private attributes of participants can be updated within the flow. This is possible because they are updated from the Users could potentially develop functionality that allows them to save intermediate results or artifacts into these private attributes and access them via the participant object at the end of the experiment. An example of this functionality is as follows: Add simple example While this approach works for backend="single_process", it does not work for backend="ray". This PR introduces functionality to update the state for Type of Change (Mandatory)Specify the type of change being made.
Description (Mandatory)In LocalRuntime with the Ray backend, the To update the local participant state, the following changes are implemented for the
Testing
Topics for Discussion
|
Summary
Workflow API allows for the specification of private attributes for participants in a Federation. These private attributes represent confidential information that should not be shared with other participants.
Currently, in LocalRuntime, private attributes of participants can be updated within the
flow. This is possible because they are updated from theFLSpecclones back into the participant object before being removed from the clone (ref).This introduces the possibility for users to implement mechanisms that persist intermediate results or artifacts within private attributes, which can subsequently be retrieved via the participant object upon experiment completion. For example:
Although this approach is effective when using the
single_processbackend, it does not behave as expected under theraybackend.This PR introduces functionality to update the state for
AggregatorandCollaboratorusing theraybackend inLocalRuntime, ensuring consistent behavior with thesingle_processbackend.Use cases:
if current_round_recall < 0.6: self.train_loader = build_oversampled_loader(local_dataset)self.train_loader = filter_out_noisy_samples(self.train_loader)Type of Change (Mandatory)
Specify the type of change being made.
Description (Mandatory)
In LocalRuntime with the Ray backend, the
AggregatorandCollaboratoroperate as remote actors. After the experiment concludes, while theFLSpecstate is updated ([reference]), the internal states of these remote actors are not synchronized with their corresponding objects.To update the local participant state, the following changes are implemented for the
raybackend:LocalRuntime.Participantclass to implement aget_state()method.get_state()on remote actors and update references.Testing
Topics for Discussion
Workflow API is designed to enable users to retrieve experiment results (trained model, metrics, and other artifacts) via the FLSpec. The ability for users to modify the state of private attributes and fetch it exposes a new interface for accessing the internal participant state. Should this behavior be considered acceptable and supported? Could be helpful to align on this.
The private attributes of Participants are properties of the Aggregator and Collaborator. Allowing the flow (developed by the user/data scientist) to modify these attributes could pose a security risk. Since
LocalRuntimeis a simulation with no real participants, this behavior could still be acceptableHowever, in
FederatedRuntime, these private attributes are strictly inaccessible to the user-defined flow by design, in order to preserve data privacy and maintain system integrity.Supporting this feature only in
LocalRuntimewould create a discrepancy between the simulation and production environments. If this behavior is retained, it should be clearly documented to avoid confusion and misaligned expectations.