Lightning-AI / Lightning-AI/pytorch-lightning

Inconsistency between the definition of `root_dir` in fabric and pytorch loggers

Open
#17,155 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

logger refactor
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### Outline & Motivation

When trying to fix https://github.com/Lightning-AI/lightning/issues/17138, I found that the definition of `root_dir` in fabric and pytorch is different. Let's say we want the logging dir to be like `tmpdir/some_exp/name/version_0`. Here is a table of the current behaviors:

| | Fabric CSVLogger | Fabric TensorboardLogger | PL CSVLogger | PL TensorboardLogger |
|-|-|-|-|-|
|what user should pass in `init`| `tmpdir/some_exp/name` | `tmpdir/some_exp` | `tmpdir/some_exp` | `tmpdir/some_exp` |
|what `root_dir` stored| `tmpdir/some_exp/name` | `tmpdir/some_exp` | `tmpdir/some_exp/name` | `tmpdir/some_exp/name` |
| has `_get_next_version` implemented | Yes | Yes | No, calling the function from fabric | Yes |

The differences are not obvious because I assume users should use the PL API, but these differences have made the corresponding test modules and internal implementations like `_get_next_version` having different calling conventions and implementations.

### Pitch

Unify the definitions of the `root_dir` variable, and possibly refactor the code to include fewer copies of functions like `_get_next_version`.

### Additional context

_No response_

cc @lantiga @justusschock @borda @awaelchli

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

Compare the Fabric and PyTorch Lightning CSVLogger and TensorboardLogger implementations, along with their corresponding test modules, focusing first on root_dir and _get_next_version calling conventions. Done means the loggers use a unified root_dir definition and consistent version handling, with duplicated helper implementations reduced where appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.