Add opt-in PyTorch Auto-SCAFFOLD mode#4642
Conversation
|
@greptileai review |
Greptile SummaryThis PR introduces an opt-in Auto-SCAFFOLD mode for PyTorch, letting existing FedAvg-style Client API scripts participate in SCAFFOLD without manually instrumenting control-variate code. It also threads a generic
Confidence Score: 5/5The change is safe to merge; the new Auto-SCAFFOLD path is opt-in and the default behaviour (auto_scaffold=False) is completely unchanged. All three issues raised in the previous review round have been addressed with thread-local state, a shared constants module, and a first-step LR check that raises on change. The plumbing additions are additive and backward-compatible. The single remaining nit (a dead _last_lr assignment) has no effect on correctness. No files require special attention; the core logic is in scaffold_auto_patch.py which has thorough test coverage. Important Files Changed
Reviews (2): Last reviewed commit: "Address Auto-SCAFFOLD review feedback" | Re-trigger Greptile |
|
Follow-up pushed in
Validation run:
|
|
@greptileai review again |
|
Closing this draft as superseded by #4838. We decided not to pursue process-wide PyTorch monkey-patching for arbitrary Client API scripts. Inferring the SCAFFOLD protocol from #4838 provides the supported automatic path through |
Summary
auto_scaffold=Truefor PyTorchScaffoldRecipeto support standard FedAvg-style Client API scripts.scaffold_c_diffon send.task_exchange_configplumbing through ScriptRunner/client executors, plus docs and recipe/example guidance.Validation
python3 -m pytest tests/unit_test/app_opt/pt/scaffold_auto_patch_test.py tests/unit_test/recipe/scaffold_recipe_test.py -qpython3 -m pytest tests/unit_test/job_config/script_runner_test.py tests/unit_test/app_common/executors/task_script_runner_test.py -qpython3 -m py_compile nvflare/app_opt/pt/scaffold_auto_patch.py nvflare/app_opt/pt/recipes/scaffold.py nvflare/job_config/script_runner.py nvflare/client/in_process/api.py nvflare/client/ex_process/api.py tests/unit_test/app_opt/pt/scaffold_auto_patch_test.pygit diff --check