# Summetric

> Compute the SumMetric metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute SumMetric, or asks how to score with SumMetric.

- Skill: `qhjqhj00/summetric` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/summetric`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/summetric/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/summetric

---


# summetric

> Metric `SumMetric` from `torchmetrics` (torchmetrics.SumMetric)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with SumMetric, or
mentions `torchmetrics.SumMetric` directly, or wants the standard torchmetrics implementation.

## Reference signature

```python
from torchmetrics import SumMetric

# SumMetric(nan_strategy: Union[Literal['error', 'warn', 'ignore', 'disable'], float] = 'warn', **kwargs: Any) -> None
```

## Library docstring

```
Aggregate a stream of value into their sum.

As input to ``forward`` and ``update`` the metric accepts the following input

- ``value`` (:class:`~float` or :class:`~torch.Tensor`): a single float or an tensor of float values with
  arbitrary shape ``(...,)``.

As output of `forward` and `compute` the metric returns the following output

- ``agg`` (:class:`~torch.Tensor`): scalar float tensor with aggregated sum over all inputs received

Args:
    nan_strategy: options:
        - ``'error'``: if any `nan` values are encountered will give a RuntimeError
        - ``'warn'``: if any `nan` values are encountered will give a warning and continue
        - ``'ignore'``: all `nan` values are silently removed
        - ``'disable'``: disable all `nan` checks
        - a float: if a float is provided will impute any `nan` values with this value

    kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.

Raises:
    ValueError:
        If ``nan_strategy`` is not one of ``error``, ``warn``, ``ignore``, ``disable`` or a float

Example:
    >>> from torch import tensor
    >>> from torchmetrics.aggregation import SumMetric
    >>> metric = SumMetric()
    >>> metric.update(1)
    >>> metric.update(tensor([2, 3]))
    >>> metric.compute()
    tensor(6.)
```

## Quick recipe

```python
import torchmetrics as _m
score = _m.SumMetric(y_true, y_pred)
```

## Don'ts

- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.

