-
Notifications
You must be signed in to change notification settings - Fork 97
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
[tt-train] Add RMSNorm module #16991
base: main
Are you sure you want to change the base?
Conversation
|
||
class RMSNormLayer : public autograd::ModuleBase { | ||
private: | ||
float m_epsilon; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't forgeet default initialization.
|
||
public: | ||
void initialize_tensors(uint32_t features); | ||
explicit RMSNormLayer(uint32_t features, std::optional<float> epsilon = std::nullopt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we always need optional. Overall I am not a fun of active using of the std::optional if not really needed.
/* program_config */ std::nullopt, | ||
/* activation */ std::nullopt, | ||
/* compute_kernel_config */ core::ComputeKernelConfig::matmul(), | ||
/* core_grid */ std::nullopt, // NOTE: I believe matmul will use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let better reuse our default grid parameters for now. Also is it a copypaste of the same function in the linear? if yes you probably can put it somewhere else to avoid copypasting.
auto grad_a = ttnn_matmul( | ||
out->get_grad(), | ||
b->get_value(), | ||
/* transpose_a */ false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure you don't need to change this params depending on transpose_a, transpose_b
/* transpose_a */ false, | ||
/* transpose_b */ true); | ||
auto eps_tensor = | ||
autograd::create_tensor(core::from_xtensor(xt::xarray<float>{epsilon}, &autograd::ctx().get_device())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to implement our op which takes tensor and scalar then create an even small tensor every step.
/* output_tile */ std::nullopt); | ||
} | ||
|
||
autograd::TensorPtr matmul( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need matmul here? :)
auto a_shape = a.get_logical_shape(); | ||
auto b_shape = b.get_logical_shape(); | ||
|
||
auto suffix_len = std::min(a_shape.size(), b_shape.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it unsigned type? if yes, -suffix_len
looks suspicious. Anyway, i would advise to cast it signed in this case (even if size returns signed value for now, because in future it should change)
Problem description
We need RMSNorm to train Llama 3 and some other exciting open source models.
What's changed
Checklist