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

[TestFailure] Resolving exceptions thrown across multiple GraphBolt tests. #7852

Merged
merged 7 commits into from
Jan 8, 2025
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: 4 additions & 2 deletions dglgo/dglgo/apply_pipeline/graphpred/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def config(
cpt: str = typer.Option(..., help="input checkpoint file path"),
):
# Training configuration
train_cfg = torch.load(cpt)["cfg"]
train_cfg = torch.load(cpt, weights_only=False)["cfg"]
if data is None:
print("data is not specified, use the training dataset")
data = train_cfg["data_name"]
Expand Down Expand Up @@ -119,7 +119,9 @@ def gen_script(cls, user_cfg_dict):
cls.user_cfg_cls(**user_cfg_dict)

# Training configuration
train_cfg = torch.load(user_cfg_dict["cpt_path"])["cfg"]
train_cfg = torch.load(user_cfg_dict["cpt_path"], weights_only=False)[
"cfg"
]

# Dict for code rendering
render_cfg = deepcopy(user_cfg_dict)
Expand Down
2 changes: 1 addition & 1 deletion dglgo/dglgo/apply_pipeline/graphpred/graphpred.jinja-py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def main():
data to have the same number of input edge features, got {:d} and {:d}'.format(model_edge_feat_size, data_edge_feat_size)

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

# Dump the results
Expand Down
6 changes: 4 additions & 2 deletions dglgo/dglgo/apply_pipeline/nodepred/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def config(
cpt: str = typer.Option(..., help="input checkpoint file path"),
):
# Training configuration
train_cfg = torch.load(cpt)["cfg"]
train_cfg = torch.load(cpt, weights_only=False)["cfg"]
if data is None:
print("data is not specified, use the training dataset")
data = train_cfg["data_name"]
Expand Down Expand Up @@ -101,7 +101,9 @@ def gen_script(cls, user_cfg_dict):
cls.user_cfg_cls(**user_cfg_dict)

# Training configuration
train_cfg = torch.load(user_cfg_dict["cpt_path"])["cfg"]
train_cfg = torch.load(user_cfg_dict["cpt_path"], weights_only=False)[
"cfg"
]

# Dict for code rendering
render_cfg = deepcopy(user_cfg_dict)
Expand Down
2 changes: 1 addition & 1 deletion dglgo/dglgo/apply_pipeline/nodepred/nodepred.jinja-py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def main():
features, got {:d} and {:d}'.format(model_in_size, data_in_size)

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

Expand Down
6 changes: 4 additions & 2 deletions dglgo/dglgo/apply_pipeline/nodepred_sample/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def config(
cpt: str = typer.Option(..., help="input checkpoint file path"),
):
# Training configuration
train_cfg = torch.load(cpt)["cfg"]
train_cfg = torch.load(cpt, weights_only=False)["cfg"]
if data is None:
print("data is not specified, use the training dataset")
data = train_cfg["data_name"]
Expand Down Expand Up @@ -101,7 +101,9 @@ def gen_script(cls, user_cfg_dict):
cls.user_cfg_cls(**user_cfg_dict)

# Training configuration
train_cfg = torch.load(user_cfg_dict["cpt_path"])["cfg"]
train_cfg = torch.load(user_cfg_dict["cpt_path"], weights_only=False)[
"cfg"
]

# Dict for code rendering
render_cfg = deepcopy(user_cfg_dict)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def main():
features, got {:d} and {:d}'.format(model_in_size, data_in_size)

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

Expand Down
2 changes: 1 addition & 1 deletion dglgo/dglgo/pipeline/graphpred/graphpred.jinja-py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def main(run, cfg, data):
else:
lr_scheduler.step()

model.load_state_dict(torch.load(tmp_cpt_path))
model.load_state_dict(torch.load(tmp_cpt_path, weights_only=False))
os.remove(tmp_cpt_path)
test_metric = evaluate(device, test_loader, model)
print('Test Metric: {:.4f}'.format(test_metric))
Expand Down
2 changes: 1 addition & 1 deletion dglgo/dglgo/pipeline/nodepred/nodepred.jinja-py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class EarlyStopping:
torch.save(model.state_dict(), self.checkpoint_path)

def load_checkpoint(self, model):
model.load_state_dict(torch.load(self.checkpoint_path))
model.load_state_dict(torch.load(self.checkpoint_path, weights_only=False))

def close(self):
os.remove(self.checkpoint_path)
Expand Down
2 changes: 1 addition & 1 deletion dglgo/dglgo/pipeline/nodepred_sample/nodepred-ns.jinja-py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class EarlyStopping:
torch.save(model.state_dict(), self.checkpoint_path)

def load_checkpoint(self, model):
model.load_state_dict(torch.load(self.checkpoint_path))
model.load_state_dict(torch.load(self.checkpoint_path, weights_only=False))

def close(self):
os.remove(self.checkpoint_path)
Expand Down
4 changes: 3 additions & 1 deletion dglgo/dglgo/utils/early_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ def save_checkpoint(self, model):
torch.save(model.state_dict(), self.checkpoint_path)

def load_checkpoint(self, model):
model.load_state_dict(torch.load(self.checkpoint_path))
model.load_state_dict(
torch.load(self.checkpoint_path, weights_only=False)
)
4 changes: 3 additions & 1 deletion examples/pytorch/GNN-FiLM/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ def main(args):
model.eval()
test_loss = []
test_f1 = []
model.load_state_dict(torch.load(os.path.join(args.save_dir, args.name)))
model.load_state_dict(
torch.load(os.path.join(args.save_dir, args.name), weights_only=False)
)
with torch.no_grad():
for batch in test_set:
g = batch.graph
Expand Down
4 changes: 3 additions & 1 deletion examples/pytorch/TAHIN/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def main(args):
# test use the best model
model.eval()
with torch.no_grad():
model.load_state_dict(torch.load("TAHIN" + "_" + args.dataset))
model.load_state_dict(
torch.load("TAHIN" + "_" + args.dataset, weights_only=False)
)
test_loss = []
test_acc = []
test_auc = []
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/argo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def train(

PATH = "model.pt"
if counter[0] != 0:
checkpoint = torch.load(PATH)
checkpoint = torch.load(PATH, weights_only=False)
model.load_state_dict(checkpoint["model_state_dict"])
opt.load_state_dict(checkpoint["optimizer_state_dict"])
epoch = checkpoint["epoch"]
Expand Down
4 changes: 3 additions & 1 deletion examples/pytorch/correct_and_smooth/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def main():
if args.pretrain:
print("---------- Before ----------")
model.load_state_dict(
torch.load(f"base/{args.dataset}-{args.model}.pt")
torch.load(
f"base/{args.dataset}-{args.model}.pt", weights_only=False
)
)
model.eval()

Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/dgi/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def main(args):

# train classifier
print("Loading {}th epoch".format(best_t))
dgi.load_state_dict(torch.load("best_dgi.pkl"))
dgi.load_state_dict(torch.load("best_dgi.pkl", weights_only=False))
embeds = dgi.encoder(features, corrupt=False)
embeds = embeds.detach()
mean = 0
Expand Down
6 changes: 4 additions & 2 deletions examples/pytorch/diffpool/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ def graph_classify_task(prog_args):
+ "/"
+ prog_args.dataset
+ "/model.iter-"
+ str(prog_args.load_epoch)
+ str(prog_args.load_epoch),
weights_only=False,
)
)

Expand Down Expand Up @@ -334,7 +335,8 @@ def evaluate(dataloader, model, prog_args, logger=None):
+ "/"
+ prog_args.dataset
+ "/model.iter-"
+ str(logger["best_epoch"])
+ str(logger["best_epoch"]),
weights_only=False,
)
)
model.eval()
Expand Down
4 changes: 3 additions & 1 deletion examples/pytorch/dimenet/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ def main(model_cnf):
if pretrain_params["flag"]:
torch_path = pretrain_params["path"]
target = model_params["targets"][0]
model.load_state_dict(torch.load(f"{torch_path}/{target}.pt"))
model.load_state_dict(
torch.load(f"{torch_path}/{target}.pt", weights_only=False)
)

logger.info("Testing with Pretrained model")
predictions, labels = evaluate(device, model, test_loader)
Expand Down
4 changes: 3 additions & 1 deletion examples/pytorch/gatv2/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ def main(args):

print()
if args.early_stop:
model.load_state_dict(torch.load("es_checkpoint.pt"))
model.load_state_dict(
torch.load("es_checkpoint.pt", weights_only=False)
)
acc = evaluate(g, model, features, labels, test_mask)
print("Test Accuracy {:.4f}".format(acc))

Expand Down
5 changes: 4 additions & 1 deletion examples/pytorch/graphsaint/train_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ def main(args, task):
# test
if args.use_val:
model.load_state_dict(
torch.load(os.path.join(log_dir, "best_model_{}.pkl".format(task)))
torch.load(
os.path.join(log_dir, "best_model_{}.pkl".format(task)),
weights_only=False,
)
)
if cpu_flag and cuda:
model = model.to("cpu")
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/graphwriter/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def main(args):
model = GraphWriter(args)
model.to(args.device)
if args.test:
model = torch.load(args.save_model)
model = torch.load(args.save_model, weights_only=False)
model.args = args
print(model)
test(model, test_dataloader, args)
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/han/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,4 +304,4 @@ def save_checkpoint(self, model):

def load_checkpoint(self, model):
"""Load the latest checkpoint."""
model.load_state_dict(torch.load(self.filename))
model.load_state_dict(torch.load(self.filename, weights_only=False))
4 changes: 3 additions & 1 deletion examples/pytorch/hardgat/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def main(args):

print()
if args.early_stop:
model.load_state_dict(torch.load("es_checkpoint.pt"))
model.load_state_dict(
torch.load("es_checkpoint.pt", weights_only=False)
)
acc = evaluate(model, features, labels, test_mask)
print("Test Accuracy {:.4f}".format(acc))

Expand Down
4 changes: 3 additions & 1 deletion examples/pytorch/hilander/PSS/Smooth_AP/src/netlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def networkselect(opt):
raise Exception("Network {} not available!".format(opt.arch))

if opt.resume:
weights = torch.load(os.path.join(opt.save_path, opt.resume))
weights = torch.load(
os.path.join(opt.save_path, opt.resume), weights_only=False
)
weights_state_dict = weights["state_dict"]

if torch.cuda.device_count() > 1:
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/hilander/PSS/test_subg_inat.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
use_cluster_feat=args.use_cluster_feat,
use_focal_loss=args.use_focal_loss,
)
model.load_state_dict(torch.load(args.model_filename))
model.load_state_dict(torch.load(args.model_filename, weights_only=False))
model = model.to(device)
model.eval()

Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/hilander/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
use_cluster_feat=args.use_cluster_feat,
use_focal_loss=args.use_focal_loss,
)
model.load_state_dict(torch.load(args.model_filename))
model.load_state_dict(torch.load(args.model_filename, weights_only=False))
model = model.to(device)
model.eval()

Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/hilander/test_subg.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
use_cluster_feat=args.use_cluster_feat,
use_focal_loss=args.use_focal_loss,
)
model.load_state_dict(torch.load(args.model_filename))
model.load_state_dict(torch.load(args.model_filename, weights_only=False))
model = model.to(device)
model.eval()

Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/jtnn/vaetrain_dgl.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def worker_init_fn(id_):
model = DGLJTNNVAE(vocab, hidden_size, latent_size, depth)

if opts.model_path is not None:
model.load_state_dict(torch.load(opts.model_path))
model.load_state_dict(torch.load(opts.model_path, weights_only=False))
else:
for param in model.parameters():
if param.dim() == 1:
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/lda/lda_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,6 @@ def doc_subgraph(G, doc_ids):
with io.BytesIO() as f:
model.save(f)
f.seek(0)
print(torch.load(f))
print(torch.load(f, weights_only=False))

print("Testing LatentDirichletAllocation passed!")
8 changes: 6 additions & 2 deletions examples/pytorch/ogb/ngnn_seal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,12 @@ def print_log(*x, sep="\n", end="\n", mode="a"):
args.res_dir,
f"run{run+1}_optimizer_checkpoint{epoch}.pth",
)
model.load_state_dict(torch.load(model_name))
optimizer.load_state_dict(torch.load(optimizer_name))
model.load_state_dict(
torch.load(model_name, weights_only=False)
)
optimizer.load_state_dict(
torch.load(optimizer_name, weights_only=False)
)
tested[epoch] = (
test(final_val_loader, dataset.eval_metric)[
dataset.eval_metric
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/ogb/ogbn-arxiv/correct_and_smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def main():

for pred_file in glob.iglob(args.pred_files):
print("load:", pred_file)
pred = torch.load(pred_file)
pred = torch.load(pred_file, weights_only=False)
val_acc, test_acc = run(
args, graph, labels, pred, train_idx, val_idx, test_idx, evaluator
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def main(args):
if num_patient_epochs == args["patience"]:
break

model.load_state_dict(torch.load(model_path))
model.load_state_dict(torch.load(model_path, weights_only=False))
train_score, val_score, test_score = run_an_eval_epoch(
graph, splitted_idx, model, evaluator
)
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/ogb_lsc/MAG240M/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test(args, dataset, g, feats, paper_offset):
0.5,
"paper",
).cuda()
model.load_state_dict(torch.load(args.model_path))
model.load_state_dict(torch.load(args.model_path, weights_only=False))

model.eval()
correct = total = 0
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/ogb_lsc/MAG240M/train_multi_gpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def test(args, dataset, g, feats, paper_offset):
).cuda()

# load ddp's model parameters, we need to remove the name of 'module.'
state_dict = torch.load(args.model_path)
state_dict = torch.load(args.model_path, weights_only=False)
new_state_dict = OrderedDict()
for k, v in state_dict.items():
name = k[7:]
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/ogb_lsc/PCQM4M/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def main():
raise RuntimeError(f"Checkpoint file not found at {checkpoint_path}")

## reading in checkpoint
checkpoint = torch.load(checkpoint_path)
checkpoint = torch.load(checkpoint_path, weights_only=False)
model.load_state_dict(checkpoint["model_state_dict"])

print("Predicting on test data...")
Expand Down
4 changes: 3 additions & 1 deletion examples/pytorch/pointcloud/bipointnet/train_cls.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ def evaluate(net, test_loader, dev):

net = net.to(dev)
if args.load_model_path:
net.load_state_dict(torch.load(args.load_model_path, map_location=dev))
net.load_state_dict(
torch.load(args.load_model_path, weights_only=False, map_location=dev)
)

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

Expand Down
4 changes: 3 additions & 1 deletion examples/pytorch/pointcloud/edgeconv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ def evaluate(model, test_loader, dev):
model = Model(20, [64, 64, 128, 256], [512, 512, 256], 40)
model = model.to(dev)
if args.load_model_path:
model.load_state_dict(torch.load(args.load_model_path, map_location=dev))
model.load_state_dict(
torch.load(args.load_model_path, weights_only=False, map_location=dev)
)

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

Expand Down
Loading
Loading