flwr-nightly 1.11.0.dev20240826__py3-none-any.whl → 1.11.0.dev20240828__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.

Potentially problematic release.


This version of flwr-nightly might be problematic. Click here for more details.

Files changed (30) hide show
  1. flwr/cli/new/new.py +24 -9
  2. flwr/cli/new/templates/app/LICENSE.tpl +202 -0
  3. flwr/cli/new/templates/app/README.baseline.md.tpl +127 -0
  4. flwr/cli/new/templates/app/README.flowertune.md.tpl +16 -6
  5. flwr/cli/new/templates/app/code/__init__.baseline.py.tpl +1 -0
  6. flwr/cli/new/templates/app/code/client.baseline.py.tpl +58 -0
  7. flwr/cli/new/templates/app/code/dataset.baseline.py.tpl +36 -0
  8. flwr/cli/new/templates/app/code/flwr_tune/{client.py.tpl → client_app.py.tpl} +50 -40
  9. flwr/cli/new/templates/app/code/flwr_tune/dataset.py.tpl +32 -2
  10. flwr/cli/new/templates/app/code/flwr_tune/models.py.tpl +0 -3
  11. flwr/cli/new/templates/app/code/flwr_tune/server_app.py.tpl +95 -0
  12. flwr/cli/new/templates/app/code/flwr_tune/strategy.py.tpl +83 -0
  13. flwr/cli/new/templates/app/code/model.baseline.py.tpl +80 -0
  14. flwr/cli/new/templates/app/code/server.baseline.py.tpl +46 -0
  15. flwr/cli/new/templates/app/code/strategy.baseline.py.tpl +1 -0
  16. flwr/cli/new/templates/app/code/utils.baseline.py.tpl +1 -0
  17. flwr/cli/new/templates/app/pyproject.baseline.toml.tpl +138 -0
  18. flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl +34 -7
  19. flwr/cli/run/run.py +2 -2
  20. flwr/client/supernode/app.py +3 -1
  21. flwr/common/config.py +14 -11
  22. {flwr_nightly-1.11.0.dev20240826.dist-info → flwr_nightly-1.11.0.dev20240828.dist-info}/METADATA +2 -2
  23. {flwr_nightly-1.11.0.dev20240826.dist-info → flwr_nightly-1.11.0.dev20240828.dist-info}/RECORD +26 -18
  24. flwr/cli/new/templates/app/code/flwr_tune/app.py.tpl +0 -89
  25. flwr/cli/new/templates/app/code/flwr_tune/config.yaml.tpl +0 -34
  26. flwr/cli/new/templates/app/code/flwr_tune/server.py.tpl +0 -48
  27. flwr/cli/new/templates/app/code/flwr_tune/static_config.yaml.tpl +0 -11
  28. {flwr_nightly-1.11.0.dev20240826.dist-info → flwr_nightly-1.11.0.dev20240828.dist-info}/LICENSE +0 -0
  29. {flwr_nightly-1.11.0.dev20240826.dist-info → flwr_nightly-1.11.0.dev20240828.dist-info}/WHEEL +0 -0
  30. {flwr_nightly-1.11.0.dev20240826.dist-info → flwr_nightly-1.11.0.dev20240828.dist-info}/entry_points.txt +0 -0
@@ -8,15 +8,15 @@ version = "1.0.0"
8
8
  description = ""
9
9
  license = "Apache-2.0"
10
10
  dependencies = [
11
- "flwr[simulation]>=1.9.0,<2.0",
12
- "flwr-datasets>=0.1.0,<1.0.0",
13
- "hydra-core==1.3.2",
11
+ "flwr[simulation]>=1.10.0",
12
+ "flwr-datasets>=0.3.0",
14
13
  "trl==0.8.1",
15
14
  "bitsandbytes==0.43.0",
16
15
  "scipy==1.13.0",
17
16
  "peft==0.6.2",
18
17
  "transformers==4.39.3",
19
18
  "sentencepiece==0.2.0",
19
+ "omegaconf==2.3.0",
20
20
  ]
21
21
 
22
22
  [tool.hatch.build.targets.wheel]
@@ -26,14 +26,41 @@ packages = ["."]
26
26
  publisher = "$username"
27
27
 
28
28
  [tool.flwr.app.components]
29
- serverapp = "$import_name.app:server"
30
- clientapp = "$import_name.app:client"
29
+ serverapp = "$import_name.server_app:app"
30
+ clientapp = "$import_name.client_app:app"
31
31
 
32
32
  [tool.flwr.app.config]
33
- num-server-rounds = 3
33
+ model.name = "mistralai/Mistral-7B-v0.3"
34
+ model.quantization = 4
35
+ model.gradient-checkpointing = true
36
+ model.lora.peft-lora-r = 32
37
+ model.lora.peft-lora-alpha = 64
38
+ train.save-every-round = 5
39
+ train.learning-rate-max = 5e-5
40
+ train.learning-rate-min = 1e-6
41
+ train.seq-length = 512
42
+ train.training-arguments.output-dir = ""
43
+ train.training-arguments.learning-rate = ""
44
+ train.training-arguments.per-device-train-batch-size = 16
45
+ train.training-arguments.gradient-accumulation-steps = 1
46
+ train.training-arguments.logging-steps = 10
47
+ train.training-arguments.num-train-epochs = 3
48
+ train.training-arguments.max-steps = 10
49
+ train.training-arguments.save-steps = 1000
50
+ train.training-arguments.save-total-limit = 10
51
+ train.training-arguments.gradient-checkpointing = true
52
+ train.training-arguments.lr-scheduler-type = "constant"
53
+ strategy.fraction-fit = $fraction_fit
54
+ strategy.fraction-evaluate = 0.0
55
+ num-server-rounds = 200
56
+
57
+ [tool.flwr.app.config.static]
58
+ dataset.name = "$dataset_name"
34
59
 
35
60
  [tool.flwr.federations]
36
61
  default = "local-simulation"
37
62
 
38
63
  [tool.flwr.federations.local-simulation]
39
- options.num-supernodes = 10
64
+ options.num-supernodes = $num_clients
65
+ options.backend.client-resources.num-cpus = 6
66
+ options.backend.client-resources.num-gpus = 1.0
flwr/cli/run/run.py CHANGED
@@ -124,14 +124,14 @@ def run(
124
124
 
125
125
 
126
126
  def _run_with_superexec(
127
- app: Optional[Path],
127
+ app: Path,
128
128
  federation_config: Dict[str, Any],
129
129
  config_overrides: Optional[List[str]],
130
130
  ) -> None:
131
131
 
132
132
  insecure_str = federation_config.get("insecure")
133
133
  if root_certificates := federation_config.get("root-certificates"):
134
- root_certificates_bytes = Path(root_certificates).read_bytes()
134
+ root_certificates_bytes = (app / root_certificates).read_bytes()
135
135
  if insecure := bool(insecure_str):
136
136
  typer.secho(
137
137
  "❌ `root_certificates` were provided but the `insecure` parameter"
@@ -77,7 +77,9 @@ def run_supernode() -> None:
77
77
  authentication_keys=authentication_keys,
78
78
  max_retries=args.max_retries,
79
79
  max_wait_time=args.max_wait_time,
80
- node_config=parse_config_args([args.node_config]),
80
+ node_config=parse_config_args(
81
+ [args.node_config] if args.node_config else args.node_config
82
+ ),
81
83
  isolation=args.isolation,
82
84
  supernode_address=args.supernode_address,
83
85
  )
flwr/common/config.py CHANGED
@@ -185,23 +185,26 @@ def parse_config_args(
185
185
  if config is None:
186
186
  return overrides
187
187
 
188
+ # Handle if .toml file is passed
189
+ if len(config) == 1 and config[0].endswith(".toml"):
190
+ with Path(config[0]).open("rb") as config_file:
191
+ overrides = flatten_dict(tomli.load(config_file))
192
+ return overrides
193
+
188
194
  # Regular expression to capture key-value pairs with possible quoted values
189
195
  pattern = re.compile(r"(\S+?)=(\'[^\']*\'|\"[^\"]*\"|\S+)")
190
196
 
191
197
  for config_line in config:
192
198
  if config_line:
193
- matches = pattern.findall(config_line)
199
+ # .toml files aren't allowed alongside other configs
200
+ if config_line.endswith(".toml"):
201
+ raise ValueError(
202
+ "TOML files cannot be passed alongside key-value pairs."
203
+ )
194
204
 
195
- if (
196
- len(matches) == 1
197
- and "=" not in matches[0][0]
198
- and matches[0][0].endswith(".toml")
199
- ):
200
- with Path(matches[0][0]).open("rb") as config_file:
201
- overrides = flatten_dict(tomli.load(config_file))
202
- else:
203
- toml_str = "\n".join(f"{k} = {v}" for k, v in matches)
204
- overrides.update(tomli.loads(toml_str))
205
+ matches = pattern.findall(config_line)
206
+ toml_str = "\n".join(f"{k} = {v}" for k, v in matches)
207
+ overrides.update(tomli.loads(toml_str))
205
208
 
206
209
  return overrides
207
210
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flwr-nightly
3
- Version: 1.11.0.dev20240826
3
+ Version: 1.11.0.dev20240828
4
4
  Summary: Flower: A Friendly Federated Learning Framework
5
5
  Home-page: https://flower.ai
6
6
  License: Apache-2.0
@@ -195,7 +195,7 @@ Other [examples](https://github.com/adap/flower/tree/main/examples):
195
195
  - [PyTorch: From Centralized to Federated](https://github.com/adap/flower/tree/main/examples/pytorch-from-centralized-to-federated)
196
196
  - [Vertical FL](https://github.com/adap/flower/tree/main/examples/vertical-fl)
197
197
  - [Federated Finetuning of OpenAI's Whisper](https://github.com/adap/flower/tree/main/examples/whisper-federated-finetuning)
198
- - [Federated Finetuning of Large Language Model](https://github.com/adap/flower/tree/main/examples/llm-flowertune)
198
+ - [Federated Finetuning of Large Language Model](https://github.com/adap/flower/tree/main/examples/flowertune-llm)
199
199
  - [Federated Finetuning of a Vision Transformer](https://github.com/adap/flower/tree/main/examples/flowertune-vit)
200
200
  - [Advanced Flower with TensorFlow/Keras](https://github.com/adap/flower/tree/main/examples/advanced-tensorflow)
201
201
  - [Advanced Flower with PyTorch](https://github.com/adap/flower/tree/main/examples/advanced-pytorch)
@@ -6,14 +6,18 @@ flwr/cli/config_utils.py,sha256=mDGXbcIxG14UpkUplILBYUkSk5M1LeTzZYDGNx-pFpU,7540
6
6
  flwr/cli/example.py,sha256=1bGDYll3BXQY2kRqSN-oICqS5n1b9m0g0RvXTopXHl4,2215
7
7
  flwr/cli/install.py,sha256=tUncrbZYRbC9QEcWSeTER16plPEoU-ERP0-nMgWiSPo,7094
8
8
  flwr/cli/new/__init__.py,sha256=cQzK1WH4JP2awef1t2UQ2xjl1agVEz9rwutV18SWV1k,789
9
- flwr/cli/new/new.py,sha256=VNb31-NLedm-_OK_D0aed0QxHO-tVlXjnf9UWVhC_Jk,9612
9
+ flwr/cli/new/new.py,sha256=RXNf8rYy5N9lgHgMR9dhFFm_MUGMPkAZf3ROMfaZRgc,10158
10
10
  flwr/cli/new/templates/__init__.py,sha256=4luU8RL-CK8JJCstQ_ON809W9bNTkY1l9zSaPKBkgwY,725
11
11
  flwr/cli/new/templates/app/.gitignore.tpl,sha256=XixnHdyeMB2vwkGtGnwHqoWpH-9WChdyG0GXe57duhc,3078
12
- flwr/cli/new/templates/app/README.flowertune.md.tpl,sha256=PqzkGm0g6Zy-vZK9_0EO3f_U6g1r69lGc4UL8kds5Q8,2696
12
+ flwr/cli/new/templates/app/LICENSE.tpl,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
13
+ flwr/cli/new/templates/app/README.baseline.md.tpl,sha256=4dg2aBS-NIleVyDlxsG8m65Af6LIJ-pZA5ICjGFU5XA,9641
14
+ flwr/cli/new/templates/app/README.flowertune.md.tpl,sha256=lxr_RCGfiDy8QGcMVdjXsUXWM_gLf6cY7UQanGL_FFQ,3304
13
15
  flwr/cli/new/templates/app/README.md.tpl,sha256=t7w4YFZEcJOxAnuJmNPw5-fDdIJu7PfLd8gFJDiBwwo,436
14
16
  flwr/cli/new/templates/app/__init__.py,sha256=DU7QMY7IhMQyuwm_tja66xU0KXTWQFqzfTqwg-_NJdE,729
17
+ flwr/cli/new/templates/app/code/__init__.baseline.py.tpl,sha256=YkHAgppUeD2BnBoGfVB6dEvBfjuIPGsU1gw4CiUi3qA,40
15
18
  flwr/cli/new/templates/app/code/__init__.py,sha256=EM6vfvgAILKPaPn7H1wMV1Wi01WyZCP_Eg6NxD6oWg8,736
16
19
  flwr/cli/new/templates/app/code/__init__.py.tpl,sha256=J0Gn74E7khpLyKJVNqOPu7ev93vkcu1PZugsbxtABMw,52
20
+ flwr/cli/new/templates/app/code/client.baseline.py.tpl,sha256=1htktXX3jXX05r0vuG_afjS1sXGtuONW9EpiQ7vSBes,1901
17
21
  flwr/cli/new/templates/app/code/client.huggingface.py.tpl,sha256=62wtB4k1yrDApiG-rvGlOYFuiwAVk8kqJFmyY_v8HLo,1803
18
22
  flwr/cli/new/templates/app/code/client.jax.py.tpl,sha256=c2LDew2V8BUybZJiz1FeB3Kq4ey0Q2s0S5qNPUTNmI4,1490
19
23
  flwr/cli/new/templates/app/code/client.mlx.py.tpl,sha256=gxipt57ldc741qwRqSWtsLQH05JODKdGMTtvoXiBzDA,2906
@@ -21,14 +25,15 @@ flwr/cli/new/templates/app/code/client.numpy.py.tpl,sha256=DMUXvQd2dr-wEn0ZrYJQh
21
25
  flwr/cli/new/templates/app/code/client.pytorch.py.tpl,sha256=WczaR5avJUhfw2Grn2KEC4tDJ4voIYG-2pAy-7i2cT8,1685
22
26
  flwr/cli/new/templates/app/code/client.sklearn.py.tpl,sha256=xW9cuKhybk5S8IeDZhbeb0DNegDIJGEYrzMKsxgc2GE,2978
23
27
  flwr/cli/new/templates/app/code/client.tensorflow.py.tpl,sha256=u3KKf7hC9xGqOIUJXYCHJ_jiIu3aVbsC8pxVxm4yN6I,1759
28
+ flwr/cli/new/templates/app/code/dataset.baseline.py.tpl,sha256=jbd_exHAk2-Blu_kVutjPO6a_dkJQWb232zxSeXIZ1k,1453
24
29
  flwr/cli/new/templates/app/code/flwr_tune/__init__.py,sha256=JgNgBtKdm1jKM9625WxappCAVUGtYAmcjKSsXJ1u3ZQ,748
25
- flwr/cli/new/templates/app/code/flwr_tune/app.py.tpl,sha256=LOtmEYYayMCpF4rJRdo059n5w_cZRmzyuEkCN2qpTyQ,2826
26
- flwr/cli/new/templates/app/code/flwr_tune/client.py.tpl,sha256=3s41XYHRvmcLhyA60tZyGCNK2wxo2shl6mwmPfZANlA,4155
27
- flwr/cli/new/templates/app/code/flwr_tune/config.yaml.tpl,sha256=aPjrwFU020tPkJmOjzSUjb9dSi2bhs4ZTMEyd0uRlCA,867
28
- flwr/cli/new/templates/app/code/flwr_tune/dataset.py.tpl,sha256=kPG4AIXQfNNHZGYC3amet3ttI23N72N6jjoDkp_wYIA,2028
29
- flwr/cli/new/templates/app/code/flwr_tune/models.py.tpl,sha256=cEq9ZWM3zImJVceNtxHC_bYBLE8OChK0BdjpWs5Wz-0,1881
30
- flwr/cli/new/templates/app/code/flwr_tune/server.py.tpl,sha256=tz4hgAGV6pn5cOFW10ELRNRsUzLBSssHxrH_gSs_jtk,1552
31
- flwr/cli/new/templates/app/code/flwr_tune/static_config.yaml.tpl,sha256=cBPpBVN_N7p4T2a3rqChlngmE0dB_jveOLHesNcEHvs,268
30
+ flwr/cli/new/templates/app/code/flwr_tune/client_app.py.tpl,sha256=DbotzaXzLDwplVBkJLOe5Lt5b6Yutwv9rJ69oVwyrvU,4397
31
+ flwr/cli/new/templates/app/code/flwr_tune/dataset.py.tpl,sha256=iAujo8WubDGrz0gg_6zl-TUvkIbNRJM-VJmwKJ9tGY8,3051
32
+ flwr/cli/new/templates/app/code/flwr_tune/models.py.tpl,sha256=UCLEKUpXarkz9tMFtDrxmLv6QuKe5zCimTuoopQedUM,1717
33
+ flwr/cli/new/templates/app/code/flwr_tune/server_app.py.tpl,sha256=yMVcbfGkTPV9AV16bVdi5fTX1a6jmtszTUrvLXSosio,3305
34
+ flwr/cli/new/templates/app/code/flwr_tune/strategy.py.tpl,sha256=BhiqRg9w1MGuU5h2_vrLhRc0oHItYzE69qX_JI411k8,2754
35
+ flwr/cli/new/templates/app/code/model.baseline.py.tpl,sha256=cSz6-IWsnMl7s04DW4URINiIppCIberrtE8NqK6Qz48,2571
36
+ flwr/cli/new/templates/app/code/server.baseline.py.tpl,sha256=outx7lDXsWS8QXKWOGOiDno6eE8WL7LBD51ZkAuC3WU,1570
32
37
  flwr/cli/new/templates/app/code/server.huggingface.py.tpl,sha256=etpjLvGu6pVXzYQBKZp4tTbD3zm461qFo24NliKo74U,591
33
38
  flwr/cli/new/templates/app/code/server.jax.py.tpl,sha256=pIdUH-LgWRAGWQYLlivMNf8XnDSNDe2cCuRjlxbRzys,529
34
39
  flwr/cli/new/templates/app/code/server.mlx.py.tpl,sha256=RqiZ0k468SOlm9dcPr-fvA8xcWv4zwDCbJfBwL7P9Us,529
@@ -36,12 +41,15 @@ flwr/cli/new/templates/app/code/server.numpy.py.tpl,sha256=RqiZ0k468SOlm9dcPr-fv
36
41
  flwr/cli/new/templates/app/code/server.pytorch.py.tpl,sha256=DW5c8vzXCvFeIE8YIWBhoGnSdv8Ka_e5wd3F6B3xvp8,916
37
42
  flwr/cli/new/templates/app/code/server.sklearn.py.tpl,sha256=25Ae3kDqjDdBl8LwkDwye69nevd02Pk_e7F3SQKLdyk,624
38
43
  flwr/cli/new/templates/app/code/server.tensorflow.py.tpl,sha256=xMhQ7AumowgLkgUilgjVK7IbpRhPjslhVJU-vID6NY8,856
44
+ flwr/cli/new/templates/app/code/strategy.baseline.py.tpl,sha256=YkHAgppUeD2BnBoGfVB6dEvBfjuIPGsU1gw4CiUi3qA,40
39
45
  flwr/cli/new/templates/app/code/task.huggingface.py.tpl,sha256=G_LOeGErw-6WZAyuT01mXqR6s_BUrQYErXf_nHLujo4,3153
40
46
  flwr/cli/new/templates/app/code/task.jax.py.tpl,sha256=F05eg149c9icRyVNdfcLyZvAXROQ7QhfifoGw_U1dsg,1530
41
47
  flwr/cli/new/templates/app/code/task.mlx.py.tpl,sha256=jWtCULLRr_9bCIJvoTLMx037-SDl_LF8udtA1UGoXDk,2946
42
48
  flwr/cli/new/templates/app/code/task.pytorch.py.tpl,sha256=NgbPix74X1t3ybaGjqdls30vF1i5oY3L7EQExhWhN74,3812
43
49
  flwr/cli/new/templates/app/code/task.tensorflow.py.tpl,sha256=SKXAZdgBnPpbAbJ90Rb7oQ5ilnopBx_j_JNFoUDeEAI,1732
44
- flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl,sha256=chTKewidM-st9Uk5o95tGOqJ5FSa1L2R0UdSW2wTr0c,789
50
+ flwr/cli/new/templates/app/code/utils.baseline.py.tpl,sha256=YkHAgppUeD2BnBoGfVB6dEvBfjuIPGsU1gw4CiUi3qA,40
51
+ flwr/cli/new/templates/app/pyproject.baseline.toml.tpl,sha256=4gi90W9_B1kj6rYkpvVJxhNX9Yctsv9OH6CzXP-dcE4,2666
52
+ flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl,sha256=pogRZLrwSfN_XH4NxDdMkhMh1O_7DP90VOoP-cP0HvI,1827
45
53
  flwr/cli/new/templates/app/pyproject.huggingface.toml.tpl,sha256=nD0rRUyr_Cj0TaSH8PsiaMhCwu_BuOVX4oqWfFSvOcE,765
46
54
  flwr/cli/new/templates/app/pyproject.jax.toml.tpl,sha256=Tq6jeGcoOKzMwWWYxMVnzMcipLURHLiW69iYlD1ywMg,659
47
55
  flwr/cli/new/templates/app/pyproject.mlx.toml.tpl,sha256=SHwYAA2qgIlOAU3Sb9BKSZcZ7O9biACg27MHexXUtDw,741
@@ -50,7 +58,7 @@ flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl,sha256=vIO1ArukTC76ogYLNmJ
50
58
  flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl,sha256=jk_5teoyOVM9QdBea8J-nk10S6TKw81QZiiKB54ATF0,654
51
59
  flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl,sha256=bRIvPCPvTTI4Eo5b61Rmw8WdDw3sjcohciTXgULN5l8,702
52
60
  flwr/cli/run/__init__.py,sha256=oCd6HmQDx-sqver1gecgx-uMA38BLTSiiKpl7RGNceg,789
53
- flwr/cli/run/run.py,sha256=8JziIz-NITpCVcGj1OgOdyjxa80SyifV0a_jElXaCU0,7987
61
+ flwr/cli/run/run.py,sha256=RI6MgLBNYxmacjQg8XMAQ7VKxbV0DkRyJTfe4GsDFuw,7979
54
62
  flwr/cli/utils.py,sha256=l65Ul0YsSBPuypk0uorAtEDmLEYiUrzpCXi6zCg9mJ4,4506
55
63
  flwr/client/__init__.py,sha256=wzJZsYJIHf_8-PMzvfbinyzzjgh1UP1vLrAw2_yEbKI,1345
56
64
  flwr/client/app.py,sha256=o_2bhmlBeZATtWnAPZhL-Q1Ly0QZxc9ou4i7t0HKumE,31956
@@ -87,11 +95,11 @@ flwr/client/numpy_client.py,sha256=9rpj5OLmeeDQVzopR1My6A2VS3nkBFw6cmNcMMPYGlQ,1
87
95
  flwr/client/rest_client/__init__.py,sha256=5KGlp7pjc1dhNRkKlaNtUfQmg8wrRFh9lS3P3uRS-7Q,735
88
96
  flwr/client/rest_client/connection.py,sha256=21YNE6K6JfyZtwIftx1MGOkM78J9wb4EGGOyLS8ej0E,12767
89
97
  flwr/client/supernode/__init__.py,sha256=SUhWOzcgXRNXk1V9UgB5-FaWukqqrOEajVUHEcPkwyQ,865
90
- flwr/client/supernode/app.py,sha256=MOYvLX3VkrslsMQ7V0YdY0GovjXOGsgabYXrvRvHUWc,11856
98
+ flwr/client/supernode/app.py,sha256=6dWrpgMDmbWt-GFzWcANGsDdpGuCS5fb4j7dEDeVvX4,11920
91
99
  flwr/client/typing.py,sha256=dxoTBnTMfqXr5J7G3y-uNjqxYCddvxhu89spfj4Lm2U,1048
92
100
  flwr/common/__init__.py,sha256=TVaoFEJE158aui1TPZQiJCDZX4RNHRyI8I55VC80HhI,3901
93
101
  flwr/common/address.py,sha256=1zvmVIAyYP6JbGkMnXuROzkYJ7aSKbJM754lC_kbh1M,3024
94
- flwr/common/config.py,sha256=GN-eKrCuyypLMFgr1kO2d-mwiNNphaFt30UlfbaKJFk,7435
102
+ flwr/common/config.py,sha256=TBw2sI0ZgZ3l3JrjfrcnD1mnMJbaHi_i8w68YXEgPUk,7586
95
103
  flwr/common/constant.py,sha256=1XxuRezsr9fl3xvQNPR2kyFkwNeG_f5vZayv0PFh0kY,3012
96
104
  flwr/common/context.py,sha256=5Bd9RCrhLkYZOVR7vr97OVhzVBHQkS1fUsYiIKTwpxU,2239
97
105
  flwr/common/date.py,sha256=OcQuwpb2HxcblTqYm6H223ufop5UZw5N_fzalbpOVzY,891
@@ -286,8 +294,8 @@ flwr/superexec/exec_grpc.py,sha256=PhqGoZEpTMxSQmUSV8Wgtzb1Za_pHJ-adZqo5RYnDyE,1
286
294
  flwr/superexec/exec_servicer.py,sha256=jl0aKVjm0PLQABcTL5c3jdSIzb0Z6hpVOtrAn4Ob7ts,2323
287
295
  flwr/superexec/executor.py,sha256=k_adivto6R2U82DADOHNvdtobehBYreRek1gOEBIQnQ,2318
288
296
  flwr/superexec/simulation.py,sha256=J6pw-RqCSiUed8I_3MasZH4tl57ZmDebPAHNnbb0-vE,7420
289
- flwr_nightly-1.11.0.dev20240826.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
290
- flwr_nightly-1.11.0.dev20240826.dist-info/METADATA,sha256=OmK8rSpoeTJ0WUZcf-1nAMnPigWTFG4p8gCpd9ek4_Q,15703
291
- flwr_nightly-1.11.0.dev20240826.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
292
- flwr_nightly-1.11.0.dev20240826.dist-info/entry_points.txt,sha256=3cDQVJEBRCSLzJrVYAgjXpoCjuQ74I3A9NZ61DOHdVo,388
293
- flwr_nightly-1.11.0.dev20240826.dist-info/RECORD,,
297
+ flwr_nightly-1.11.0.dev20240828.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
298
+ flwr_nightly-1.11.0.dev20240828.dist-info/METADATA,sha256=DW4GNlzLFXJ5MQZC68Xdz7ie4OMwHW486Ci6x_G5--E,15703
299
+ flwr_nightly-1.11.0.dev20240828.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
300
+ flwr_nightly-1.11.0.dev20240828.dist-info/entry_points.txt,sha256=3cDQVJEBRCSLzJrVYAgjXpoCjuQ74I3A9NZ61DOHdVo,388
301
+ flwr_nightly-1.11.0.dev20240828.dist-info/RECORD,,
@@ -1,89 +0,0 @@
1
- """$project_name: A Flower / FlowerTune app."""
2
-
3
- import os
4
- import warnings
5
- from datetime import datetime
6
-
7
- from flwr_datasets import FederatedDataset
8
- from hydra import compose, initialize
9
- from hydra.utils import instantiate
10
-
11
- from flwr.client import ClientApp
12
- from flwr.common import Context, ndarrays_to_parameters
13
- from flwr.server import ServerApp, ServerAppComponents, ServerConfig
14
-
15
- from $import_name.client_app import gen_client_fn, get_parameters
16
- from $import_name.dataset import get_tokenizer_and_data_collator_and_propt_formatting
17
- from $import_name.models import get_model
18
- from $import_name.server_app import fit_weighted_average, get_evaluate_fn, get_on_fit_config
19
-
20
- # Avoid warnings
21
- warnings.filterwarnings("ignore", category=UserWarning)
22
- os.environ["TOKENIZERS_PARALLELISM"] = "true"
23
- os.environ["RAY_DISABLE_DOCKER_CPU_WARNING"] = "1"
24
-
25
- # Initialise regular config
26
- with initialize(config_path="conf", version_base="1.1"):
27
- cfg = compose(config_name="config")
28
-
29
- # Initialise static config
30
- with initialize(config_path="conf", version_base="1.1"):
31
- cfg_static = compose(config_name="static_config")
32
-
33
- cfg.train.num_rounds = cfg_static.num_rounds
34
-
35
- # Create output directory given current timestamp
36
- current_time = datetime.now()
37
- folder_name = current_time.strftime("%Y-%m-%d_%H-%M-%S")
38
- save_path = os.path.join(os.getcwd(), f"results/{folder_name}")
39
- os.makedirs(save_path, exist_ok=True)
40
-
41
- # Partition dataset and get dataloaders
42
- partitioner = instantiate(cfg_static.partitioner)
43
- fds = FederatedDataset(
44
- dataset=cfg_static.dataset.name, partitioners={"train": partitioner}
45
- )
46
- (
47
- tokenizer,
48
- data_collator,
49
- formatting_prompts_func,
50
- ) = get_tokenizer_and_data_collator_and_propt_formatting(cfg.model.name)
51
-
52
- # ClientApp for Flower Next
53
- client = ClientApp(
54
- client_fn=gen_client_fn(
55
- fds,
56
- tokenizer,
57
- formatting_prompts_func,
58
- data_collator,
59
- cfg.model,
60
- cfg.train,
61
- save_path,
62
- ),
63
- )
64
-
65
- # Get initial model weights
66
- init_model = get_model(cfg.model)
67
- init_model_parameters = get_parameters(init_model)
68
- init_model_parameters = ndarrays_to_parameters(init_model_parameters)
69
-
70
- def server_fn(context: Context):
71
- # Instantiate strategy according to config. Here we pass other arguments
72
- # that are only defined at runtime.
73
- strategy = instantiate(
74
- cfg.strategy,
75
- on_fit_config_fn=get_on_fit_config(),
76
- fit_metrics_aggregation_fn=fit_weighted_average,
77
- initial_parameters=init_model_parameters,
78
- evaluate_fn=get_evaluate_fn(
79
- cfg.model, cfg.train.save_every_round, cfg_static.num_rounds, save_path
80
- ),
81
- )
82
-
83
- config = ServerConfig(num_rounds=cfg_static.num_rounds)
84
-
85
- return ServerAppComponents(strategy=strategy, config=config)
86
-
87
-
88
- # ServerApp for Flower Next
89
- server = ServerApp(server_fn=server_fn)
@@ -1,34 +0,0 @@
1
- # Federated Instruction Tuning
2
- ---
3
- model:
4
- name: "mistralai/Mistral-7B-v0.3"
5
- quantization: 4 # 8 or 4 if you want to do quantization with BitsAndBytes
6
- gradient_checkpointing: True
7
- lora:
8
- peft_lora_r: 32
9
- peft_lora_alpha: 64
10
-
11
- train:
12
- num_rounds: null
13
- save_every_round: 5
14
- learning_rate_max: 5e-5
15
- learning_rate_min: 1e-6
16
- seq_length: 512
17
- training_arguments:
18
- output_dir: null # to be set by hydra
19
- learning_rate: null # to be set by the client
20
- per_device_train_batch_size: 16
21
- gradient_accumulation_steps: 1
22
- logging_steps: 10
23
- num_train_epochs: 3
24
- max_steps: 10
25
- report_to: null
26
- save_steps: 1000
27
- save_total_limit: 10
28
- gradient_checkpointing: True
29
- lr_scheduler_type: "constant"
30
-
31
- strategy:
32
- _target_: flwr.server.strategy.FedAvg
33
- fraction_fit: $fraction_fit
34
- fraction_evaluate: 0.0 # no client evaluation
@@ -1,48 +0,0 @@
1
- """$project_name: A Flower / FlowerTune app."""
2
-
3
- from $import_name.client_app import set_parameters
4
- from $import_name.models import get_model
5
-
6
-
7
- # Get function that will be executed by the strategy's evaluate() method
8
- # Here we use it to save global model checkpoints
9
- def get_evaluate_fn(model_cfg, save_every_round, total_round, save_path):
10
- """Return an evaluation function for saving global model."""
11
-
12
- def evaluate(server_round: int, parameters, config):
13
- # Save model
14
- if server_round != 0 and (
15
- server_round == total_round or server_round % save_every_round == 0
16
- ):
17
- # Init model
18
- model = get_model(model_cfg)
19
- set_parameters(model, parameters)
20
-
21
- model.save_pretrained(f"{save_path}/peft_{server_round}")
22
-
23
- return 0.0, {}
24
-
25
- return evaluate
26
-
27
-
28
- def get_on_fit_config():
29
- """
30
- Return a function that will be used to construct the config
31
- that the client's fit() method will receive.
32
- """
33
-
34
- def fit_config_fn(server_round: int):
35
- fit_config = {"current_round": server_round}
36
- return fit_config
37
-
38
- return fit_config_fn
39
-
40
-
41
- def fit_weighted_average(metrics):
42
- """Aggregate (federated) evaluation metrics."""
43
- # Multiply accuracy of each client by number of examples used
44
- losses = [num_examples * m["train_loss"] for num_examples, m in metrics]
45
- examples = [num_examples for num_examples, _ in metrics]
46
-
47
- # Aggregate and return custom metric (weighted average)
48
- return {"train_loss": sum(losses) / sum(examples)}
@@ -1,11 +0,0 @@
1
- # Federated Instruction Tuning (static)
2
- ---
3
- dataset:
4
- name: $dataset_name
5
-
6
- # FL experimental settings
7
- num_clients: $num_clients # total number of clients
8
- num_rounds: 200
9
- partitioner:
10
- _target_: flwr_datasets.partitioner.IidPartitioner
11
- num_partitions: $num_clients