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

Gemv degen fix #568

Closed
wants to merge 2 commits into from
Closed

Gemv degen fix #568

wants to merge 2 commits into from

Conversation

ndellingwood
Copy link
Contributor

No description provided.

gemv with degenerate matrices in transpose mode return incorrect
results.
Previously detected with cublas, but also observed with host blas.
@ndellingwood ndellingwood changed the base branch from release-candidate-3.0 to develop January 15, 2020 22:46
&& !std::is_same<typename AViewType::device_type::execution_space, Kokkos::Cuda>::value
#endif
)
if ((trans[0] == 'T' || trans[0] == 't' || trans[0] == 'C' || trans[0] == 'c' || trans[0] == 'H' || trans[0] == 'h'))
Copy link
Contributor

@kyungjoo-kim kyungjoo-kim Jan 15, 2020

Choose a reason for hiding this comment

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

Why "h" ? T is transpose and C is conj transpose. What does H mean ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed with new push

@@ -139,7 +139,7 @@ gemv (const char trans[],
typename YViewType::device_type,
Kokkos::MemoryTraits<Kokkos::Unmanaged> > YVT;

if ((trans[0] == 'T' || trans[0] == 't' || trans[0] == 'C' || trans[0] == 'c' || trans[0] == 'H' || trans[0] == 'h'))
if ((trans[0] == 'T' || trans[0] == 't' || trans[0] == 'C' || trans[0] == 'c') && A.extent(0) == 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't understand the context. A is m x n matrix and m is zero. The spec said y = beta y + alpha A x. So, in this case, y = beta y + alpha A' x. If A is degenerated, then this is scaling y = beta y. How come this makes a special case that is distinct from non transpose case ? Also, why do we only consider degeneration case for m = 0 ? When n (extent(1)) is zero, this should behave the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If A is degenerated, then this is scaling y = beta y

Correct. When testing the degenerated case with transpose mode with m = 0 the gemv result (which essentially acts as scaling like you pointed out) results in incorrect results. This occurs when tpls are enabled; short-circuiting the code path to instead use the fallback implementation allows for correct results (via passing tests).

Part of the reason this was not showing up prior is because transpose mode was not being tested, Ichi added this when he updated the fallback implementation for transpose mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kyungjoo-kim issue #539 has discussion of when this problem first observed.

@ndellingwood
Copy link
Contributor Author

@kyungjoo-kim I'll close this PR and put in a new one where scal is being called instead during the degenerate case, thanks!

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.

2 participants