Repository navigation
refactor: use a common DatasetConfig class - #1712
Merged
Merged
Conversation
lkhphuc
requested review from
fegin,
tianyu-l,
wconstab and
wwwjn
as code owners
September 15, 2025 13:49
tianyu-l
approved these changes
Sep 15, 2025
fegin
approved these changes
Sep 16, 2025
fegin
left a comment
Contributor
There was a problem hiding this comment.
LGTM, one comment, please fix it.
Contributor
Author
|
Thanks. fixed lint and added `all``. |
tianyu-l
pushed a commit
that referenced
this pull request
Sep 23, 2025
…on (#1730) This PR resolves the `datasets` import error that were introduced in #1712. The error causes the following error message: ```Traceback (most recent call last): File "./torchtitan/train.py", line 16, in <module> import torchtitan.protocols.train_spec as train_spec_module File "./torchtitan/__init__.py", line 12, in <module> import torchtitan.experiments # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "./torchtitan/experiments/__init__.py", line 7, in <module> import torchtitan.experiments.llama4 # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "./torchtitan/experiments/llama4/__init__.py", line 11, in <module> from torchtitan.datasets.hf_datasets import build_hf_dataloader File "./torchtitan/datasets/hf_datasets.py", line 12, in <module> from datasets import Dataset, load_dataset ImportError: cannot import name 'Dataset' from 'datasets' (./torchtitan/datasets/__init__.py) ``` Why is this happening? It is because #1712 added an `__init__.py` file to the `datasets` folder. On the surface the PR looks fine, however, it causes a collision with HF datasets Python package called `datasets`. So when we try to import the `Dataset` class, we actually want the HF datasets package and not the local `datasets` folder. This, in turn, causes an import error. The solution is simple, change the `__init__.py` name to something else, in our case I changed it to `common.py` as I found this name most fitting.
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 13, 2026
As suggested in the comment [here](pytorch#1615 (comment)) for PR pytorch#1615 , I refactored all the dataset config instance to a common one in `torchtitan/datasets/__init__.py`, with a common name `sample_processor`. Doing it here to make it easier to review and limit scope of the other PR.
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 13, 2026
…on (pytorch#1730) This PR resolves the `datasets` import error that were introduced in pytorch#1712. The error causes the following error message: ```Traceback (most recent call last): File "./torchtitan/train.py", line 16, in <module> import torchtitan.protocols.train_spec as train_spec_module File "./torchtitan/__init__.py", line 12, in <module> import torchtitan.experiments # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "./torchtitan/experiments/__init__.py", line 7, in <module> import torchtitan.experiments.llama4 # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "./torchtitan/experiments/llama4/__init__.py", line 11, in <module> from torchtitan.datasets.hf_datasets import build_hf_dataloader File "./torchtitan/datasets/hf_datasets.py", line 12, in <module> from datasets import Dataset, load_dataset ImportError: cannot import name 'Dataset' from 'datasets' (./torchtitan/datasets/__init__.py) ``` Why is this happening? It is because pytorch#1712 added an `__init__.py` file to the `datasets` folder. On the surface the PR looks fine, however, it causes a collision with HF datasets Python package called `datasets`. So when we try to import the `Dataset` class, we actually want the HF datasets package and not the local `datasets` folder. This, in turn, causes an import error. The solution is simple, change the `__init__.py` name to something else, in our case I changed it to `common.py` as I found this name most fitting.
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 25, 2026
As suggested in the comment [here](pytorch#1615 (comment)) for PR pytorch#1615 , I refactored all the dataset config instance to a common one in `torchtitan/datasets/__init__.py`, with a common name `sample_processor`. Doing it here to make it easier to review and limit scope of the other PR.
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 25, 2026
…on (pytorch#1730) This PR resolves the `datasets` import error that were introduced in pytorch#1712. The error causes the following error message: ```Traceback (most recent call last): File "./torchtitan/train.py", line 16, in <module> import torchtitan.protocols.train_spec as train_spec_module File "./torchtitan/__init__.py", line 12, in <module> import torchtitan.experiments # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "./torchtitan/experiments/__init__.py", line 7, in <module> import torchtitan.experiments.llama4 # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "./torchtitan/experiments/llama4/__init__.py", line 11, in <module> from torchtitan.datasets.hf_datasets import build_hf_dataloader File "./torchtitan/datasets/hf_datasets.py", line 12, in <module> from datasets import Dataset, load_dataset ImportError: cannot import name 'Dataset' from 'datasets' (./torchtitan/datasets/__init__.py) ``` Why is this happening? It is because pytorch#1712 added an `__init__.py` file to the `datasets` folder. On the surface the PR looks fine, however, it causes a collision with HF datasets Python package called `datasets`. So when we try to import the `Dataset` class, we actually want the HF datasets package and not the local `datasets` folder. This, in turn, causes an import error. The solution is simple, change the `__init__.py` name to something else, in our case I changed it to `common.py` as I found this name most fitting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As suggested in the comment here for PR #1615 , I refactored all the dataset config instance to a common one in
torchtitan/datasets/__init__.py, with a common namesample_processor.Doing it here to make it easier to review and limit scope of the other PR.