flwr-nightly 1.10.0.dev20240717__py3-none-any.whl → 1.10.0.dev20240719__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,11 @@ class FlowerClient(NumPyClient):
30
30
 
31
31
  def fit(self, parameters, config):
32
32
  self.set_parameters(parameters)
33
- train(self.net, self.trainloader, epochs=1)
33
+ train(
34
+ self.net,
35
+ self.trainloader,
36
+ epochs=int(self.context.run_config["local-epochs"]),
37
+ )
34
38
  return self.get_parameters(config={}), len(self.trainloader), {}
35
39
 
36
40
  def evaluate(self, parameters, config):
@@ -45,8 +49,8 @@ def client_fn(context: Context):
45
49
  CHECKPOINT, num_labels=2
46
50
  ).to(DEVICE)
47
51
 
48
- partition_id = int(context.node_config['partition-id'])
49
- num_partitions = int(context.node_config['num-partitions])
52
+ partition_id = int(context.node_config["partition-id"])
53
+ num_partitions = int(context.node_config["num-partitions"])
50
54
  trainloader, valloader = load_data(partition_id, num_partitions)
51
55
 
52
56
  # Return Client instance
@@ -20,17 +20,19 @@ from $import_name.task import (
20
20
  # Define Flower Client and client_fn
21
21
  class FlowerClient(NumPyClient):
22
22
  def __init__(self, data):
23
- num_layers = 2
24
- hidden_dim = 32
23
+ num_layers = int(self.context.run_config["num-layers"])
24
+ hidden_dim = int(self.context.run_config["hidden-dim"])
25
25
  num_classes = 10
26
- batch_size = 256
27
- num_epochs = 1
28
- learning_rate = 1e-1
26
+ batch_size = int(self.context.run_config["batch-size"])
27
+ learning_rate = float(self.context.run_config["lr"])
28
+ num_epochs = int(self.context.run_config["local-epochs"])
29
29
 
30
30
  self.train_images, self.train_labels, self.test_images, self.test_labels = data
31
- self.model = MLP(num_layers, self.train_images.shape[-1], hidden_dim, num_classes)
32
- self.optimizer = optim.SGD(learning_rate=learning_rate)
33
- self.loss_and_grad_fn = nn.value_and_grad(self.model, loss_fn)
31
+ self.model = MLP(
32
+ num_layers, self.train_images.shape[-1], hidden_dim, num_classes
33
+ )
34
+ self.optimizer = optim.SGD(learning_rate=learning_rate)
35
+ self.loss_and_grad_fn = nn.value_and_grad(self.model, loss_fn)
34
36
  self.num_epochs = num_epochs
35
37
  self.batch_size = batch_size
36
38
 
@@ -23,7 +23,13 @@ class FlowerClient(NumPyClient):
23
23
 
24
24
  def fit(self, parameters, config):
25
25
  set_weights(self.net, parameters)
26
- results = train(self.net, self.trainloader, self.valloader, 1, DEVICE)
26
+ results = train(
27
+ self.net,
28
+ self.trainloader,
29
+ self.valloader,
30
+ int(self.context.run_config["local-epochs"]),
31
+ DEVICE,
32
+ )
27
33
  return get_weights(self.net), len(self.trainloader.dataset), results
28
34
 
29
35
  def evaluate(self, parameters, config):
@@ -67,10 +67,11 @@ class FlowerClient(NumPyClient):
67
67
 
68
68
  return loss, len(self.X_test), {"accuracy": accuracy}
69
69
 
70
- fds = FederatedDataset(dataset="mnist", partitioners={"train": 2})
71
70
 
72
71
  def client_fn(context: Context):
73
72
  partition_id = int(context.node_config["partition-id"])
73
+ num_partitions = int(context.node_config["num-partitions"])
74
+ fds = FederatedDataset(dataset="mnist", partitioners={"train": num_partitions})
74
75
  dataset = fds.load_partition(partition_id, "train").with_format("numpy")
75
76
 
76
77
  X, y = dataset["image"].reshape((len(dataset), -1)), dataset["label"]
@@ -20,7 +20,13 @@ class FlowerClient(NumPyClient):
20
20
 
21
21
  def fit(self, parameters, config):
22
22
  self.model.set_weights(parameters)
23
- self.model.fit(self.x_train, self.y_train, epochs=1, batch_size=32, verbose=0)
23
+ self.model.fit(
24
+ self.x_train,
25
+ self.y_train,
26
+ epochs=int(self.context.run_config["local-epochs"]),
27
+ batch_size=int(self.context.run_config["batch-size"]),
28
+ verbose=bool(self.context.run_config.get("verbose")),
29
+ )
24
30
  return self.model.get_weights(), len(self.x_train), {}
25
31
 
26
32
  def evaluate(self, parameters, config):
@@ -34,7 +40,8 @@ def client_fn(context: Context):
34
40
  net = load_model()
35
41
 
36
42
  partition_id = int(context.node_config["partition-id"])
37
- x_train, y_train, x_test, y_test = load_data(partition_id, 2)
43
+ num_partitions = int(context.node_config["num-partitions"])
44
+ x_train, y_train, x_test, y_test = load_data(partition_id, num_partitions)
38
45
 
39
46
  # Return Client instance
40
47
  return FlowerClient(net, x_train, y_train, x_test, y_test).to_client()
@@ -29,6 +29,7 @@ clientapp = "$import_name.client_app:app"
29
29
 
30
30
  [tool.flwr.app.config]
31
31
  num-server-rounds = "3"
32
+ local-epochs = "1"
32
33
 
33
34
  [tool.flwr.federations]
34
35
  default = "localhost"
@@ -26,6 +26,11 @@ clientapp = "$import_name.client_app:app"
26
26
 
27
27
  [tool.flwr.app.config]
28
28
  num-server-rounds = "3"
29
+ local-epochs = "1"
30
+ num-layers = "2"
31
+ hidden-dim = "32"
32
+ batch-size = "256"
33
+ lr = "0.1"
29
34
 
30
35
  [tool.flwr.federations]
31
36
  default = "localhost"
@@ -26,6 +26,7 @@ clientapp = "$import_name.client_app:app"
26
26
 
27
27
  [tool.flwr.app.config]
28
28
  num-server-rounds = "3"
29
+ local-epochs = "1"
29
30
 
30
31
  [tool.flwr.federations]
31
32
  default = "localhost"
@@ -25,6 +25,9 @@ clientapp = "$import_name.client_app:app"
25
25
 
26
26
  [tool.flwr.app.config]
27
27
  num-server-rounds = "3"
28
+ local-epochs = "1"
29
+ batch-size = "32"
30
+ verbose = "" # Empty string means False
28
31
 
29
32
  [tool.flwr.federations]
30
33
  default = "localhost"
flwr/cli/run/run.py CHANGED
@@ -199,7 +199,7 @@ def _run_without_superexec(
199
199
  ]
200
200
 
201
201
  if config_overrides:
202
- command.extend(["--run-config", f"{config_overrides}"])
202
+ command.extend(["--run-config", f"{','.join(config_overrides)}"])
203
203
 
204
204
  # Run the simulation
205
205
  subprocess.run(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flwr-nightly
3
- Version: 1.10.0.dev20240717
3
+ Version: 1.10.0.dev20240719
4
4
  Summary: Flower: A Friendly Federated Learning Framework
5
5
  Home-page: https://flower.ai
6
6
  License: Apache-2.0
@@ -14,13 +14,13 @@ flwr/cli/new/templates/app/README.md.tpl,sha256=_qGtgpKYKoCJVjQnvlBMKvFs_1gzTcL9
14
14
  flwr/cli/new/templates/app/__init__.py,sha256=DU7QMY7IhMQyuwm_tja66xU0KXTWQFqzfTqwg-_NJdE,729
15
15
  flwr/cli/new/templates/app/code/__init__.py,sha256=EM6vfvgAILKPaPn7H1wMV1Wi01WyZCP_Eg6NxD6oWg8,736
16
16
  flwr/cli/new/templates/app/code/__init__.py.tpl,sha256=olwrBeJemHNBWvjc6gJURloFRqW40dAy7FRQA5pDqHU,21
17
- flwr/cli/new/templates/app/code/client.hf.py.tpl,sha256=cqq2M-l8yrsw6kZZLIjum2g-0uKg4Pyh3YGhgpQKQrw,1636
17
+ flwr/cli/new/templates/app/code/client.hf.py.tpl,sha256=_x-V6EcSgX2nPo-0ODHaKFgt9n_aONNrWpkbQPrTxE0,1727
18
18
  flwr/cli/new/templates/app/code/client.jax.py.tpl,sha256=i_SZykD42vqEvv2ZyX655szuikXJXLc6uV1T-LWiYLU,1479
19
- flwr/cli/new/templates/app/code/client.mlx.py.tpl,sha256=Ntpbz9fcw-87FPBZmhns1NbJJXOQxnssJ_lStAqGuaQ,2299
19
+ flwr/cli/new/templates/app/code/client.mlx.py.tpl,sha256=rrRXIU-jrx4FuzbMjqlMCrWi9ctEmtI9UCwol-U0oPg,2513
20
20
  flwr/cli/new/templates/app/code/client.numpy.py.tpl,sha256=ov9mtWJGjaQ9ZVlQ5jsuCjHDeETf13GFla5jbP3KimE,561
21
- flwr/cli/new/templates/app/code/client.pytorch.py.tpl,sha256=bmmplNEVk3uHERFGlDP6FmBJQ7IBFw-OQ8otueAmOX0,1358
22
- flwr/cli/new/templates/app/code/client.sklearn.py.tpl,sha256=C2PfCn0w8MpXmY4tuIIJ7fF2Mv-YW37YmMf0knIEARo,2905
23
- flwr/cli/new/templates/app/code/client.tensorflow.py.tpl,sha256=D8h_RSWk2GGazW2-fLle1dIz9ABWuC_1aczxNbKHfOA,1390
21
+ flwr/cli/new/templates/app/code/client.pytorch.py.tpl,sha256=CJXi89YbOEirevOSy-VmfCpN59vV5Q3iM2TwCTgWkGc,1472
22
+ flwr/cli/new/templates/app/code/client.sklearn.py.tpl,sha256=44NQwBGHT1hTunUXQIvmv1EWDvKLw4Z40J1QnFRqIao,2986
23
+ flwr/cli/new/templates/app/code/client.tensorflow.py.tpl,sha256=Rb0St2Hp-ftQyYR_Ao6okT8lkiQto76M66fp_y3Etgo,1664
24
24
  flwr/cli/new/templates/app/code/flwr_tune/__init__.py,sha256=JgNgBtKdm1jKM9625WxappCAVUGtYAmcjKSsXJ1u3ZQ,748
25
25
  flwr/cli/new/templates/app/code/flwr_tune/app.py.tpl,sha256=p5ImtKbFXw3x64n9xehvMwqXUmjLcwYfUPvRqKK2owU,2655
26
26
  flwr/cli/new/templates/app/code/flwr_tune/client.py.tpl,sha256=MvQ5tt1r7CBUR8y-nBcZs4as2m1YimxegLYw_nHmXzc,4048
@@ -42,15 +42,15 @@ flwr/cli/new/templates/app/code/task.mlx.py.tpl,sha256=nrfZ1aGOs_ayb70j7XdAmwFYa
42
42
  flwr/cli/new/templates/app/code/task.pytorch.py.tpl,sha256=TU4uNtJ9wtxeVvoHD3_K89EFWmrIvdECdASzRX-4Uvk,3694
43
43
  flwr/cli/new/templates/app/code/task.tensorflow.py.tpl,sha256=cPOUUS07QbblT9PGFucwu9lY1clRA4-W4DQGA7cpcao,1044
44
44
  flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl,sha256=XBcU_XPYt7GecNjeBmD915fZGsF189QMb_IzFl4ATTA,777
45
- flwr/cli/new/templates/app/pyproject.hf.toml.tpl,sha256=zat9eXJG3mm2IucKVw7rqyM9ErvzG22zmAndlNx728E,757
45
+ flwr/cli/new/templates/app/pyproject.hf.toml.tpl,sha256=kU2cAmlxC_DuJXU6zbNcXy2RmyjEsNTjyXDyeeHClnY,776
46
46
  flwr/cli/new/templates/app/pyproject.jax.toml.tpl,sha256=njY9toiCCaKCM2yqPsAytlD-jgWF3-aUQmg3vBjbTi0,651
47
- flwr/cli/new/templates/app/pyproject.mlx.toml.tpl,sha256=Ux-C7IC6-4F8TYVfzaXpium8YhEN8WDxpV0U9PaSZ5g,666
47
+ flwr/cli/new/templates/app/pyproject.mlx.toml.tpl,sha256=ztZC5kQhjzVUUnvlfhOPebn1dx9QJOHRP4JARuZ_5EQ,750
48
48
  flwr/cli/new/templates/app/pyproject.numpy.toml.tpl,sha256=5KiJUl6gm7rmW4xIBgF5qK5s2YMnMkouHBdOHuWUmcw,604
49
- flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl,sha256=BO-dnjEahswyGQZ1ZJaQpCP2-URK1M63bfsw8rtwirE,673
49
+ flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl,sha256=Ur0D2S98AnoiVcy_pTQnxSuLssioQe6yzGWQ1rLkTU8,692
50
50
  flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl,sha256=lOi7R32xbO6MF5_BF6-bUbjWoC_z3XtJhRj1REHmL5w,653
51
- flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl,sha256=tvccRauwP6kZP7RFreeoOl41A5W8cpEH1Fis4LImkGw,652
51
+ flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl,sha256=svb0YkuTACGh_PWn_tbiH8T05xrnn0MyVEnuQsQH4h0,730
52
52
  flwr/cli/run/__init__.py,sha256=oCd6HmQDx-sqver1gecgx-uMA38BLTSiiKpl7RGNceg,789
53
- flwr/cli/run/run.py,sha256=34A6GVhK7wXWiKAG6VObAFkZM-zZmYnlNPe1QQUBY5c,6973
53
+ flwr/cli/run/run.py,sha256=DnABj0eJMNj_05nxzP8CCodocHe-EmDlAZhylGceauY,6983
54
54
  flwr/cli/utils.py,sha256=l65Ul0YsSBPuypk0uorAtEDmLEYiUrzpCXi6zCg9mJ4,4506
55
55
  flwr/client/__init__.py,sha256=wzJZsYJIHf_8-PMzvfbinyzzjgh1UP1vLrAw2_yEbKI,1345
56
56
  flwr/client/app.py,sha256=jobLLjUGV3pkSYpd2wGyzG8e1KZPk2_O47IjTsXnk6Y,26106
@@ -270,8 +270,8 @@ flwr/superexec/exec_grpc.py,sha256=vYbZyV89MuvYDH1XzVYHkKmGfOcU6FWh8rTcIJk2TIQ,1
270
270
  flwr/superexec/exec_servicer.py,sha256=4R1f_9v0vly_bXpIYaXAeV1tO5LAy1AYygGGGNZmlQk,2194
271
271
  flwr/superexec/executor.py,sha256=5ua0AU2cfisyD79dosP-POF3w0FRH2I5Wko_PPKLWqU,2153
272
272
  flwr/superexec/simulation.py,sha256=yOykF9zqFwHwkEN5gKHf7dMYdc1BVOysKpFPwlXIoOY,4663
273
- flwr_nightly-1.10.0.dev20240717.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
274
- flwr_nightly-1.10.0.dev20240717.dist-info/METADATA,sha256=6h_872LVH21poiM0K85aNZeaqZsktXuV4IIeBG0Asvo,15672
275
- flwr_nightly-1.10.0.dev20240717.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
276
- flwr_nightly-1.10.0.dev20240717.dist-info/entry_points.txt,sha256=7qBQcA-bDGDxnJmLd9FYqglFQubjCNqyg9M8a-lukps,336
277
- flwr_nightly-1.10.0.dev20240717.dist-info/RECORD,,
273
+ flwr_nightly-1.10.0.dev20240719.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
274
+ flwr_nightly-1.10.0.dev20240719.dist-info/METADATA,sha256=uUxTicfl_cj9_CQEFdvVvyjl06EphWU1db1jvN8cO48,15672
275
+ flwr_nightly-1.10.0.dev20240719.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
276
+ flwr_nightly-1.10.0.dev20240719.dist-info/entry_points.txt,sha256=7qBQcA-bDGDxnJmLd9FYqglFQubjCNqyg9M8a-lukps,336
277
+ flwr_nightly-1.10.0.dev20240719.dist-info/RECORD,,