Skip to content

Fix the CI loss issue - #2315

Merged
fegin merged 16 commits into
mainfrom
gh/fegin/77/head
Feb 7, 2026
Merged

fegin merged 16 commits into
mainfrom
gh/fegin/77/head

Conversation

@fegin

@fegin fegin commented Feb 3, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes

  1. Only compare FSDP and HSDP for one step.
  2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).

fegin added 2 commits February 2, 2026 16:33
[ghstack-poisoned]
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 3, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: 4e6258e
Pull-Request: #2315
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 3, 2026
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 3, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: d94772d
Pull-Request: #2315
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 3, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: aba91dc
Pull-Request: #2315
@fegin fegin changed the title [Not Ready] Fix the CI loss issue Fix the CI loss issue Feb 3, 2026
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 3, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: de6d6b4
Pull-Request: #2315
Comment thread tests/assets/losses/llama3_cuda.txt Outdated
7 4.3239
8 4.0675
9 3.9687
10 3.7249

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmm, why the change is so drastic -- does it mean previously there are bugs?
cc @pianpwk

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure if it is unrealistic but the first couple steps we have big learning rate, so some minor difference in the gradient can result in big change?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No if we use the same seed, it's absolutely not nondeterminism -- there must be something going on.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can i ask why the first 4 steps remain unchanged?

@fegin fegin Feb 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No if we use the same seed, it's absolutely not nondeterminism -- there must be something going on.

I don't understand the nondeterminism statement. The loss change is from pytorch/pytorch#173569 removing allreduce, according @pianpwk. So the loss change is expected. The loss is deterministic after pytorch/pytorch#173569. But the loss is different from what we have previously, pytorch/pytorch#173569.

I thought your concern is the degree of the change, why nondeterminism?

Can i ask why the first 4 steps remain unchanged?
Only the first step doesn't change, but we only compare the 4 digits. We can print out more digits if this confuses people.

@pianpwk pianpwk Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah also, that PR is reverted for now... the same issue showed up internally (doesn't match numerics before)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok do I understand correctly that, with the PR reverted, the current PR should fail?

Also, if the change is caused by that PR, why the change is so drastic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok do I understand correctly that, with the PR reverted, the current PR should fail?
Yes

And since the PR cause more than one training framework numeric changes, I would suggest that @pianpwk verifies both frameworks before relanding the PR.

Comment thread tests/assets/losses/llama3_cuda.txt Outdated
7 4.3239
8 4.0675
9 3.9687
10 3.7249

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No if we use the same seed, it's absolutely not nondeterminism -- there must be something going on.

python3 scripts/loss_compare.py . . --baseline-options="${baseline_options}" --test-options="${test_options}" --job-dump-folder="${RUNNER_TEMP}/artifacts-to-be-uploaded/accuracy_comparison_outputs" --assert-equal --steps=1
rm -rf $RUNNER_TEMP/artifacts-to-be-uploaded/*

python3 scripts/loss_compare.py . . --baseline-options="${baseline_options}" --job-dump-folder="${RUNNER_TEMP}/artifacts-to-be-uploaded/accuracy_comparison_outputs" --import-result="${LOSS_FILE}" --assert-equal --job-dump-folder="${RUNNER_TEMP}/artifacts-to-be-uploaded/accuracy_comparison_outputs/loss.txt" --steps=100

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why we only compare step=1 with the LOSS_FILE in previous comparison, but run again with 100 steps, why don't we merge these comparision?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We cannot compare FSDP and HSDP for 100 steps anymore. These are essentially two different comparisons. For one step, that is to ensure that FSDP and HSDP first forward loss is on par. After the first step, we couldn't guarantee the same loss anymore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, so here's my understanding of the code:

  1. llama3_cuda/rocm.txt has loss from FSDP (dp_shard=8) experiments
  2. This line we are comparing a new FSDP run (baseline_options = "dp_replicate=1", so FSDP degree = 8), with the result in llama3_cuda/rocm.txt

python3 scripts/loss_compare.py . . --baseline-options="${baseline_options}" --test-options="${test_options}" --job-dump-folder="${RUNNER_TEMP}/artifacts-to-be-uploaded/accuracy_comparison_outputs" --assert-equal --steps=1
rm -rf $RUNNER_TEMP/artifacts-to-be-uploaded/*

python3 scripts/loss_compare.py . . --baseline-options="${baseline_options}" --job-dump-folder="${RUNNER_TEMP}/artifacts-to-be-uploaded/accuracy_comparison_outputs" --import-result="${LOSS_FILE}" --assert-equal --job-dump-folder="${RUNNER_TEMP}/artifacts-to-be-uploaded/accuracy_comparison_outputs/loss.txt" --steps=100

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, so here's my understanding of the code:

  1. llama3_cuda/rocm.txt has loss from FSDP (dp_shard=8) experiments
  2. This line we are comparing a new FSDP run (baseline_options = "dp_replicate=1", so FSDP degree = 8), with the result in llama3_cuda/rocm.txt

[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 6, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: c5ee918
Pull-Request: #2315
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 6, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: d7ed318
Pull-Request: #2315
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 6, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: 0202ff0
Pull-Request: #2315
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 6, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: 182c594
Pull-Request: #2315
fegin added 2 commits February 6, 2026 15:28
[ghstack-poisoned]
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 6, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: 5e3ec64
Pull-Request: #2315
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 7, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: 3245f3e
Pull-Request: #2315
fegin added 2 commits February 6, 2026 16:29
[ghstack-poisoned]
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 7, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: b1b0b06
Pull-Request: #2315
logger.info(
f"{color.red}step: {step:2} "
f"{color.green}loss: {global_avg_loss:7.4f} "
f"{color.green}loss: {global_avg_loss:8.5f} "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not sure if this format change would break anything in your internal loss check script

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We used space to separate the metrics, so this should be okay. Will fix it if this does break something.

fegin added 2 commits February 6, 2026 17:41
[ghstack-poisoned]
[ghstack-poisoned]
fegin added a commit that referenced this pull request Feb 7, 2026
pytorch/pytorch#173569 changes how NormPartial works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with previous result (also FSDP).
ghstack-source-id: ad87608
Pull-Request: #2315
@fegin
fegin changed the base branch from gh/fegin/77/base to main February 7, 2026 07:34
@fegin
fegin merged commit cf86edc into main Feb 7, 2026
25 checks passed
@fegin
fegin deleted the gh/fegin/77/head branch February 9, 2026 17:37
TXacs pushed a commit to McmillanTAC/torchtitan that referenced this pull request Apr 13, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0)
(oldest at bottom):
* __->__ pytorch#2315

pytorch/pytorch#173569 changes how NormPartial
works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with
previous result (also FSDP).
ACharacterInASimulation pushed a commit to ACharacterInASimulation/torchtitan that referenced this pull request Apr 21, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0)
(oldest at bottom):
* __->__ pytorch#2315

pytorch/pytorch#173569 changes how NormPartial
works and potentially change the loss.

This PR changes
1. Only compare FSDP and HSDP for one step.
2. Have a seperate run to compare the loss of FSDP after 100 steps with
previous result (also FSDP).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants