Skip to content

Commit 540dd2b

Browse files
authored
[TestFailure] Resolving exceptions thrown across multiple GraphBolt tests. (#7852)
1 parent 275183b commit 540dd2b

File tree

53 files changed

+301
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+301
-248
lines changed

dglgo/dglgo/apply_pipeline/graphpred/gen.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def config(
6363
cpt: str = typer.Option(..., help="input checkpoint file path"),
6464
):
6565
# Training configuration
66-
train_cfg = torch.load(cpt)["cfg"]
66+
train_cfg = torch.load(cpt, weights_only=False)["cfg"]
6767
if data is None:
6868
print("data is not specified, use the training dataset")
6969
data = train_cfg["data_name"]
@@ -119,7 +119,9 @@ def gen_script(cls, user_cfg_dict):
119119
cls.user_cfg_cls(**user_cfg_dict)
120120

121121
# Training configuration
122-
train_cfg = torch.load(user_cfg_dict["cpt_path"])["cfg"]
122+
train_cfg = torch.load(user_cfg_dict["cpt_path"], weights_only=False)[
123+
"cfg"
124+
]
123125

124126
# Dict for code rendering
125127
render_cfg = deepcopy(user_cfg_dict)

dglgo/dglgo/apply_pipeline/graphpred/graphpred.jinja-py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def main():
5757
data to have the same number of input edge features, got {:d} and {:d}'.format(model_edge_feat_size, data_edge_feat_size)
5858

5959
model = {{ model_class_name }}(**cfg['model'])
60-
model.load_state_dict(torch.load(cfg['cpt_path'], map_location='cpu')['model'])
60+
model.load_state_dict(torch.load(cfg['cpt_path'], weights_only=False, map_location='cpu')['model'])
6161
pred = infer(device, data_loader, model).detach().cpu()
6262

6363
# Dump the results

dglgo/dglgo/apply_pipeline/nodepred/gen.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def config(
4848
cpt: str = typer.Option(..., help="input checkpoint file path"),
4949
):
5050
# Training configuration
51-
train_cfg = torch.load(cpt)["cfg"]
51+
train_cfg = torch.load(cpt, weights_only=False)["cfg"]
5252
if data is None:
5353
print("data is not specified, use the training dataset")
5454
data = train_cfg["data_name"]
@@ -101,7 +101,9 @@ def gen_script(cls, user_cfg_dict):
101101
cls.user_cfg_cls(**user_cfg_dict)
102102

103103
# Training configuration
104-
train_cfg = torch.load(user_cfg_dict["cpt_path"])["cfg"]
104+
train_cfg = torch.load(user_cfg_dict["cpt_path"], weights_only=False)[
105+
"cfg"
106+
]
105107

106108
# Dict for code rendering
107109
render_cfg = deepcopy(user_cfg_dict)

dglgo/dglgo/apply_pipeline/nodepred/nodepred.jinja-py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def main():
4848
features, got {:d} and {:d}'.format(model_in_size, data_in_size)
4949

5050
model = {{ model_class_name }}(**cfg['model'])
51-
model.load_state_dict(torch.load(cfg['cpt_path'], map_location='cpu')['model'])
51+
model.load_state_dict(torch.load(cfg['cpt_path'], weights_only=False, map_location='cpu')['model'])
5252
logits = infer(device, data, model)
5353
pred = logits.argmax(dim=1).cpu()
5454

dglgo/dglgo/apply_pipeline/nodepred_sample/gen.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def config(
4848
cpt: str = typer.Option(..., help="input checkpoint file path"),
4949
):
5050
# Training configuration
51-
train_cfg = torch.load(cpt)["cfg"]
51+
train_cfg = torch.load(cpt, weights_only=False)["cfg"]
5252
if data is None:
5353
print("data is not specified, use the training dataset")
5454
data = train_cfg["data_name"]
@@ -101,7 +101,9 @@ def gen_script(cls, user_cfg_dict):
101101
cls.user_cfg_cls(**user_cfg_dict)
102102

103103
# Training configuration
104-
train_cfg = torch.load(user_cfg_dict["cpt_path"])["cfg"]
104+
train_cfg = torch.load(user_cfg_dict["cpt_path"], weights_only=False)[
105+
"cfg"
106+
]
105107

106108
# Dict for code rendering
107109
render_cfg = deepcopy(user_cfg_dict)

dglgo/dglgo/apply_pipeline/nodepred_sample/nodepred-ns.jinja-py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def main():
4848
features, got {:d} and {:d}'.format(model_in_size, data_in_size)
4949

5050
model = {{ model_class_name }}(**cfg['model'])
51-
model.load_state_dict(torch.load(cfg['cpt_path'], map_location='cpu')['model'])
51+
model.load_state_dict(torch.load(cfg['cpt_path'], weights_only=False, map_location='cpu')['model'])
5252
logits = infer(device, data, model)
5353
pred = logits.argmax(dim=1).cpu()
5454

dglgo/dglgo/pipeline/graphpred/graphpred.jinja-py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def main(run, cfg, data):
101101
else:
102102
lr_scheduler.step()
103103

104-
model.load_state_dict(torch.load(tmp_cpt_path))
104+
model.load_state_dict(torch.load(tmp_cpt_path, weights_only=False))
105105
os.remove(tmp_cpt_path)
106106
test_metric = evaluate(device, test_loader, model)
107107
print('Test Metric: {:.4f}'.format(test_metric))

dglgo/dglgo/pipeline/nodepred/nodepred.jinja-py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class EarlyStopping:
4242
torch.save(model.state_dict(), self.checkpoint_path)
4343

4444
def load_checkpoint(self, model):
45-
model.load_state_dict(torch.load(self.checkpoint_path))
45+
model.load_state_dict(torch.load(self.checkpoint_path, weights_only=False))
4646

4747
def close(self):
4848
os.remove(self.checkpoint_path)

dglgo/dglgo/pipeline/nodepred_sample/nodepred-ns.jinja-py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class EarlyStopping:
4242
torch.save(model.state_dict(), self.checkpoint_path)
4343

4444
def load_checkpoint(self, model):
45-
model.load_state_dict(torch.load(self.checkpoint_path))
45+
model.load_state_dict(torch.load(self.checkpoint_path, weights_only=False))
4646

4747
def close(self):
4848
os.remove(self.checkpoint_path)

dglgo/dglgo/utils/early_stop.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ def save_checkpoint(self, model):
3434
torch.save(model.state_dict(), self.checkpoint_path)
3535

3636
def load_checkpoint(self, model):
37-
model.load_state_dict(torch.load(self.checkpoint_path))
37+
model.load_state_dict(
38+
torch.load(self.checkpoint_path, weights_only=False)
39+
)

examples/pytorch/GNN-FiLM/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ def main(args):
194194
model.eval()
195195
test_loss = []
196196
test_f1 = []
197-
model.load_state_dict(torch.load(os.path.join(args.save_dir, args.name)))
197+
model.load_state_dict(
198+
torch.load(os.path.join(args.save_dir, args.name), weights_only=False)
199+
)
198200
with torch.no_grad():
199201
for batch in test_set:
200202
g = batch.graph

examples/pytorch/TAHIN/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ def main(args):
111111
# test use the best model
112112
model.eval()
113113
with torch.no_grad():
114-
model.load_state_dict(torch.load("TAHIN" + "_" + args.dataset))
114+
model.load_state_dict(
115+
torch.load("TAHIN" + "_" + args.dataset, weights_only=False)
116+
)
115117
test_loss = []
116118
test_acc = []
117119
test_auc = []

examples/pytorch/argo/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def train(
180180

181181
PATH = "model.pt"
182182
if counter[0] != 0:
183-
checkpoint = torch.load(PATH)
183+
checkpoint = torch.load(PATH, weights_only=False)
184184
model.load_state_dict(checkpoint["model_state_dict"])
185185
opt.load_state_dict(checkpoint["optimizer_state_dict"])
186186
epoch = checkpoint["epoch"]

examples/pytorch/correct_and_smooth/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def main():
6666
if args.pretrain:
6767
print("---------- Before ----------")
6868
model.load_state_dict(
69-
torch.load(f"base/{args.dataset}-{args.model}.pt")
69+
torch.load(
70+
f"base/{args.dataset}-{args.model}.pt", weights_only=False
71+
)
7072
)
7173
model.eval()
7274

examples/pytorch/dgi/train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def main(args):
126126

127127
# train classifier
128128
print("Loading {}th epoch".format(best_t))
129-
dgi.load_state_dict(torch.load("best_dgi.pkl"))
129+
dgi.load_state_dict(torch.load("best_dgi.pkl", weights_only=False))
130130
embeds = dgi.encoder(features, corrupt=False)
131131
embeds = embeds.detach()
132132
mean = 0

examples/pytorch/diffpool/train.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ def graph_classify_task(prog_args):
223223
+ "/"
224224
+ prog_args.dataset
225225
+ "/model.iter-"
226-
+ str(prog_args.load_epoch)
226+
+ str(prog_args.load_epoch),
227+
weights_only=False,
227228
)
228229
)
229230

@@ -334,7 +335,8 @@ def evaluate(dataloader, model, prog_args, logger=None):
334335
+ "/"
335336
+ prog_args.dataset
336337
+ "/model.iter-"
337-
+ str(logger["best_epoch"])
338+
+ str(logger["best_epoch"]),
339+
weights_only=False,
338340
)
339341
)
340342
model.eval()

examples/pytorch/dimenet/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ def main(model_cnf):
238238
if pretrain_params["flag"]:
239239
torch_path = pretrain_params["path"]
240240
target = model_params["targets"][0]
241-
model.load_state_dict(torch.load(f"{torch_path}/{target}.pt"))
241+
model.load_state_dict(
242+
torch.load(f"{torch_path}/{target}.pt", weights_only=False)
243+
)
242244

243245
logger.info("Testing with Pretrained model")
244246
predictions, labels = evaluate(device, model, test_loader)

examples/pytorch/gatv2/train.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ def main(args):
178178

179179
print()
180180
if args.early_stop:
181-
model.load_state_dict(torch.load("es_checkpoint.pt"))
181+
model.load_state_dict(
182+
torch.load("es_checkpoint.pt", weights_only=False)
183+
)
182184
acc = evaluate(g, model, features, labels, test_mask)
183185
print("Test Accuracy {:.4f}".format(acc))
184186

examples/pytorch/graphsaint/train_sampling.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ def main(args, task):
214214
# test
215215
if args.use_val:
216216
model.load_state_dict(
217-
torch.load(os.path.join(log_dir, "best_model_{}.pkl".format(task)))
217+
torch.load(
218+
os.path.join(log_dir, "best_model_{}.pkl".format(task)),
219+
weights_only=False,
220+
)
218221
)
219222
if cpu_flag and cuda:
220223
model = model.to("cpu")

examples/pytorch/graphwriter/train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def main(args):
161161
model = GraphWriter(args)
162162
model.to(args.device)
163163
if args.test:
164-
model = torch.load(args.save_model)
164+
model = torch.load(args.save_model, weights_only=False)
165165
model.args = args
166166
print(model)
167167
test(model, test_dataloader, args)

examples/pytorch/han/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,4 @@ def save_checkpoint(self, model):
304304

305305
def load_checkpoint(self, model):
306306
"""Load the latest checkpoint."""
307-
model.load_state_dict(torch.load(self.filename))
307+
model.load_state_dict(torch.load(self.filename, weights_only=False))

examples/pytorch/hardgat/train.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ def main(args):
154154

155155
print()
156156
if args.early_stop:
157-
model.load_state_dict(torch.load("es_checkpoint.pt"))
157+
model.load_state_dict(
158+
torch.load("es_checkpoint.pt", weights_only=False)
159+
)
158160
acc = evaluate(model, features, labels, test_mask)
159161
print("Test Accuracy {:.4f}".format(acc))
160162

examples/pytorch/hilander/PSS/Smooth_AP/src/netlib.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ def networkselect(opt):
7171
raise Exception("Network {} not available!".format(opt.arch))
7272

7373
if opt.resume:
74-
weights = torch.load(os.path.join(opt.save_path, opt.resume))
74+
weights = torch.load(
75+
os.path.join(opt.save_path, opt.resume), weights_only=False
76+
)
7577
weights_state_dict = weights["state_dict"]
7678

7779
if torch.cuda.device_count() > 1:

examples/pytorch/hilander/PSS/test_subg_inat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
use_cluster_feat=args.use_cluster_feat,
174174
use_focal_loss=args.use_focal_loss,
175175
)
176-
model.load_state_dict(torch.load(args.model_filename))
176+
model.load_state_dict(torch.load(args.model_filename, weights_only=False))
177177
model = model.to(device)
178178
model.eval()
179179

examples/pytorch/hilander/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
use_cluster_feat=args.use_cluster_feat,
8484
use_focal_loss=args.use_focal_loss,
8585
)
86-
model.load_state_dict(torch.load(args.model_filename))
86+
model.load_state_dict(torch.load(args.model_filename, weights_only=False))
8787
model = model.to(device)
8888
model.eval()
8989

examples/pytorch/hilander/test_subg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
use_cluster_feat=args.use_cluster_feat,
105105
use_focal_loss=args.use_focal_loss,
106106
)
107-
model.load_state_dict(torch.load(args.model_filename))
107+
model.load_state_dict(torch.load(args.model_filename, weights_only=False))
108108
model = model.to(device)
109109
model.eval()
110110

examples/pytorch/jtnn/vaetrain_dgl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def worker_init_fn(id_):
5454
model = DGLJTNNVAE(vocab, hidden_size, latent_size, depth)
5555

5656
if opts.model_path is not None:
57-
model.load_state_dict(torch.load(opts.model_path))
57+
model.load_state_dict(torch.load(opts.model_path, weights_only=False))
5858
else:
5959
for param in model.parameters():
6060
if param.dim() == 1:

examples/pytorch/lda/lda_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,6 @@ def doc_subgraph(G, doc_ids):
496496
with io.BytesIO() as f:
497497
model.save(f)
498498
f.seek(0)
499-
print(torch.load(f))
499+
print(torch.load(f, weights_only=False))
500500

501501
print("Testing LatentDirichletAllocation passed!")

examples/pytorch/ogb/ngnn_seal/main.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,12 @@ def print_log(*x, sep="\n", end="\n", mode="a"):
625625
args.res_dir,
626626
f"run{run+1}_optimizer_checkpoint{epoch}.pth",
627627
)
628-
model.load_state_dict(torch.load(model_name))
629-
optimizer.load_state_dict(torch.load(optimizer_name))
628+
model.load_state_dict(
629+
torch.load(model_name, weights_only=False)
630+
)
631+
optimizer.load_state_dict(
632+
torch.load(optimizer_name, weights_only=False)
633+
)
630634
tested[epoch] = (
631635
test(final_val_loader, dataset.eval_metric)[
632636
dataset.eval_metric

examples/pytorch/ogb/ogbn-arxiv/correct_and_smooth.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def main():
179179

180180
for pred_file in glob.iglob(args.pred_files):
181181
print("load:", pred_file)
182-
pred = torch.load(pred_file)
182+
pred = torch.load(pred_file, weights_only=False)
183183
val_acc, test_acc = run(
184184
args, graph, labels, pred, train_idx, val_idx, test_idx, evaluator
185185
)

examples/pytorch/ogb/ogbn-proteins/main_proteins_full_dgl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def main(args):
168168
if num_patient_epochs == args["patience"]:
169169
break
170170

171-
model.load_state_dict(torch.load(model_path))
171+
model.load_state_dict(torch.load(model_path, weights_only=False))
172172
train_score, val_score, test_score = run_an_eval_epoch(
173173
graph, splitted_idx, model, evaluator
174174
)

examples/pytorch/ogb_lsc/MAG240M/train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def test(args, dataset, g, feats, paper_offset):
247247
0.5,
248248
"paper",
249249
).cuda()
250-
model.load_state_dict(torch.load(args.model_path))
250+
model.load_state_dict(torch.load(args.model_path, weights_only=False))
251251

252252
model.eval()
253253
correct = total = 0

examples/pytorch/ogb_lsc/MAG240M/train_multi_gpus.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def test(args, dataset, g, feats, paper_offset):
304304
).cuda()
305305

306306
# load ddp's model parameters, we need to remove the name of 'module.'
307-
state_dict = torch.load(args.model_path)
307+
state_dict = torch.load(args.model_path, weights_only=False)
308308
new_state_dict = OrderedDict()
309309
for k, v in state_dict.items():
310310
name = k[7:]

examples/pytorch/ogb_lsc/PCQM4M/test_inference.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def main():
206206
raise RuntimeError(f"Checkpoint file not found at {checkpoint_path}")
207207

208208
## reading in checkpoint
209-
checkpoint = torch.load(checkpoint_path)
209+
checkpoint = torch.load(checkpoint_path, weights_only=False)
210210
model.load_state_dict(checkpoint["model_state_dict"])
211211

212212
print("Predicting on test data...")

examples/pytorch/pointcloud/bipointnet/train_cls.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ def evaluate(net, test_loader, dev):
136136

137137
net = net.to(dev)
138138
if args.load_model_path:
139-
net.load_state_dict(torch.load(args.load_model_path, map_location=dev))
139+
net.load_state_dict(
140+
torch.load(args.load_model_path, weights_only=False, map_location=dev)
141+
)
140142

141143
opt = optim.Adam(net.parameters(), lr=1e-3, weight_decay=1e-4)
142144

examples/pytorch/pointcloud/edgeconv/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ def evaluate(model, test_loader, dev):
115115
model = Model(20, [64, 64, 128, 256], [512, 512, 256], 40)
116116
model = model.to(dev)
117117
if args.load_model_path:
118-
model.load_state_dict(torch.load(args.load_model_path, map_location=dev))
118+
model.load_state_dict(
119+
torch.load(args.load_model_path, weights_only=False, map_location=dev)
120+
)
119121

120122
opt = optim.SGD(model.parameters(), lr=0.1, momentum=0.9, weight_decay=1e-4)
121123

0 commit comments

Comments
 (0)