-
Notifications
You must be signed in to change notification settings - Fork 234
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
Hip Refactor #1359
Hip Refactor #1359
Conversation
… into repo-refactor
Finish implementing `compiler`
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.
Reviewable status: 0 of 13 files reviewed, 11 unresolved discussions (waiting on @Bob-Chen222)
docs/doxygen/Doxyfile
line 884 at r1 (raw file):
INPUT += $(FF_HOME)/python INPUT += $(FF_HOME)/src INPUT += $(FF_HOME)/lib/substitutions/include
What is this change for?
lib/kernels/src/hip/layer_norm_kernels.cpp
line 27 at r1 (raw file):
constexpr int kColwiseReduceTileSize = 32; LayerNormPerDeviceState::LayerNormPerDeviceState(
Actually, you can get rid of this constructor in both the hip and cuda kernels. (Also remove the LayerNormPerDeviceState
class, only keep the struct in layer_norm_kernels.h
)
lib/kernels/src/hip/layer_norm_kernels.cpp
line 57 at r1 (raw file):
int64_t effective_num_elements_, float eps_) { elementwise_affine = elementwise_affine_;
Need to have a datatype for these.
Code snippet:
float* mean = allocator.allocate(...);
lib/kernels/src/hip/layer_norm_kernels.cpp
line 67 at r1 (raw file):
scale = allocator.allocate(sizeof(float) * effective_batch_size); bias = allocator.allocate(sizeof(float) * effective_batch_size); LayerNormPerDeviceState per_device_state =
Here, just list-initialize LayerNormPerDeviceState
(both hip and cuda)
Code snippet:
LayerNormPerDeviceState per_device_state = {handle, elementwise_affine, ...};
lib/kernels/src/hip/layer_norm_kernels.cpp
line 85 at r1 (raw file):
struct ForwardKernel { void operator()(hipStream_t stream, LayerNormPerDeviceState const *m,
Use reference instead of pointer (same for rest of file)
lib/kernels/src/hip/linear_kernels.cpp
line 25 at r1 (raw file):
namespace Linear { // what's the float * one_ptr
You can get rid of this comment
lib/kernels/src/hip/linear_kernels.cpp
line 90 at r1 (raw file):
void forward_kernel(hipStream_t stream, LinearPerDeviceState const *m,
Change to a reference (so use m.xxx
instead of m->xxx
in the rest of the code)
Code snippet:
LinearPerDeviceState const &m,
lib/kernels/src/hip/linear_kernels.cpp
line 152 at r1 (raw file):
HIPBLAS_GEMM_DEFAULT)); } if (use_activation(m->activation)) {
use_activation
needs to be defined and implemented.
Code snippet:
bool use_activation(ActiMode mode) {
switch (mode) {
case AC_MODE_RELU:
case AC_MODE_SIGMOID:
case AC_MODE_TANH:
return true;
case AC_MODE_NONE:
return false;
default:
assert(0);
break;
}
return false;
}
lib/kernels/src/hip/linear_kernels.cpp
line 182 at r1 (raw file):
void backward_kernel(hipStream_t stream, LinearPerDeviceState const *m,
Same here. Use a reference instead of a pointer
lib/substitutions/TUTORIAL.md
line 1 at r1 (raw file):
## Tutorial of substitution lib with simple example
Why is this file included?
lib/substitutions/include/substitutions/attribute_expr.h
line 10 at r1 (raw file):
enum class ConstraintType { EQUAL }; /**
I'm guessing you may have merged a docs PR with the kernel refactor. We should probably separate these out.
Hi @reyna-abhyankar, I believe that everything is fixed now! Redundant changes from substitution are eliminated and all the requests you made have been fixed. |
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.
Reviewable status: 0 of 16 files reviewed, 11 unresolved discussions (waiting on @reyna-abhyankar)
lib/kernels/src/hip/layer_norm_kernels.cpp
line 27 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
Actually, you can get rid of this constructor in both the hip and cuda kernels. (Also remove the
LayerNormPerDeviceState
class, only keep the struct inlayer_norm_kernels.h
)
Done.
lib/kernels/src/hip/layer_norm_kernels.cpp
line 57 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
Need to have a datatype for these.
Done.
lib/kernels/src/hip/layer_norm_kernels.cpp
line 67 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
Here, just list-initialize
LayerNormPerDeviceState
(both hip and cuda)
Done.
lib/kernels/src/hip/layer_norm_kernels.cpp
line 85 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
Use reference instead of pointer (same for rest of file)
Done.
lib/kernels/src/hip/linear_kernels.cpp
line 25 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
You can get rid of this comment
Done.
lib/kernels/src/hip/linear_kernels.cpp
line 90 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
Change to a reference (so use
m.xxx
instead ofm->xxx
in the rest of the code)
Done.
lib/kernels/src/hip/linear_kernels.cpp
line 152 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
use_activation
needs to be defined and implemented.
Done.
lib/kernels/src/hip/linear_kernels.cpp
line 182 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
Same here. Use a reference instead of a pointer
Done.
docs/doxygen/Doxyfile
line 884 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
What is this change for?
Done.
lib/substitutions/TUTORIAL.md
line 1 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
Why is this file included?
Done.
lib/substitutions/include/substitutions/attribute_expr.h
line 10 at r1 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
I'm guessing you may have merged a docs PR with the kernel refactor. We should probably separate these out.
Done.
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.
Reviewable status: 0 of 16 files reviewed, all discussions resolved
Description of changes:
Hi @lockshaw Colin and @reyna-abhyankar Reyna,
This PR aligned the hip of linear and layer_norm against the Cuda version. If everything works fine, I can proceed to change other hip kernels.
Related Issues:
Linked Issues:
Issues closed by this PR:
This change is