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

Optimization in memory usage of gKDR #242

Open
yyimingucl opened this issue Aug 24, 2022 · 3 comments · Fixed by #244
Open

Optimization in memory usage of gKDR #242

yyimingucl opened this issue Aug 24, 2022 · 3 comments · Fixed by #244

Comments

@yyimingucl
Copy link

Hi MOGP developing team,

I met a RAM exceeding problems when I use gKDR for a 40k dimensional dataset and the it was quite slow to solve a 641d problem. I am raising the issue for a potential optimisation after I compare the gKDR in mogp and its original implementation by matlab.

I noticed that we compute the matrix R jointly with all samples but this will lead to a problem when the sample size is large. From the original implementation of gKDR, the author uses a loop instead and compute the R incrementally which largely reduce the required memory.

The matlab code looks like (all the notations are same with mogp):
R = 0;
for i = 1:N
% Derivative of k(X_i,x) w.r.t x
Hi = ((repmat(X(i,:),N,1) - X)./SGX/SGX).*repmat(Kx(:,i),1,M);
%Hi = squeeze(Xij(i,:,:)).*repmat(Kx(:,i),1,M);
Ri = Hi'FHi;
R = R+Ri;
end

Best,
Yiming

@ots22
Copy link
Member

ots22 commented Aug 25, 2022

Hi @yyimingucl,

Thanks for opening this issue - I agree with your diagnosis and proposed solution and will try to push a fix fairly soon.

Oliver

@yyimingucl
Copy link
Author

Hi @yyimingucl,

Thanks for opening this issue - I agree with your diagnosis and proposed solution and will try to push a fix fairly soon.

Oliver

Many thanks Oliver

Yiming

@ots22
Copy link
Member

ots22 commented Sep 5, 2022

Hi @yyimingucl, the PR above introduces these changes from the branch gkdr-mem.

This was referenced Nov 4, 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 a pull request may close this issue.

2 participants