GithubHelp home page GithubHelp logo

Configuring individual clients about flower HOT 3 OPEN

gioperin avatar gioperin commented on June 11, 2024
Configuring individual clients

from flower.

Comments (3)

gioperin avatar gioperin commented on June 11, 2024 1

Hi @jafermarq please note that the documentation is highly misleading because the title of that section is "configuring individual clients" and the example does not achieve what the title suggests. The workaround you cited is the one I am using right now. I want to point out that this procedure is extremely inefficient because it implies copying N times all the fields inside FitIns, among which there are the parameters, ending up in poor memory usage. Don't you think it would be a good idea to use another dictionary other than FitIns to pass configuration parameters so that we don't need to copy the model parameters?

Thank you for your reply!

from flower.

danielphan2003 avatar danielphan2003 commented on June 11, 2024 1

This can be achieved by customizing an existing strategy or by implementing a custom strategy from scratch. Here’s a nonsensical example that customizes FedAvg by adding a custom "hello": "world" configuration key/value pair to the config dict of a single client (only the first client in the list, the other clients in this round to not receive this “special” config value):

# Add special "hello": "world" config key/value pair,
# but only to the first client in the list
_, fit_ins = client_instructions[0]  # First (ClientProxy, FitIns) pair
fit_ins.config["hello"] = "world"  # Change config for this client only

I think the code needs to be updated so that it is in fact only the first client receives {"hello": "world"}, such as:

_, fit_ins = client_instructions[0]
fit_ins = FitIns(parameters=fit_ins.parameters, fit_ins.config | {"hello": "world"})

Is this a Pythonic behavior or somewhere else in the codebase would have required such workarounds in the first place?

EDIT: I was wrong, using copy would solve the problem but would result in poor memory usage as well:

client_instructions = [(client, copy(fit_ins)) for client, fit_ins in client_instructions]
_, fit_ins = client_instructions[0]
fit_ins.config = fit_ins.config | {"hello": "world"})

from flower.

jafermarq avatar jafermarq commented on June 11, 2024

Hey @gioperin, that part of the documentation indicates (as you point out) how to configure clients, but not individually. You can still achieve what you want by implementing a custom strategy and overriding the configure_fit() method and assign a different FitIns object to each client that has been sampled.

from flower.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.