Skip to content

Commit 46f1eb6

Browse files
holgerrothchesterxgchenYuanTingHsieh
authored
[BioNeMo] Use decomposer register widget (#3784)
update other bionemo examples Fixes # . ### Description Update bionemo examples and tutorial for 2.7 with decomposer register widget ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Quick tests passed locally by running `./runtest.sh`. - [ ] In-line docstrings updated. - [ ] Documentation updated. Signed-off-by: Holger Roth <[email protected]> Co-authored-by: Chester Chen <[email protected]> Co-authored-by: Yuan-Ting Hsieh (謝沅廷) <[email protected]>
1 parent 6c09d01 commit 46f1eb6

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

examples/advanced/bionemo/downstream/downstream_nvflare.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"source": [
5050
"%%capture --no-display --no-stderr cell_output\n",
5151
"! pip install fuzzywuzzy PyTDC --no-dependencies # install tdc without dependencies to avoid version conflicts in the BioNeMo container\n",
52-
"! pip install nvflare~=2.6rc\n",
52+
"! pip install \"nvflare~=2.7.0rc\"\n",
5353
"\n",
5454
"import os\n",
5555
"import warnings\n",

examples/advanced/bionemo/downstream/sabdab/run_sim_sabdab.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from nvflare import FilterType
2222
from nvflare.app_common.launchers.subprocess_launcher import SubprocessLauncher
23+
from nvflare.app_common.widgets.decomposer_reg import DecomposerRegister
2324
from nvflare.app_common.workflows.fedavg import FedAvg
2425
from nvflare.app_opt.pt.job_config.base_fed_job import BaseFedJob
2526
from nvflare.job_config.script_runner import BaseScriptRunner
@@ -38,6 +39,7 @@ def main(args):
3839
num_rounds=args.num_rounds,
3940
)
4041
job.to_server(controller)
42+
job.to_server(DecomposerRegister(["nvflare.app_opt.pt.decomposers.TensorDecomposer"]))
4143

4244
checkpoint_path = load(f"esm2/{args.model}:2.0")
4345
print(f"Downloaded {args.model} to {checkpoint_path}")
@@ -87,6 +89,7 @@ def main(args):
8789
BioNeMoParamsFilter(precision), client_name, tasks=["train", "validate"], filter_type=FilterType.TASK_DATA
8890
)
8991
job.to(BioNeMoStateDictFilter(), client_name, tasks=["train", "validate"], filter_type=FilterType.TASK_RESULT)
92+
job.to(DecomposerRegister(["nvflare.app_opt.pt.decomposers.TensorDecomposer"]), client_name)
9093

9194
job.export_job("./exported_jobs")
9295
job.simulator_run(f"/tmp/nvflare/bionemo/sabdab/{job.name}", gpu=args.sim_gpus)

examples/advanced/bionemo/downstream/scl/run_sim_scl.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@
1313
# limitations under the License.
1414

1515
import argparse
16-
import os
17-
import sys
1816

1917
from bionemo.core.data.load import load
18+
from bionemo_filters import BioNeMoParamsFilter, BioNeMoStateDictFilter
2019

2120
from nvflare import FilterType
2221
from nvflare.app_common.launchers.subprocess_launcher import SubprocessLauncher
22+
from nvflare.app_common.widgets.decomposer_reg import DecomposerRegister
2323
from nvflare.app_common.workflows.fedavg import FedAvg
2424
from nvflare.app_opt.pt.job_config.base_fed_job import BaseFedJob
2525
from nvflare.job_config.script_runner import BaseScriptRunner
2626

27-
sys.path.append(os.path.join(os.getcwd(), "..")) # include parent folder in path
28-
from bionemo_filters import BioNeMoParamsFilter, BioNeMoStateDictFilter
29-
3027

3128
def main(args):
3229
# Create BaseFedJob with initial model
@@ -38,6 +35,7 @@ def main(args):
3835
num_rounds=args.num_rounds,
3936
)
4037
job.to_server(controller)
38+
job.to_server(DecomposerRegister(["nvflare.app_opt.pt.decomposers.TensorDecomposer"]))
4139

4240
checkpoint_path = load(f"esm2/{args.model}:2.0")
4341
print(f"Downloaded {args.model} to {checkpoint_path}")
@@ -81,6 +79,7 @@ def main(args):
8179
BioNeMoParamsFilter(precision), client_name, tasks=["train", "validate"], filter_type=FilterType.TASK_DATA
8280
)
8381
job.to(BioNeMoStateDictFilter(), client_name, tasks=["train", "validate"], filter_type=FilterType.TASK_RESULT)
82+
job.to(DecomposerRegister(["nvflare.app_opt.pt.decomposers.TensorDecomposer"]), client_name)
8483

8584
job.export_job("./exported_jobs")
8685
job.simulator_run(f"/tmp/nvflare/bionemo/scl/{job.name}", gpu=args.sim_gpus)
@@ -91,9 +90,7 @@ def main(args):
9190
parser.add_argument("--num_clients", type=int, help="Number of clients", required=False, default=1)
9291
parser.add_argument("--num_rounds", type=int, help="Number of rounds", required=False, default=30)
9392
parser.add_argument("--local_steps", type=int, help="Number of rounds", required=False, default=10)
94-
parser.add_argument(
95-
"--train_script", type=str, help="Training script", required=False, default="../finetune_esm2.py"
96-
)
93+
parser.add_argument("--train_script", type=str, help="Training script", required=False, default="finetune_esm2.py")
9794
parser.add_argument("--exp_name", type=str, help="Job name prefix", required=False, default="fedavg")
9895
parser.add_argument("--model", choices=["8m", "650m", "3b"], help="ESM2 model", required=False, default="8m")
9996
parser.add_argument(

examples/advanced/bionemo/downstream/tap/run_sim_tap.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from nvflare import FilterType
2222
from nvflare.app_common.launchers.subprocess_launcher import SubprocessLauncher
23+
from nvflare.app_common.widgets.decomposer_reg import DecomposerRegister
2324
from nvflare.app_common.workflows.fedavg import FedAvg
2425
from nvflare.app_opt.pt.job_config.base_fed_job import BaseFedJob
2526
from nvflare.job_config.script_runner import BaseScriptRunner
@@ -38,6 +39,7 @@ def main(args):
3839
num_rounds=args.num_rounds,
3940
)
4041
job.to_server(controller)
42+
job.to_server(DecomposerRegister(["nvflare.app_opt.pt.decomposers.TensorDecomposer"]))
4143

4244
checkpoint_path = load(f"esm2/{args.model}:2.0")
4345
print(f"Downloaded {args.model} to {checkpoint_path}")
@@ -85,6 +87,7 @@ def main(args):
8587
BioNeMoParamsFilter(precision), client_name, tasks=["train", "validate"], filter_type=FilterType.TASK_DATA
8688
)
8789
job.to(BioNeMoStateDictFilter(), client_name, tasks=["train", "validate"], filter_type=FilterType.TASK_RESULT)
90+
job.to(DecomposerRegister(["nvflare.app_opt.pt.decomposers.TensorDecomposer"]), client_name)
8891
job.to(
8992
BioNeMoExcludeParamsFilter(exclude_vars="regression_head"),
9093
client_name,

examples/tutorials/self-paced-training/part-5_federated_learning_applications_in_industries/chapter-11_federated_learning_in_healthcare_lifescience/11.2_drug_discovery/11.2.1_drug_discovery_bionemo/protein_property_prediction_with_bionemo.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
"cell_type": "code",
3737
"execution_count": null,
3838
"id": "b4ab20c8",
39-
"metadata": {},
39+
"metadata": {
40+
"scrolled": true
41+
},
4042
"outputs": [],
4143
"source": [
4244
"%%capture --no-display --no-stderr cell_output\n",
43-
"! pip install nvflare>=2.6\n",
45+
"! pip install \"nvflare~=2.7.0rc\"\n",
4446
"! pip install biopython --no-dependencies\n",
4547
"\n",
4648
"import io\n",
@@ -242,7 +244,7 @@
242244
"metadata": {},
243245
"outputs": [],
244246
"source": [
245-
"# for this to work run the task_fitting notebook first in ../nvflare_with_bionemo/task_fitting/task_fitting.ipynb in order to download the SCL dataset, each client will run on the same GPU.\n",
247+
"# Each client will run on the same GPU.\n",
246248
"!python run_sim_scl.py --num_clients=3 --num_rounds=1 --local_steps=5000 --exp_name \"local\" --model \"8m\" --sim_gpus=\"0\""
247249
]
248250
},

examples/tutorials/self-paced-training/part-5_federated_learning_applications_in_industries/chapter-11_federated_learning_in_healthcare_lifescience/11.2_drug_discovery/11.2.1_drug_discovery_bionemo/run_sim_scl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from nvflare import FilterType
2121
from nvflare.app_common.launchers.subprocess_launcher import SubprocessLauncher
22+
from nvflare.app_common.widgets.decomposer_reg import DecomposerRegister
2223
from nvflare.app_common.workflows.fedavg import FedAvg
2324
from nvflare.app_opt.pt.job_config.base_fed_job import BaseFedJob
2425
from nvflare.job_config.script_runner import BaseScriptRunner
@@ -34,6 +35,7 @@ def main(args):
3435
num_rounds=args.num_rounds,
3536
)
3637
job.to_server(controller)
38+
job.to_server(DecomposerRegister(["nvflare.app_opt.pt.decomposers.TensorDecomposer"]))
3739

3840
checkpoint_path = load(f"esm2/{args.model}:2.0")
3941
print(f"Downloaded {args.model} to {checkpoint_path}")
@@ -77,6 +79,7 @@ def main(args):
7779
BioNeMoParamsFilter(precision), client_name, tasks=["train", "validate"], filter_type=FilterType.TASK_DATA
7880
)
7981
job.to(BioNeMoStateDictFilter(), client_name, tasks=["train", "validate"], filter_type=FilterType.TASK_RESULT)
82+
job.to(DecomposerRegister(["nvflare.app_opt.pt.decomposers.TensorDecomposer"]), client_name)
8083

8184
job.export_job("./exported_jobs")
8285
job.simulator_run(f"/tmp/nvflare/bionemo/scl/{job.name}", gpu=args.sim_gpus)

0 commit comments

Comments
 (0)