From c048917dcd686fcdc7dd386c6d2b345767085bac Mon Sep 17 00:00:00 2001 From: Tom Jackson Date: Tue, 24 Mar 2026 17:07:24 -0700 Subject: [PATCH] Enable quieting FAISS warning "inverted lists not stored" (#4964) Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4964 This unthrottled log site is leading to log spew. Reviewed By: luciang Differential Revision: D97350834 fbshipit-source-id: 824a98cc20504bc363bad662e4b57b68d0699758 --- faiss/impl/index_read.cpp | 10 +++++++--- faiss/index_io.h | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/faiss/impl/index_read.cpp b/faiss/impl/index_read.cpp index ea6d3b7ea..d8fa569fb 100644 --- a/faiss/impl/index_read.cpp +++ b/faiss/impl/index_read.cpp @@ -413,15 +413,19 @@ static void read_ArrayInvertedLists_sizes( } } +bool index_read_warn_on_null_invlists = true; + std::unique_ptr read_InvertedLists_up( IOReader* f, int io_flags) { uint32_t h; READ1(h); if (h == fourcc("il00")) { - fprintf(stderr, - "read_InvertedLists:" - " WARN! inverted lists not stored with IVF object\n"); + if (index_read_warn_on_null_invlists) { + fprintf(stderr, + "read_InvertedLists:" + " WARN! inverted lists not stored with IVF object\n"); + } return nullptr; } else if (h == fourcc("ilpn") && !(io_flags & IO_FLAG_SKIP_IVF_DATA)) { size_t nlist, code_size, n_levels; diff --git a/faiss/index_io.h b/faiss/index_io.h index 6caef84e5..6e95c04bb 100644 --- a/faiss/index_io.h +++ b/faiss/index_io.h @@ -13,6 +13,8 @@ #include #include +#include + /** I/O functions can read/write to a filename, a file handle or to an * object that abstracts the medium. * @@ -68,6 +70,8 @@ const int IO_FLAG_MMAP = IO_FLAG_SKIP_IVF_DATA | 0x646f0000; // after OnDiskInvertedLists get properly updated. const int IO_FLAG_MMAP_IFC = 1 << 9; +FAISS_API extern bool index_read_warn_on_null_invlists; + Index* read_index(const char* fname, int io_flags = 0); Index* read_index(FILE* f, int io_flags = 0); Index* read_index(IOReader* reader, int io_flags = 0);