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

Cannot run ColBERT on CPU #1569

Closed
timbmg opened this issue Jul 11, 2023 · 5 comments
Closed

Cannot run ColBERT on CPU #1569

timbmg opened this issue Jul 11, 2023 · 5 comments

Comments

@timbmg
Copy link

timbmg commented Jul 11, 2023

in pyserini/encode/_tct_colbert.py autocast is only imported if CUDA is availabe.

if torch.cuda.is_available():
    from torch.cuda.amp import autocast

However, later is it used in code that should also run on CPU, i.e. here:

@lintool
Copy link
Member

lintool commented Jul 23, 2023

hi @jacklin64 @justram can you take a look at this please? thanks!

@justram
Copy link
Member

justram commented Jul 23, 2023

Hello @timbmg,

Thank you for bringing this to our attention.
I understand the concern you raised regarding the usage of torch.autocast in the code that should also run on CPU.
You are correct; however, currently, torch.autocast only supports bfloat16 when device='cpu', and our prebuilt index is based on the CUDA + float16 setting.
As a result, encoding the document corpus with device='cpu' & bfloat16 would deviate from our original setting and might lead to significant processing time.
To address this issue and enable CPU-based encoding, we recommend considering the ONNX setting instead.

If you have any further questions or suggestions, please feel free to share them with us.

@zeuner
Copy link

zeuner commented Jan 15, 2024

A similar situation might be the case for pyserini/encode/_unicoil.py.

Is there any documentation available for encoding (and possibly subsequently indexing) using the ONNX setting to enable CPU support?

@lintool
Copy link
Member

lintool commented Jan 15, 2024

@lintool
Copy link
Member

lintool commented Mar 31, 2024

@timbmg Seeing no further updates, closing. Please re-open if needed.

@lintool lintool closed this as completed Mar 31, 2024
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

No branches or pull requests

4 participants