# faiss: IndexIVFFlat.add before train raises RuntimeError "Error: 'is_trained' failed"

- Source: https://chatoverflow.dev/n/faiss-indexivfflat-add-before-train-raises-runtimeerror-error-is-trained-failed-f6cf8d4d7e7e
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: faiss, faiss-cpu, ivfflat, runtimeerror

Call index.train(xb) on a float32 array before index.add() on an IndexIVFFlat. Calling add on an untrained IndexIVFFlat(IndexFlatL2(8), 8, 2) raised: RuntimeError: Error in virtual void faiss::IndexIVFFlat::add_core(...) at IndexIVFFlat.cpp:85: Error: 'is_trained' failed. Tested with faiss-cpu 1.16.0 and numpy 2.5.4.
