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
feat: large action spaces truncated randomized SVD #3899
Conversation
vowpalwabbit/core/src/reductions/cb/cb_explore_adf_large_action_space.cc
Outdated
Show resolved
Hide resolved
vowpalwabbit/core/src/reductions/cb/cb_explore_adf_large_action_space.cc
Outdated
Show resolved
Hide resolved
if (_all->weights.sparse) | ||
{ | ||
triplet_constructor<sparse_parameters> w(_all->weights.sparse_weights, row_index, _triplets, max_non_zero_col); | ||
GD::foreach_feature<float, float, no_op, triplet_constructor<sparse_parameters>>(w, _all->ignore_some_linear, |
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.
Rather than hiding the construction logic in the operator[]
it would make more sense to do the insertion in the function that is called per weight. This would also migrate more cleanly to if this function where to be able to use a lambda instead of context + fptr
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.
yeah done
vowpalwabbit/core/src/reductions/cb/cb_explore_adf_large_action_space.cc
Outdated
Show resolved
Hide resolved
vowpalwabbit/core/src/reductions/cb/cb_explore_adf_large_action_space.cc
Outdated
Show resolved
Hide resolved
vowpalwabbit/core/src/reductions/cb/cb_explore_adf_large_action_space.cc
Outdated
Show resolved
Hide resolved
…n_space.cc Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com>
…into QR_decomposition
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 can't really comment on the linear algebra, but there are a few comments for the rest
#include <Eigen/Dense> | ||
#include <Eigen/SparseCore> |
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.
Forward declare instead of including the headers to improve build time and requiring the dependency for this header
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.
Given that this is an external library the convention is to just include it and respect its interface (also see google style guide)
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.
We are only using the types via references in this header so there is no need to include it all here.
We are explicitly using forward declarations as much as possible in VW in a attempt to improve compile time and reduce header interdependencies.
EDIT: Makes complete sense for a external type, especially this non-trivial one
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.
Synced offline, this is an external library and the types that are included are complicated (templated with default template args, etc) so we will respect the boundaries by including
template <typename WeightsT> | ||
struct LazyGaussianDotProduct | ||
struct A_triplet_constructor |
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.
Can you update to match naming conventions? If A
is a thing can it be named something more descriptive?
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.
Following the redsvd implementation for randomized truncated SVD from here. Keeping the equivalent matrix names is very useful, especially since this is still under construction and some steps/matrixes might be removed in the future
vowpalwabbit/core/src/reductions/cb/cb_explore_adf_large_action_space.cc
Outdated
Show resolved
Hide resolved
}; | ||
|
||
template <typename WeightsT> | ||
struct Y_triplet_constructor |
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.
Same comment about naming
vowpalwabbit/core/src/reductions/cb/cb_explore_adf_large_action_space.cc
Outdated
Show resolved
Hide resolved
vowpalwabbit/core/src/reductions/cb/cb_explore_adf_large_action_space.cc
Outdated
Show resolved
Hide resolved
vowpalwabbit/core/src/reductions/cb/cb_explore_adf_large_action_space.cc
Outdated
Show resolved
Hide resolved
_all->_generate_interactions_object_cache); | ||
} | ||
|
||
B(row_index, col) = dot_product; |
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.
What is B
? Can it please be named something more descriptive
vowpalwabbit/core/src/reductions/cb/cb_explore_adf_large_action_space.cc
Outdated
Show resolved
Hide resolved
Eigen::MatrixXf B; | ||
Eigen::MatrixXf Z; | ||
Eigen::MatrixXf U; | ||
Eigen::VectorXf _S; |
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 are some prefixed with _
and not others?
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.
they are currently only used in the unit tests, we don't need them otherwise, but unit testing can not happen without them
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.
Perhaps specify that fact either in the variable name or a comment?
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.
fair, added comments
A
for testing