Repository: pyg-team/pytorch_geometric
Pull request #9020 (2024-03-05 13:20:42)

Fix macOS ARM tests

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/pyg-team/pytorch_geometric/pull/9020?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team) Report
Attention: Patch coverage is `33.33333%` with `2 lines` in your changes are missing coverage. Please review.
> Project coverage is 89.24%. Comparing base [(`d491f43`)](https://app.codecov.io/gh/pyg-team/pytorch_geometric/commit/d491f4360c15ff730ebf00cb5f6bf10eed16d932?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team) to head [(`e016d42`)](https://app.codecov.io/gh/pyg-team/pytorch_geometric/pull/9020?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team).

> :exclamation: Current head e016d42 differs from pull request most recent head 28fe475. Consider uploading reports for the commit 28fe475 to get more accurate results

| [Files](https://app.codecov.io/gh/pyg-team/pytorch_geometric/pull/9020?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team) | Patch % | Lines |
|---|---|---|
| [...ch\_geometric/transforms/add\_positional\_encoding.py](https://app.codecov.io/gh/pyg-team/pytorch_geometric/pull/9020?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team#diff-dG9yY2hfZ2VvbWV0cmljL3RyYW5zZm9ybXMvYWRkX3Bvc2l0aW9uYWxfZW5jb2RpbmcucHk=) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/pyg-team/pytorch_geometric/pull/9020?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #9020      +/-   ##
==========================================
- Coverage   89.86%   89.24%   -0.63%     
==========================================
  Files         468      468              
  Lines       30048    30044       -4     
==========================================
- Hits        27003    26813     -190     
- Misses       3045     3231     +186     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/pyg-team/pytorch_geometric/pull/9020?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team).


Patch:
diff --git a/examples/distributed/pyg/launch.py b/examples/distributed/pyg/launch.py
index fc1df50fd..8f729928e 100644
--- a/examples/distributed/pyg/launch.py
+++ b/examples/distributed/pyg/launch.py
@@ -249,6 +249,7 @@ def submit_all_jobs(args, udf_command, dry_run=False):
                if len(args.extra_envs) > 0 else cmd)
 
         cmd = cmd[:-1]
+        cmd += " --logging"
         cmd += f" --dataset_root_dir={args.dataset_root_dir}"
         cmd += f" --dataset={args.dataset}"
         cmd += f" --num_nodes={args.num_nodes}"
@@ -259,7 +260,7 @@ def submit_all_jobs(args, udf_command, dry_run=False):
         cmd += f" --batch_size={args.batch_size}"
         cmd += f" --num_workers={args.num_workers}"
         cmd += f" --concurrency={args.concurrency}"
-        cmd += f" --logging --progress_bar --ddp_port={args.ddp_port})"
+        cmd += f" --ddp_port={args.ddp_port})"
         servers_cmd.append(cmd)
 
         if not dry_run:
@@ -399,12 +400,6 @@ def main():
         default=11111,
         help="Port used for PyTorch's DDP communication",
     )
-    parser.add_argument(
-        "--part_config",
-        type=str,
-        required=True,
-        help="File (in workspace) of the partition configuration",
-    )
     parser.add_argument(
         "--ip_config",
         required=True,
diff --git a/examples/distributed/pyg/run_dist.sh b/examples/distributed/pyg/run_dist.sh
index 18e6c4a66..aeadcf43f 100755
--- a/examples/distributed/pyg/run_dist.sh
+++ b/examples/distributed/pyg/run_dist.sh
@@ -1,37 +1,37 @@
 #!/bin/bash
 
-CONDA_ENV=/home/XXX/anaconda3/envs/pyg
 PYG_WORKSPACE=$PWD
-PY_EXEC=${CONDA_ENV}/bin/python
-EXEC_SCRIPT=${PYG_WORKSPACE}/node_ogb_cpu.py
+USER=user
+CONDA_ENV=pygenv
+CONDA_DIR="/home/${USER}/anaconda3"
+PY_EXEC="${CONDA_DIR}/envs/${CONDA_ENV}/bin/python"
+EXEC_SCRIPT="${PYG_WORKSPACE}/node_ogb_cpu.py"
+CMD="cd ${PYG_WORKSPACE}; ${PY_EXEC} ${EXEC_SCRIPT}"
 
 # Node number:
 NUM_NODES=2
 
-# Dataset folder:
-DATASET_ROOT_DIR="/home/XXX/mag/2-parts"
-
 # Dataset name:
-DATASET=ogbn-mag
+DATASET=ogbn-products
+
+# Dataset folder:
+DATASET_ROOT_DIR="../../../data/partitions/${DATASET}/${NUM_NODES}-parts"
 
 # Number of epochs:
-NUM_EPOCHS=3
+NUM_EPOCHS=10
 
 # The batch size:
 BATCH_SIZE=1024
 
+# Fanout per layer:
+NUM_NEIGHBORS="5,5,5"
+
 # Number of workers for sampling:
 NUM_WORKERS=2
-CONCURRENCY=2
-
-# Partition data directory:
-PART_CONFIG="/home/XXX/mag/2-parts/ogbn-products-partitions/META.json"
-NUM_PARTS=2
+CONCURRENCY=4
 
-DDP_PORT=12351
-
-# Fanout per layer:
-NUM_NEIGHBORS="15,10,5"
+# DDP Port
+DDP_PORT=11111
 
 # IP configuration path:
 IP_CONFIG=${PYG_WORKSPACE}/ip_config.yaml
@@ -40,9 +40,14 @@ IP_CONFIG=${PYG_WORKSPACE}/ip_config.yaml
 logdir="logs"
 mkdir -p "logs"
 logname=log_${DATASET}_${NUM_PARTS}_$RANDOM
-echo $logname
+echo "stdout stored in ${PYG_WORKSPACE}/${logdir}/${logname}"
 set -x
 
 # stdout stored in `/logdir/logname.out`.
-python launch.py --workspace "${PYG_WORKSPACE}" --num_nodes ${NUM_NODES} --num_neighbors ${NUM_NEIGHBORS} --dataset_root_dir ${DATASET_ROOT_DIR} --dataset ${DATASET}  --num_epochs ${NUM_EPOCHS} --batch_size ${BATCH_SIZE} --num_workers ${NUM_WORKERS} --concurrency ${CONCURRENCY} --ddp_port ${DDP_PORT} --part_config ${PART_CONFIG} --ip_config "${IP_CONFIG}" "cd /home/XXX; source ${CONDA_ENV}/bin/activate; cd ${PYG_WORKSPACE}; ${PY_EXEC} ${EXEC_SCRIPT}" |& tee ${logdir}/${logname}.txt
+python launch.py --workspace ${PYG_WORKSPACE} --ip_config ${IP_CONFIG} --ssh_username ${USER} --num_nodes ${NUM_NODES} --num_neighbors ${NUM_NEIGHBORS} --dataset_root_dir ${DATASET_ROOT_DIR} --dataset ${DATASET}  --num_epochs ${NUM_EPOCHS} --batch_size ${BATCH_SIZE} --num_workers ${NUM_WORKERS} --concurrency ${CONCURRENCY} --ddp_port ${DDP_PORT} "${CMD}" |& tee ${logdir}/${logname} &
+pid=$!
+echo "started launch.py: ${pid}"
+# kill processes at script exit (Ctrl + C)
+trap "kill -2 $pid" SIGINT
+wait $pid
 set +x
diff --git a/torch_geometric/edge_index.py b/torch_geometric/edge_index.py
index 627536384..c9be09abd 100644
--- a/torch_geometric/edge_index.py
+++ b/torch_geometric/edge_index.py
@@ -1823,7 +1823,7 @@ def matmul(
 
     transpose &= not input.is_undirected or input_value is not None
 
-    if torch_geometric.typing.WITH_WINDOWS:  # pragma: no cover
+    if not torch_geometric.typing.WITH_MKL:  # pragma: no cover
         sparse_input = input.to_sparse_coo(input_value)
     elif input.is_sorted_by_col:
         sparse_input = input.to_sparse_csc(input_value)
@@ -1833,7 +1833,7 @@ def matmul(
     if transpose:
         sparse_input = sparse_input.t()
 
-    if torch_geometric.typing.WITH_WINDOWS:  # pragma: no cover
+    if not torch_geometric.typing.WITH_MKL:  # pragma: no cover
         other = other.to_sparse_coo(other_value)
     elif other.is_sorted_by_col:
         other = other.to_sparse_csc(other_value)
diff --git a/torch_geometric/transforms/add_positional_encoding.py b/torch_geometric/transforms/add_positional_encoding.py
index 06fad0b89..f55c2030e 100644
--- a/torch_geometric/transforms/add_positional_encoding.py
+++ b/torch_geometric/transforms/add_positional_encoding.py
@@ -153,10 +153,10 @@ class AddRandomWalkPE(BaseTransform):
             adj = torch.zeros((N, N), device=row.device)
             adj[row, col] = value
             loop_index = torch.arange(N, device=row.device)
-        elif torch_geometric.typing.WITH_WINDOWS:
-            adj = to_torch_coo_tensor(data.edge_index, value, size=data.size())
-        else:
+        elif torch_geometric.typing.WITH_MKL:
             adj = to_torch_csr_tensor(data.edge_index, value, size=data.size())
+        else:
+            adj = to_torch_coo_tensor(data.edge_index, value, size=data.size())
 
         def get_pe(out: Tensor) -> Tensor:
             if is_torch_sparse_tensor(out):
diff --git a/torch_geometric/typing.py b/torch_geometric/typing.py
index e7a6a90f8..16a5fbd42 100644
--- a/torch_geometric/typing.py
+++ b/torch_geometric/typing.py
@@ -17,6 +17,7 @@ WITH_PT112 = WITH_PT20 or int(torch.__version__.split('.')[1]) >= 12
 WITH_PT113 = WITH_PT20 or int(torch.__version__.split('.')[1]) >= 13
 
 WITH_WINDOWS = os.name == 'nt'
+WITH_MKL = 'USE_MKL=OFF' not in torch.__config__.show()
 
 MAX_INT64 = torch.iinfo(torch.int64).max
 


Test patch:
diff --git a/test/loader/test_dataloader.py b/test/loader/test_dataloader.py
index 6017fcaf1..cf7498778 100644
--- a/test/loader/test_dataloader.py
+++ b/test/loader/test_dataloader.py
@@ -11,6 +11,7 @@ from torch_geometric.loader import DataLoader
 from torch_geometric.testing import (
     get_random_edge_index,
     get_random_tensor_frame,
+    onlyLinux,
     withCUDA,
     withPackage,
 )
@@ -72,6 +73,7 @@ def test_dataloader(num_workers, device):
         assert batch.edge_index_batch.tolist() == [0, 0, 0, 0, 1, 1, 1, 1]
 
 
+@onlyLinux
 @pytest.mark.parametrize('num_workers', num_workers_list)
 def test_dataloader_on_disk_dataset(tmp_path, num_workers):
     dataset = OnDiskDataset(tmp_path)
diff --git a/test/test_edge_index.py b/test/test_edge_index.py
index fd71c824e..b6680b6d5 100644
--- a/test/test_edge_index.py
+++ b/test/test_edge_index.py
@@ -952,7 +952,7 @@ def test_spspmm(device, reduce, transpose, is_undirected):
         assert isinstance(out, EdgeIndex)
         assert out.is_sorted_by_row
         assert out._sparse_size == (3, 3)
-        if not torch_geometric.typing.WITH_WINDOWS:
+        if torch_geometric.typing.WITH_MKL:
             assert out._indptr is not None
         assert torch.allclose(out.to_dense(value), adj1_dense @ adj2_dense)
     else: