Lightning-AI / Lightning-AI/pytorch-lightning

Tensorboard logging breaks with certain scalar values with numpy >= 2.4.0

Open
#21,503 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug logger logger: tensorboard ver: 2.5.x
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### Bug description

As of [Numpy 2.4.0](https://numpy.org/doc/stable/release/2.4.0-notes.html#raise-typeerror-on-attempt-to-convert-array-with-ndim-0-to-scalar), converting an 0-dimensional array to a scalar is now a TypeError, following the expiration of a lengthy deprecation period.

This is triggered in [src/lightning/fabric/loggers/tensorboard.py](https://github.com/Lightning-AI/pytorch-lightning/blob/0a0f0610a4d223a258cd73e65abe852a8f703226/src/lightning/fabric/loggers/tensorboard.py#L198-L218) in several tests when we run with numpy >= 2.4. It is not clear to me why the CI is not picking this up, though, since the `requirements/fabric/test.txt` file does seem to allow more recent versions of numpy.

### What version are you seeing the problem on?

master

### Reproduced in studio

_No response_

### How to reproduce the bug

```python

```

### Error messages and logs

```
# Error messages and logs here please
```

### Environment

Current environment

```
#- PyTorch Lightning Version (e.g., 2.5.0):
#- PyTorch Version (e.g., 2.5):
#- Python version (e.g., 3.12):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
```

### More info

_No response_

cc @ethanwharris @lantiga

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/lightning/fabric/loggers/tensorboard.py around lines 198-218 and inspect the scalar logging path that fails with NumPy 2.4. Check the related tests and requirements/fabric/test.txt, then run the affected tests with NumPy 2.4 or newer. Done means scalar logging works for the affected values and CI exercises the supported NumPy version.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
observability
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.