Repository navigation
Fix LSTMBlockCell Check Fail - #59534
copybara-service[bot] merged 16 commits into
Conversation
|
Forgot to include the first argument for |
mihaimaruseac
left a comment
There was a problem hiding this comment.
Looks good so far, but only hides the check fail and opens the potential for more vulns as it is. We need to stop execution of the kernel, not just this function
|
@mihaimaruseac thanks for the review! I am not sure I understand the difference between what you are asking for and the original behavior where the check fail would trigger a crash. Do you mind expanding on that a little bit? |
|
Basically the issue is void LSTMBlockCellFpropWithCUDA(OpKernelContext* ctx,,...) {
CHECK(expr);
...
}
void LSTMBlockCell::Compute(OpKernelContext* ctx,...) {
// do some validation
LSTMBlockCellFpropWithCUDA(ctx, ...);
// assume validation passed
RunSomeOtherCode(...);
}Right now, void LSTMBlockCellFpropWithCUDA(OpKernelContext* ctx,,...) {
if(expr) {
ctx->Status = errors::InvalidArgument(...);
return; // <----------- this line
}
...
}
void LSTMBlockCell::Compute(OpKernelContext* ctx,...) {
// do some validation
LSTMBlockCellFpropWithCUDA(ctx, ...);
// !!!!! You still need to stop executing the kernel here if ctx->Status is not Ok !!!
// assume validation passed
RunSomeOtherCode(...);
}Now how the |
|
Ok, that makes sense. Thanks for your help! I didn't realize how the macro worked. I think this latest commit accomplishes what you're saying, but just let me know if you think anything needs to change |
|
Were you able to test your changes and see if the check fail isn't being triggered anymore? |
|
Thanks for the pointers on the unit tests! I'll get those added soon. When I test locally against the error case from the related issue, I get the following error logs, but Python no longer crashes: |
|
@swachhandl My ARM CI build is failing for the |
mihaimaruseac
left a comment
There was a problem hiding this comment.
This looks good, thank you.
Approving so it also gets imported internally and more tests run on it.
It seems your test is failing on ARM/Ubuntu/Mac CPU CI but passes on Ubuntu GPU. Can you check if the CPU version is failing because it's not throwing any error (and hence, failing the assert)? If the CPU version isn't throwing any error, I think the ideal solution would be to make the GPU version also return the same result as the CPU counterpart (instead of returning an error). |
So this is the CPU variant of the code: tensorflow/tensorflow/core/kernels/rnn/lstm_ops.cc Lines 73 to 126 in ed3e77f And then this is the GPU code: tensorflow/tensorflow/core/kernels/rnn/lstm_ops_gpu.cu.cc Lines 98 to 194 in ed3e77f I guess one or more of the assumptions spelled out in the comment are causing the error. I can try to add some validations and see how that affects things. |
|
@swachhandl I confirmed that when run on the CPU, no error is thrown, but I'm having a hard time finding a way to get the GPU code to behave in same way. Would it be valid to mark this test case to run only on GPU? |
|
Can you pull master and see if the error for GPU still persists? A recent commit (764eae3) might have fixed it. Even if it's been fixed, propagating the error/checking the status is still useful. |
Hmm, I'm not sure what happened over the weekend when I tested this, but when I run it now on GPU with the check, it does crash. Must have been an issue with how I was testing. That's my mistake. I'll remove that check. And that's correct - it does not crash on CPU. It doesn't throw any error at all on CPU. I'm still kind of stumped as to how to get the behaviors to match. |
What's the output on CPU? |
Here's what I get when I print the result on CPU: |
As I suspected, most of those are actually empty tensors. In TF, an empty tensor (e.g. one dimension has size zero) ends up having a The input sizes are likely degenerate (i.e. there's an empty input). The CPU kernel correctly handles this, returning empty outputs of the correct size. The GPU kernel does not - it blindly forwards the arguments along until the CUDA GEMM call, which then crashes because one of the inputs (whatever becomes |
lstm-block-cell-check-fail
|
ROCm CI build failure appears to be due to the removal of this constructor from Looks like other pull request builds are failing with the same errors. |
|
Just because I'm new to the project, would anybody mind filling me in on how the import/copybara works? At this point is it pending because the AMD ROCm and the MacOS CPU builds failed? I'm seeing other pull requests for which the import completed even though various builds failed |
|
The full process is at Right now, this is pending Gerrit review. CC @gbaned |

Fixes #58270