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

feat: large action spaces truncated randomized SVD #3899

Merged
merged 32 commits into from May 18, 2022

Conversation

olgavrou
Copy link
Collaborator

@olgavrou olgavrou commented Apr 28, 2022

  • qr decomposition and randomized svd steps
  • also generating the sparse action weight matrix A for testing
  • unit tests added for the randomized svd steps

@olgavrou olgavrou changed the title feat: large action spaces QR decomposition feat: large action spaces QR decomposition and SVD steps Apr 29, 2022
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,
Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah done

@olgavrou olgavrou changed the title feat: large action spaces QR decomposition and SVD steps feat: large action spaces truncated randomized SVD May 16, 2022
Copy link
Member

@jackgerrits jackgerrits left a 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

Comment on lines +6 to +7
#include <Eigen/Dense>
#include <Eigen/SparseCore>
Copy link
Member

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

Copy link
Collaborator Author

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)

Copy link
Member

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

Copy link
Collaborator Author

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
Copy link
Member

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?

Copy link
Collaborator Author

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

};

template <typename WeightsT>
struct Y_triplet_constructor
Copy link
Member

Choose a reason for hiding this comment

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

Same comment about naming

_all->_generate_interactions_object_cache);
}

B(row_index, col) = dot_product;
Copy link
Member

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

Eigen::MatrixXf B;
Eigen::MatrixXf Z;
Eigen::MatrixXf U;
Eigen::VectorXf _S;
Copy link
Member

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?

Copy link
Collaborator Author

@olgavrou olgavrou May 16, 2022

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

Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fair, added comments

@olgavrou olgavrou requested a review from jackgerrits May 17, 2022 13:43
@olgavrou olgavrou merged commit 231dcdf into VowpalWabbit:master May 18, 2022
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.

None yet

2 participants