# Persisting client class attributes within a single FL round

**URL:** <https://discuss.flower.ai/t/persisting-client-class-attributes-within-a-single-fl-round/211>\
**Category:** Flower Help - Intermediate\
**Created:** [April 26, 2024, 7:47am UTC](https://discuss.flower.ai/t/persisting-client-class-attributes-within-a-single-fl-round/211 "2024-04-26T07:47:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpouzinis](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mpouzinis](https://discuss.flower.ai/u/mpouzinis)\
**Post date:** [April 26, 2024, 7:47am UTC](https://discuss.flower.ai/t/persisting-client-class-attributes-within-a-single-fl-round/211/1 "2024-04-26T07:47:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yan-gao](https://dub1.discourse-cdn.com/flex013/user_avatar/discuss.flower.ai/yan-gao/32/39_2.png) [@yan-gao](https://discuss.flower.ai/u/yan-gao)\
**Post date:** [April 30, 2024, 3:45am UTC](https://discuss.flower.ai/t/persisting-client-class-attributes-within-a-single-fl-round/211/2 "2024-04-30T03:45:51Z")

</div>

Hi @mpouzinis, the variables defined in ` __init__ ()` should be persisted within the same round (see [here](https://github.com/adap/flower/blob/main/examples/advanced-pytorch/client.py#L14), 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?

---

<div class="post-metadata">

**Author:** ![mpouzinis](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mpouzinis](https://discuss.flower.ai/u/mpouzinis)\
**Post date:** [April 30, 2024, 7:24am UTC](https://discuss.flower.ai/t/persisting-client-class-attributes-within-a-single-fl-round/211/3 "2024-04-30T07:24:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![williamlm](https://dub1.discourse-cdn.com/flex013/user_avatar/discuss.flower.ai/williamlm/32/162_2.png) [@williamlm](https://discuss.flower.ai/u/williamlm)\
**Post date:** [August 1, 2025, 3:34pm UTC](https://discuss.flower.ai/t/persisting-client-class-attributes-within-a-single-fl-round/211/4 "2025-08-01T15:34:18Z")

</div>

Hi @mpouzinis,

Thanks for your question. You can also [design stateful client applications](https://flower.ai/docs/framework/how-to-design-stateful-clients.html) which most likely solves what you’re trying to do.

Best regards,

William
