generated from VectorInstitute/aieng-template
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checkpoint Ablation for Flamby #71
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cdfbdb5
Adding in the ability to shut off federated checkpointing for the fe…
emersodb f141ea7
By default, performing federated checkpointing.
emersodb 0716af3
correcting typo
emersodb a83c491
Getting Fed-IXI ready for checkpoint ablation study.
emersodb ff0808e
Fixing small bug
emersodb f908f29
Actually fixing typo
emersodb f32c0fb
Getting rid of commented out argument as it causes scripting problems.
emersodb c2b4cf2
Defaulting the loss weights to None in FENDA client
emersodb 15b60cd
Fixing busted test
emersodb db1d665
Merge branch 'main' into dbe/checkpoint_ablation_flamby
emersodb 5be60c2
Changing the PR template a bit.
emersodb 55427a7
Merge branch 'main' into dbe/checkpoint_ablation_flamby
emersodb a666f1f
Small black formatting change.
emersodb d0974ec
Fixing the helper comment on the no_federated_checkpointing argument.
emersodb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
# PR Type | ||
[Feature | Fix | Documentation | Other() ] | ||
[Feature | Fix | Documentation | Other ] | ||
|
||
# Short Description | ||
... | ||
|
||
Clickup Ticket(s): Link(s) if applicable. | ||
|
||
Add a short description of what is in this PR. | ||
|
||
# Tests Added | ||
... | ||
|
||
Describe the tests that have been added to ensure the codes correctness, if applicable. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,11 @@ | |
from torch.optim import Optimizer | ||
from torch.utils.data import DataLoader | ||
|
||
from fl4health.checkpointing.checkpointer import BestMetricTorchCheckpointer, TorchCheckpointer | ||
from fl4health.checkpointing.checkpointer import ( | ||
BestMetricTorchCheckpointer, | ||
LatestTorchCheckpointer, | ||
TorchCheckpointer, | ||
) | ||
from fl4health.clients.apfl_client import ApflClient | ||
from fl4health.model_bases.apfl_base import ApflModule | ||
from fl4health.utils.losses import LossMeterType | ||
|
@@ -48,7 +52,7 @@ def __init__( | |
self.alpha_learning_rate = alpha_learning_rate | ||
self.client_number = client_number | ||
|
||
def get_dataloader(self, config: Config) -> Tuple[DataLoader, DataLoader]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Somehow a typo crept into this APFL client |
||
def get_data_loaders(self, config: Config) -> Tuple[DataLoader, DataLoader]: | ||
train_dataset, validation_dataset = construct_fed_ixi_train_val_datasets( | ||
self.client_number, str(self.data_path) | ||
) | ||
|
@@ -111,17 +115,28 @@ def get_criterion(self, config: Config) -> _Loss: | |
parser.add_argument( | ||
"--alpha_learning_rate", action="store", type=float, help="Learning rate for the APFL alpha", default=0.01 | ||
) | ||
parser.add_argument( | ||
"--no_federated_checkpointing", | ||
action="store_true", | ||
help="boolean to indicate whether we're evaluating an APFL model or not, as those model have special args", | ||
emersodb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
args = parser.parse_args() | ||
|
||
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu") | ||
log(INFO, f"Device to be used: {DEVICE}") | ||
log(INFO, f"Server Address: {args.server_address}") | ||
log(INFO, f"Learning Rate: {args.learning_rate}") | ||
log(INFO, f"Alpha Learning Rate: {args.alpha_learning_rate}") | ||
log(INFO, f"Performing Federated Checkpointing: {not args.no_federated_checkpointing}") | ||
|
||
federated_checkpointing = not args.no_federated_checkpointing | ||
checkpoint_dir = os.path.join(args.artifact_dir, args.run_name) | ||
checkpoint_name = f"client_{args.client_number}_best_model.pkl" | ||
checkpointer = BestMetricTorchCheckpointer(checkpoint_dir, checkpoint_name, maximize=False) | ||
checkpointer = ( | ||
BestMetricTorchCheckpointer(checkpoint_dir, checkpoint_name, maximize=False) | ||
if federated_checkpointing | ||
else LatestTorchCheckpointer(checkpoint_dir, checkpoint_name) | ||
) | ||
|
||
client = FedIxiApflClient( | ||
data_path=Path(args.dataset_dir), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are not None, then some of these losses (at least perfcl) are still computed, but just "zeroed" out. This is problematic if you want to use asymmetric latent spaces in a FENDA architecture.