flwr-nightly 1.12.0.dev20240915__py3-none-any.whl → 1.12.0.dev20240917__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.
- flwr/cli/new/templates/app/code/flwr_tune/client_app.py.tpl +7 -17
- flwr/cli/new/templates/app/code/flwr_tune/models.py.tpl +23 -1
- flwr/cli/new/templates/app/code/flwr_tune/server_app.py.tpl +1 -2
- flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl +1 -1
- {flwr_nightly-1.12.0.dev20240915.dist-info → flwr_nightly-1.12.0.dev20240917.dist-info}/METADATA +1 -1
- {flwr_nightly-1.12.0.dev20240915.dist-info → flwr_nightly-1.12.0.dev20240917.dist-info}/RECORD +9 -9
- {flwr_nightly-1.12.0.dev20240915.dist-info → flwr_nightly-1.12.0.dev20240917.dist-info}/LICENSE +0 -0
- {flwr_nightly-1.12.0.dev20240915.dist-info → flwr_nightly-1.12.0.dev20240917.dist-info}/WHEEL +0 -0
- {flwr_nightly-1.12.0.dev20240915.dist-info → flwr_nightly-1.12.0.dev20240917.dist-info}/entry_points.txt +0 -0
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
import warnings
|
|
5
|
-
from collections import OrderedDict
|
|
6
5
|
from typing import Dict, Tuple
|
|
7
6
|
|
|
8
7
|
import torch
|
|
@@ -11,7 +10,7 @@ from flwr.common import Context
|
|
|
11
10
|
from flwr.common.config import unflatten_dict
|
|
12
11
|
from flwr.common.typing import NDArrays, Scalar
|
|
13
12
|
from omegaconf import DictConfig
|
|
14
|
-
|
|
13
|
+
|
|
15
14
|
from transformers import TrainingArguments
|
|
16
15
|
from trl import SFTTrainer
|
|
17
16
|
|
|
@@ -20,7 +19,12 @@ from $import_name.dataset import (
|
|
|
20
19
|
load_data,
|
|
21
20
|
replace_keys,
|
|
22
21
|
)
|
|
23
|
-
from $import_name.models import
|
|
22
|
+
from $import_name.models import (
|
|
23
|
+
cosine_annealing,
|
|
24
|
+
get_model,
|
|
25
|
+
set_parameters,
|
|
26
|
+
get_parameters,
|
|
27
|
+
)
|
|
24
28
|
|
|
25
29
|
# Avoid warnings
|
|
26
30
|
os.environ["TOKENIZERS_PARALLELISM"] = "true"
|
|
@@ -92,20 +96,6 @@ class FlowerClient(NumPyClient):
|
|
|
92
96
|
)
|
|
93
97
|
|
|
94
98
|
|
|
95
|
-
def set_parameters(model, parameters: NDArrays) -> None:
|
|
96
|
-
"""Change the parameters of the model using the given ones."""
|
|
97
|
-
peft_state_dict_keys = get_peft_model_state_dict(model).keys()
|
|
98
|
-
params_dict = zip(peft_state_dict_keys, parameters)
|
|
99
|
-
state_dict = OrderedDict({k: torch.Tensor(v) for k, v in params_dict})
|
|
100
|
-
set_peft_model_state_dict(model, state_dict)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def get_parameters(model) -> NDArrays:
|
|
104
|
-
"""Return the parameters of the current net."""
|
|
105
|
-
state_dict = get_peft_model_state_dict(model)
|
|
106
|
-
return [val.cpu().numpy() for _, val in state_dict.items()]
|
|
107
|
-
|
|
108
|
-
|
|
109
99
|
def client_fn(context: Context) -> FlowerClient:
|
|
110
100
|
"""Create a Flower client representing a single organization."""
|
|
111
101
|
partition_id = context.node_config["partition-id"]
|
|
@@ -4,10 +4,18 @@ import math
|
|
|
4
4
|
|
|
5
5
|
import torch
|
|
6
6
|
from omegaconf import DictConfig
|
|
7
|
-
from
|
|
7
|
+
from collections import OrderedDict
|
|
8
|
+
from peft import (
|
|
9
|
+
LoraConfig,
|
|
10
|
+
get_peft_model,
|
|
11
|
+
get_peft_model_state_dict,
|
|
12
|
+
set_peft_model_state_dict,
|
|
13
|
+
)
|
|
8
14
|
from peft.utils import prepare_model_for_kbit_training
|
|
9
15
|
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
|
|
10
16
|
|
|
17
|
+
from flwr.common.typing import NDArrays
|
|
18
|
+
|
|
11
19
|
|
|
12
20
|
def cosine_annealing(
|
|
13
21
|
current_round: int,
|
|
@@ -54,3 +62,17 @@ def get_model(model_cfg: DictConfig):
|
|
|
54
62
|
model.config.use_cache = False
|
|
55
63
|
|
|
56
64
|
return get_peft_model(model, peft_config)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def set_parameters(model, parameters: NDArrays) -> None:
|
|
68
|
+
"""Change the parameters of the model using the given ones."""
|
|
69
|
+
peft_state_dict_keys = get_peft_model_state_dict(model).keys()
|
|
70
|
+
params_dict = zip(peft_state_dict_keys, parameters)
|
|
71
|
+
state_dict = OrderedDict({k: torch.Tensor(v) for k, v in params_dict})
|
|
72
|
+
set_peft_model_state_dict(model, state_dict)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def get_parameters(model) -> NDArrays:
|
|
76
|
+
"""Return the parameters of the current net."""
|
|
77
|
+
state_dict = get_peft_model_state_dict(model)
|
|
78
|
+
return [val.cpu().numpy() for _, val in state_dict.items()]
|
|
@@ -8,8 +8,7 @@ from flwr.common.config import unflatten_dict
|
|
|
8
8
|
from flwr.server import ServerApp, ServerAppComponents, ServerConfig
|
|
9
9
|
from omegaconf import DictConfig
|
|
10
10
|
|
|
11
|
-
from $import_name.
|
|
12
|
-
from $import_name.models import get_model
|
|
11
|
+
from $import_name.models import get_model, get_parameters, set_parameters
|
|
13
12
|
from $import_name.dataset import replace_keys
|
|
14
13
|
from $import_name.strategy import FlowerTuneLlm
|
|
15
14
|
|
{flwr_nightly-1.12.0.dev20240915.dist-info → flwr_nightly-1.12.0.dev20240917.dist-info}/RECORD
RENAMED
|
@@ -27,10 +27,10 @@ flwr/cli/new/templates/app/code/client.sklearn.py.tpl,sha256=xW9cuKhybk5S8IeDZhb
|
|
|
27
27
|
flwr/cli/new/templates/app/code/client.tensorflow.py.tpl,sha256=yBiiU7B9Kf70U52cPkNs_dUpYrrTwbUi2os-PAyheaM,1680
|
|
28
28
|
flwr/cli/new/templates/app/code/dataset.baseline.py.tpl,sha256=jbd_exHAk2-Blu_kVutjPO6a_dkJQWb232zxSeXIZ1k,1453
|
|
29
29
|
flwr/cli/new/templates/app/code/flwr_tune/__init__.py,sha256=JgNgBtKdm1jKM9625WxappCAVUGtYAmcjKSsXJ1u3ZQ,748
|
|
30
|
-
flwr/cli/new/templates/app/code/flwr_tune/client_app.py.tpl,sha256=
|
|
30
|
+
flwr/cli/new/templates/app/code/flwr_tune/client_app.py.tpl,sha256=Zgr_DwzP518E0lcGjs_togOeksdTVjwGU8sK6g8Wd0U,3765
|
|
31
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=
|
|
33
|
-
flwr/cli/new/templates/app/code/flwr_tune/server_app.py.tpl,sha256=
|
|
32
|
+
flwr/cli/new/templates/app/code/flwr_tune/models.py.tpl,sha256=ONJw_BgBWEofVNGRDu8KAIThb8saRQlUEK4uS2u_6To,2449
|
|
33
|
+
flwr/cli/new/templates/app/code/flwr_tune/server_app.py.tpl,sha256=xkmmBKr0oGmewP56SP3s_6FG6JOVlGlquhg3a9nYMis,3270
|
|
34
34
|
flwr/cli/new/templates/app/code/flwr_tune/strategy.py.tpl,sha256=BhiqRg9w1MGuU5h2_vrLhRc0oHItYzE69qX_JI411k8,2754
|
|
35
35
|
flwr/cli/new/templates/app/code/model.baseline.py.tpl,sha256=cSz6-IWsnMl7s04DW4URINiIppCIberrtE8NqK6Qz48,2571
|
|
36
36
|
flwr/cli/new/templates/app/code/server.baseline.py.tpl,sha256=outx7lDXsWS8QXKWOGOiDno6eE8WL7LBD51ZkAuC3WU,1570
|
|
@@ -49,7 +49,7 @@ flwr/cli/new/templates/app/code/task.pytorch.py.tpl,sha256=NgbPix74X1t3ybaGjqdls
|
|
|
49
49
|
flwr/cli/new/templates/app/code/task.tensorflow.py.tpl,sha256=SKXAZdgBnPpbAbJ90Rb7oQ5ilnopBx_j_JNFoUDeEAI,1732
|
|
50
50
|
flwr/cli/new/templates/app/code/utils.baseline.py.tpl,sha256=YkHAgppUeD2BnBoGfVB6dEvBfjuIPGsU1gw4CiUi3qA,40
|
|
51
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
|
|
52
|
+
flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl,sha256=-tW_nwHQCK5JIRI4Cpb0yDVHJO0RUAEOTqCtWJoGHIQ,1827
|
|
53
53
|
flwr/cli/new/templates/app/pyproject.huggingface.toml.tpl,sha256=CHJgkPNkJfzJhEbTe15uiV3AhOtIddQi-yofPZsCk3E,1143
|
|
54
54
|
flwr/cli/new/templates/app/pyproject.jax.toml.tpl,sha256=Tq6jeGcoOKzMwWWYxMVnzMcipLURHLiW69iYlD1ywMg,659
|
|
55
55
|
flwr/cli/new/templates/app/pyproject.mlx.toml.tpl,sha256=SHwYAA2qgIlOAU3Sb9BKSZcZ7O9biACg27MHexXUtDw,741
|
|
@@ -294,8 +294,8 @@ flwr/superexec/exec_grpc.py,sha256=ZPq7EP55Vwj0kRcLVuTCokFqfIgBk-7YmDykZoMKi-c,1
|
|
|
294
294
|
flwr/superexec/exec_servicer.py,sha256=P4bJtQqCr0NiVIa-ss9lvdUM1SbM_ip5g5UqKp3dNL4,2344
|
|
295
295
|
flwr/superexec/executor.py,sha256=k_adivto6R2U82DADOHNvdtobehBYreRek1gOEBIQnQ,2318
|
|
296
296
|
flwr/superexec/simulation.py,sha256=J6pw-RqCSiUed8I_3MasZH4tl57ZmDebPAHNnbb0-vE,7420
|
|
297
|
-
flwr_nightly-1.12.0.
|
|
298
|
-
flwr_nightly-1.12.0.
|
|
299
|
-
flwr_nightly-1.12.0.
|
|
300
|
-
flwr_nightly-1.12.0.
|
|
301
|
-
flwr_nightly-1.12.0.
|
|
297
|
+
flwr_nightly-1.12.0.dev20240917.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
298
|
+
flwr_nightly-1.12.0.dev20240917.dist-info/METADATA,sha256=OkGAAowGmaur_4Fz28Ni91lGncc3-Xq8A6gTGnRg8Jg,15452
|
|
299
|
+
flwr_nightly-1.12.0.dev20240917.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
300
|
+
flwr_nightly-1.12.0.dev20240917.dist-info/entry_points.txt,sha256=WUCbqhLEOzjx_lyATIM0-f0e8kOVaQjzwOvyOxHrMhs,434
|
|
301
|
+
flwr_nightly-1.12.0.dev20240917.dist-info/RECORD,,
|
{flwr_nightly-1.12.0.dev20240915.dist-info → flwr_nightly-1.12.0.dev20240917.dist-info}/LICENSE
RENAMED
|
File without changes
|
{flwr_nightly-1.12.0.dev20240915.dist-info → flwr_nightly-1.12.0.dev20240917.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|