Persisting client class attributes within a single FL round

I understand that in FLower simulation, VCE does not perists client states across different rounds. Nonetheless, I’ve come across a scenario where I initialize a client attribute within the respective class using __init__(), but it doesn’t persist when I use fit() and evaluate() within a single round. Is it possible that when fit() or evaluate() is called, the client gets re-initialized? To be more precise, changes of the considered attribute applied in fit(), do not persist in evalaute() in the same round, and vice-versa.

2 Likes

Hi @mpouzinis, the variables defined in __init__() should be persisted within the same round (see here, e.g., self.device or self.model persists and can be called in fit() and evaluate()). Could you provide more context or code regarding the issues you encountered?

1 Like

Thank you for your reply! As a minimal example, suppose that the variable self.var is intialized in __init()__. If I modify self.var through fit(), this change will not persist in evaluate(), and vice-versa. Intuitively, I would anticipate that at least one of the following cases should hold: Change of self.var via evaluate() or fit() should persist on fit() or evaluate(), correspondingly. However, this is not evident based on my experimentation.

Moreover, after a careful look in the documentation, the argument client_fn of the function start_simulation, mentions: “Note that the created client instances are ephemeral and will often be destroyed after a single method invocation. Since client instances are not long-lived, they should not attempt to carry state over method invocations”. This statement may answer my question.

1 Like