Skip to content

Conversation

@yao-matrix
Copy link
Contributor

No description provided.

Signed-off-by: Matrix Yao <[email protected]>
@github-actions
Copy link
Contributor

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@github-actions github-actions bot marked this pull request as draft May 15, 2025 04:54
@yao-matrix
Copy link
Contributor Author

@ydshieh @IlyasMoutawwakil , pls help review, thx.

@yao-matrix yao-matrix marked this pull request as ready for review May 15, 2025 04:54
"""
env = os.environ.copy()
paths = [self.src_dir_str]
paths = [self.repo_root_dir_str, self.src_dir_str]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an implicit issue here.

  1. In the env where PYTHONPATH is empty, the line 2049 code join src and test to PYTHONPATH with an extra ":"(since paths has a "" string because of the code paths.append(env.get("PYTHONPATH", ""))), so the final PYTHONPATH will be like /transformers/src:/transformers/tests: with a trailing :, which implies the current folder which is /transformers.
  2. But when it comes the an env with an non-empty PYTHONPATH, the env["PYTHONPATH"] = ":".join(paths) will generate /transformers/src:/transformers/tests:A:B path without training :, which means current folder not included in the PYTHONPATH

So, in situation 2), test cases like tests/trainer/test_trainer_distributed_loss.py will fail, since while torchrun, the from tests.trainer.test_trainer import StoreLossCallback will not found, since there is only /transformers/src:/transformers/tests in PYTHONPATH, but the import statement actually needs /transformers/

what i do is making it explicit, but this is just for the cases i can see, i don't know other background.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM. But just to understand better,

when it comes the an env with an non-empty PYTHONPATH

So in your environment, this is the case? Do you set it somehow?

In our report, I see

tests/trainer/test_trainer_distributed_loss.py::TestTrainerDistributedLoss::test_trainer
(line 675) AssertionError: 0.8057947486768737 not less than 0.1

So it seems there is no import issue in our runner env.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ydshieh yes, in my CUDA env, there is no such issue either, since PYTHONPATH is empty. But in my XPU env, since Intel oneAPI will preset some paths into PYTHONPATH, and it doesn't work. That's the background i looked into that issue and found it,:)

@ydshieh ydshieh enabled auto-merge (squash) May 15, 2025 12:05
@ydshieh ydshieh merged commit 7caa57e into huggingface:main May 15, 2025
23 checks passed
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@yao-matrix yao-matrix deleted the trainer-xpu branch May 15, 2025 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants