Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix All chunked_loss Benchmark Scripts #438

Merged
merged 3 commits into from
Jan 1, 2025
Merged

Conversation

austin362667
Copy link
Collaborator

@austin362667 austin362667 commented Dec 8, 2024

Summary

With recent updates, we need to align the APIs used in the benchmark script to ensure consistency.

Code changes:

  • Fix .backward() pass in backward and full mode.
  • Reuse TorchLMHead from chunked_loss tests.

Testing Done

  • Hardware Type:
  • run make test to ensure correctness
  • run make checkstyle to ensure code style
  • run make test-convergence to ensure convergence

@austin362667 austin362667 changed the title Update DPO Loss API Update DPO Loss Benchmark Dec 8, 2024
@@ -1,4 +1,5 @@
from test.chunked_loss.test_dpo_loss import HF_DPO_Loss
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

also I believe other chunked loss benchmarking scripts would face the same issue

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it! Thanks for pointing that out~

@austin362667 austin362667 changed the title Update DPO Loss Benchmark Fix All chunked_loss Benchmark Scripts Dec 11, 2024
@lancerts lancerts requested a review from shivam15s December 11, 2024 22:15
@@ -65,13 +43,19 @@ def forward(self, x, target):
self.lin.weight,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we rather just output the loss from Torch[CUSTOM]Loss and Liger[CUSTOM]Loss, ie. just output tuple's first value. As we only need the loss, this would simplify the other code

Copy link
Collaborator Author

@austin362667 austin362667 Dec 13, 2024

Choose a reason for hiding this comment

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

Sure. Good idea. @shivam15s Thanks for review!

I'm using lambda to create a function that will access the first element only when it's actually called.
Reason is that I want to reuse TorchLMHead[CUSTOM] in tests without modifying them as well as for TorchLMHead[CUSTOM].

shivam15s

This comment was marked as outdated.

benchmark/scripts/benchmark_cpo_loss.py Outdated Show resolved Hide resolved
Signed-off-by: Austin Liu <[email protected]>

Fix all `.backward()` and reuse `TorchLMHead` from tests

Signed-off-by: Austin Liu <[email protected]>
Signed-off-by: Austin Liu <[email protected]>

Reuse LigerLMHead

Signed-off-by: Austin Liu <[email protected]>
@austin362667 austin362667 force-pushed the austin362667/fix/dpo_bench branch from 7776009 to 291f933 Compare December 30, 2024 02:11
@Tcc0403 Tcc0403 merged commit bf48d8d into main Jan 1, 2025
@Tcc0403 Tcc0403 deleted the austin362667/fix/dpo_bench branch January 1, 2025 08:22
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