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

Change embedding backward op output data format setup #1143

Merged
merged 4 commits into from
Feb 3, 2025

Conversation

pmarkovicTT
Copy link
Contributor

@pmarkovicTT pmarkovicTT commented Jan 30, 2025

Ticket

Close #1142

Problem description

The current logic for setting up output data format for backward ops selects data format of the first input operand.
Reference: void OpNode::set_output_df_from_operands(const Graph *graph) in the node_types.cpp.

This is problematic since different ops can require output to match data format of some other input operand. For instance, the embedding backward op should match data format of embedding weights (the second operand).

What's changed

Changed the way embedding backward op is created (explicitly setting up output data format through autogradContext).

Checklist

  • Add set_output_df method to autogradContext
  • Updated backward method for embedding op (embedding.py)
  • Test new logic (test_llama_backward) - note here, couldn't find explicit tests for adding new functions so test with existing one.

@pmarkovicTT pmarkovicTT added the bug Something isn't working label Jan 30, 2025
@pmarkovicTT pmarkovicTT self-assigned this Jan 30, 2025
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests564 ran485 passed79 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests505 ran446 passed59 skipped0 failed
TestResult
No test annotations available

Copy link
Contributor

@pilkicTT pilkicTT left a comment

Choose a reason for hiding this comment

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

I think i have an idea on how to do this more cleanly, let's sync tomorrow.

@pmarkovicTT pmarkovicTT requested a review from pilkicTT January 31, 2025 10:30
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests505 ran446 passed59 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests564 ran485 passed79 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests505 ran446 passed59 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests564 ran485 passed79 skipped0 failed
TestResult
No test annotations available

@pilkicTT
Copy link
Contributor

One more thing, please change the title so it reflects that this is only related to embedding_bw op. 😄

@pmarkovicTT pmarkovicTT changed the title Change backward op output data format setup Change embedding backward op output data format setup Feb 3, 2025
@pmarkovicTT pmarkovicTT merged commit a5de610 into main Feb 3, 2025
6 checks passed
@pmarkovicTT pmarkovicTT deleted the pmarkovic/fix-backward-op-output-df-setup branch February 3, 2025 08:49
vwellsTT pushed a commit that referenced this pull request Feb 4, 2025
### Ticket
Close #1142

### Problem description
The current logic for setting up output data format for backward ops
selects data format of the first input operand.
Reference: `void OpNode::set_output_df_from_operands(const Graph
*graph)` in the `node_types.cpp`.

This is problematic since different ops can require output to match data
format of some other input operand. For instance, the embedding backward
op should match data format of embedding weights (the second operand).

### What's changed
Changed the way embedding backward op is created (explicitly setting up
output data format through autogradContext).

### Checklist
- [x] Add set_output_df method to autogradContext
- [x] Updated backward method for embedding op (`embedding.py`)
- [x] Test new logic (test_llama_backward) - note here, couldn't find
explicit tests for adding new functions so test with existing one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change embedding backward op output data format setup
2 participants