{"id":24724,"library":"torch-scatter","title":"torch-scatter","description":"PyTorch Extension Library of Optimized Scatter Operations. Provides efficient scatter, gather, segment, and softmax operations for PyTorch tensors, commonly used in graph neural networks. Current version 2.1.2, released Oct 2023. Maintained by Rusty1s, part of the PyTorch Geometric ecosystem.","status":"active","version":"2.1.2","language":"python","source_language":"en","source_url":"https://github.com/rusty1s/pytorch_scatter","tags":["pytorch","scatter","gpu","graph-neural-networks","cuda"],"install":[{"cmd":"pip install torch-scatter","lang":"bash","label":"Standard install from PyPI"},{"cmd":"pip install torch-scatter -f https://data.pyg.org/whl/torch-{your_torch_version}+{cu}.html","lang":"bash","label":"Install with CUDA support matching PyTorch version"}],"dependencies":[{"reason":"Core dependency, torch-scatter compiles against specific PyTorch versions","package":"torch","optional":false}],"imports":[{"note":"","wrong":"","symbol":"scatter","correct":"from torch_scatter import scatter"},{"note":"","wrong":"","symbol":"scatter_add","correct":"from torch_scatter import scatter_add"},{"note":"","wrong":"","symbol":"scatter_max","correct":"from torch_scatter import scatter_max"},{"note":"","wrong":"","symbol":"scatter_min","correct":"from torch_scatter import scatter_min"},{"note":"","wrong":"","symbol":"scatter_mean","correct":"from torch_scatter import scatter_mean"},{"note":"","wrong":"","symbol":"scatter_mul","correct":"from torch_scatter import scatter_mul"},{"note":"","wrong":"","symbol":"scatter_softmax","correct":"from torch_scatter import scatter_softmax"},{"note":"","wrong":"","symbol":"scatter_std","correct":"from torch_scatter import scatter_std"},{"note":"","wrong":"","symbol":"segment_coo","correct":"from torch_scatter import segment_coo"},{"note":"","wrong":"","symbol":"segment_csr","correct":"from torch_scatter import segment_csr"}],"quickstart":{"code":"import torch\nfrom torch_scatter import scatter_max\n\nsrc = torch.tensor([1.0, 2.0, 3.0, 4.0, 5.0])\nindex = torch.tensor([0, 0, 1, 1, 1])\nout, argmax = scatter_max(src, index, dim=0)\nprint(out)  # tensor([2., 5.])\n","lang":"python","description":"Compute max over indices using scatter_max."},"warnings":[{"fix":"Use `torch_scatter.scatter_logsumexp` (new function) or remove `eps` from `scatter_softmax`.","message":"Version 2.1.0 removed `scatter_logsumexp` and changed `scatter_softmax` to no longer require an `eps` argument. Code using these must update calls.","severity":"breaking","affected_versions":">=2.1.0"},{"fix":"Replace `scatter_add_(src, index, out)` with `scatter_add(src, index, dim, out=out)`.","message":"`scatter_` functions (e.g., `scatter_add_`) are deprecated in favor of the out-of-place versions. They may be removed in a future release.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Install using the PyTorch Geometric wheel index: `pip install torch-scatter -f https://data.pyg.org/whl/torch-{torch_version}+{cu_version}.html`.","message":"When using CUDA, the installed wheel must match the PyTorch CUDA version exactly. Installing from PyPI may pull a CPU-only build if the CUDA version mismatch is detected.","severity":"gotcha","affected_versions":"all"},{"fix":"Set `unbiased=True` to compute sample standard deviation.","message":"`scatter_std` with `unbiased=False` uses Bessel's correction? Actually it uses population std. Check documentation: the flag defaults to `False` which computes the biased standard deviation.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install via `pip install torch-scatter` and ensure the package is imported as `from torch_scatter import scatter_max`.","cause":"torch-scatter not installed or improperly installed, importing from wrong package.","error":"ImportError: cannot import name 'scatter_max' from 'torch_scatter'"},{"fix":"Convert tensor: `src = src.float()` or use `.int()` before calling scatter functions.","cause":"Some scatter operations do not support Long tensors (int64) on CUDA; cast to float or int32.","error":"RuntimeError: scatter_max_cuda not implemented for 'torch.LongTensor'"},{"fix":"Use `from torch_scatter import scatter_logsumexp`? Actually it was replaced by a different API. Use `torch_scatter.scatter_logsumexp` after upgrading, or downgrade to 2.0.9.","cause":"Function was removed in version 2.1.0.","error":"AttributeError: module 'torch_scatter' has no attribute 'scatter_logsumexp'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}