Skip to content

[Bug]: qKnowledgeGradient shape mismatch when used with SaasFullyBayesianSingleTaskGP #2938

@ayesharoxx

Description

@ayesharoxx

What happened?

Hi, I’m trying to use qKnowledgeGradient with a fully Bayesian SAAS GP (SaasFullyBayesianSingleTaskGP) in BoTorch. I'm doing so by writing a new class that inherits from both SaasFullyBayesianSingleTaskGP and FantasizeMixin. Then, I override the fantasize() method to define how fantasy data is generated for this model. I have used 256 samples, warmup of 512, thinning of 1, num_fantasies=2. However, on running the code, I keep getting a shape mismatch error even with raw_samples=1 and num_restarts=1. The error looks like this:
RuntimeError: shape '[2, 1, 16, 1]' is invalid for input of size 64

I don't understand why I keep getting this error and where it is coming from. Any guidance on what might be causing this and how to properly structure the fantasy model in this context would be greatly appreciated!

Thanks in advance.

Please provide a minimal, reproducible example of the unexpected behavior.

The error occurs whenever I combine a SaasFullyBayesianSingleTaskGP with qKnowledgeGradient. I fit the SAAS model via fit_fully_bayesian_model_nuts, and then construct qKnowledgeGradient(model=model, num_fantasies=2). Calling optimize_acqf with q=1, num_restarts=1 and raw_samples=1 leads to the runtime error above. Removing KG (e.g. using qExpectedImprovement) works without issue, so the problem seems isolated to qKnowledgeGradient and the fully Bayesian SAAS model.

Please paste any relevant traceback/logs produced by the example provided.

RuntimeError: shape '[2, 1, 16, 1]' is invalid for input of size 64

BoTorch Version

v0.14.0

Python Version

No response

Operating System

No response

(Optional) Describe any potential fixes you've considered to the issue outlined above.

No response

Pull Request

None

Code of Conduct

  • I agree to follow BoTorch's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions