Skip to content
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

Fix --load-checkpoint bug #270

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mlpf/pyg_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def run(rank, world_size, config, args, outdir, logfile):
checkpoint_freq=config["checkpoint_freq"],
)

checkpoint = torch.load(f"{outdir}/best_weights.pth", map_location=torch.device(rank))
model, optimizer = load_checkpoint(checkpoint, model, optimizer)

if args.test:
if config["load"] is None:
# if we don't load, we must have a newly trained model
Expand All @@ -200,9 +203,6 @@ def run(rank, world_size, config, args, outdir, logfile):
else:
outdir = config["load"]

checkpoint = torch.load(f"{outdir}/best_weights.pth", map_location=torch.device(rank))
model, optimizer = load_checkpoint(checkpoint, model, optimizer)

for type_ in config["test_dataset"][config["dataset"]]: # will be "physical", "gun"
batch_size = config["test_dataset"][config["dataset"]][type_]["batch_size"] * config["gpu_batch_multiplier"]
for sample in config["test_dataset"][config["dataset"]][type_]["samples"]:
Expand Down
74 changes: 74 additions & 0 deletions parameters/pyg-cms-physical.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
backend: pytorch

dataset: cms
data_dir:
gpus: "0"
gpu_batch_multiplier: 1
load:
num_epochs: 2
patience: 20
lr: 0.0001
conv_type: gnn_lsh
ntrain:
ntest:
nvalid: 500
num_workers: 0
prefetch_factor:
checkpoint_freq:

model:
gnn_lsh:
conv_type: gnn_lsh
embedding_dim: 512
width: 512
num_convs: 3
dropout: 0.0

gravnet:
conv_type: gravnet
embedding_dim: 512
width: 512
num_convs: 3
k: 16
propagate_dimensions: 32
space_dimensions: 4
dropout: 0.0

attention:
conv_type: attention
embedding_dim: 256
width: 256
num_convs: 3
dropout: 0.0

train_dataset:
cms:
physical:
batch_size: 1
samples:
cms_pf_ttbar:
version: 1.6.0
cms_pf_qcd:
version: 1.6.0
cms_pf_ztt:
version: 1.6.0
cms_pf_qcd_high_pt:
version: 1.6.0
cms_pf_sms_t1tttt:
version: 1.6.0

valid_dataset:
cms:
physical:
batch_size: 1
samples:
cms_pf_qcd_high_pt:
version: 1.6.0

test_dataset:
cms:
physical:
batch_size: 1
samples:
cms_pf_qcd_high_pt:
version: 1.6.0
70 changes: 70 additions & 0 deletions parameters/pyg-cms-small-highqcd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
backend: pytorch

dataset: cms
data_dir:
gpus: "0"
gpu_batch_multiplier: 1
load:
num_epochs: 2
patience: 20
lr: 0.0001
conv_type: gnn_lsh
ntrain:
ntest:
nvalid: 500
num_workers: 0
prefetch_factor:
checkpoint_freq:

model:
gnn_lsh:
conv_type: gnn_lsh
embedding_dim: 512
width: 512
num_convs: 3
dropout: 0.0

gravnet:
conv_type: gravnet
embedding_dim: 512
width: 512
num_convs: 3
k: 16
propagate_dimensions: 32
space_dimensions: 4
dropout: 0.0

attention:
conv_type: attention
embedding_dim: 256
width: 256
num_convs: 3
dropout: 0.0

train_dataset:
cms:
physical:
batch_size: 1
samples:
cms_pf_ttbar:
version: 1.6.0
cms_pf_qcd:
version: 1.6.0
cms_pf_qcd_high_pt:
version: 1.6.0

valid_dataset:
cms:
physical:
batch_size: 1
samples:
cms_pf_qcd_high_pt:
version: 1.6.0

test_dataset:
cms:
physical:
batch_size: 1
samples:
cms_pf_qcd_high_pt:
version: 1.6.0
Loading