Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ Possible contribution values are: `answering questions`, `bug reports`, `code`,
|-----------------|---------------|-----------------|
| Sebastienlejeune | infrastructure | Lejeune, Sébastien |
| ego-thales | bug reports, code, documentation, fixes, ideas, maintenance, pr reviews, testing, tutorials | Goudout, Élie |
| eliegoudout | documentation, fixes | Goudout, Élie |
| eliegoudout | bug reports, documentation, fixes, maintenance | Goudout, Élie |
| Lap0u | fixes | Beaurain, Clément |
<!-- TABLE END -->
7 changes: 6 additions & 1 deletion docs/src/conf.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
"""For ruff :)."""

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import html
import importlib
import inspect
import os
import re
from collections.abc import Mapping, Sequence
from enum import EnumType
from functools import partial
from itertools import zip_longest
from operator import itemgetter
from os.path import dirname, relpath
Expand All @@ -19,6 +20,7 @@
from types import MappingProxyType
from typing import TYPE_CHECKING, Literal, cast

import torch
from paramclasses import IMPL, MISSING, isparamclass
from sphinx.application import Sphinx
from sphinx.util import logging
Expand Down Expand Up @@ -297,6 +299,9 @@ def linkcode_resolve(

# -- Options for "sphinx_gallery.gen_gallery" --------------------------------
os.environ.setdefault("HF_DATASETS_DISABLE_PROGRESS_BARS", "true") # No download logs
# Monkeypatch for github.com/ThalesGroup/scio/issues/11
torch.hub.load = partial(torch.hub.load, skip_validation=True)

tutorials_order = [
"inferring_with_confidence.py",
"visualizing_and_evaluating_ood_detection_algorithms.py",
Expand Down
9 changes: 3 additions & 6 deletions docs/src/user_guide/installation_compatibility.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,18 @@ If you wish to install from source or wheels manually, you can download `release

OS Compatibility
----------------
The library is available and functional on Ubuntu, Windows and MacOS. However, note the following regarding ``faiss``-related features.

- They are **partially** supported on **Windows** and their use will trigger a warning: due to non-Python dependency conflicts, there might be uncontrolled and silent concurrency issues, potentially altering results. For more information, see this nice ressource about `native dependencies <https://pypackaging-native.github.io/key-issues/native-dependencies>`_. Note that we still run full CI tests on Windows.
- They are **not officially supported** on **MacOS** and might generate random crashes. We should match the current Windows support status *relatively soon*.
The library is available and functional on **Ubuntu**, **Windows** and *MacOS* (minus ``faiss``-related features ─ feel free to show your interest `here <https://github.com/ThalesGroup/scio/issues/2>`__).

Framework Compatiblity
----------------------
Although confidence scores are not a particularity of Neural Networks, ``scio`` is precisely developed to handle such models. More precisely, only *PyTorch* models (inheriting from ``torch.nn.Module``) are currently supported.

GPU Compatibility
-----------------
Our library is **fully compatible** and tested with CUDA devices for native use of GPU acceleration! Note however that features using ``faiss`` currently use CPU-bound indexes, introducing a potential GPU > CPU > GPU bottleneck. This may be improved in future versions. Do not hesitate to express interest by opening a related issue.
Our library is **fully compatible** and tested with CUDA devices for native use of GPU acceleration! Note however that features using ``faiss`` currently use CPU-bound indexes, introducing a potential GPU > CPU > GPU bottleneck. This may be improved in future versions ─ feel free to show your interest `here <https://github.com/ThalesGroup/scio/issues/18>`__.

Supported Data Types
--------------------
The package is **fully compatible** and tested with ``torch.half`` (float16), ``torch.float`` (float32) and ``torch.double`` (float64) data types. However, we **discourage** the use of gradient-based algorithms with ``torch.half`` data, as they can easily generate irrelevant results due to potential ``nan`` values. Finally, note that ``faiss``-related operations temporarily convert to 32 bits data, regardless of the input type.

There is currently no official support for ``torch.bfloat16`` even though many features may be compatible. Do not hesitate to express interest by opening a related issue.
There is currently no official support for ``torch.bfloat16`` even though many features may be compatible. Feel free to show your interest by opening a related issue.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ classifiers = [
]
dependencies = [
"dill>=0.3.8",
"faiss-cpu>=1.11",
"faiss-cpu>=1.12",
"lazy-loader>=0.4",
"matplotlib>=3.10",
"numpy>=2.2.2",
Expand Down
47 changes: 0 additions & 47 deletions scio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""scio package."""

import os
import platform
from importlib.metadata import PackageNotFoundError, version

try:
Expand All @@ -13,48 +11,3 @@

# Lazily load from adjacent `.pyi` file
__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)

# Monkeypatch the use of ``faiss`` on non-Linux platforms
if (
platform.system() != "Linux"
and os.environ.get("KMP_DUPLICATE_LIB_OK", None) != "TRUE"
): # pragma: no cover
import importlib
import sys
import types
from warnings import warn

null = object()

class DummyFaiss(types.ModuleType):
"""Dummy faiss to intercept faiss loading."""

__faiss = null

def __getattribute__(self, attr: str) -> object:
"""Intercept loading, warn & enable KMP_DUPLICATE_LIB_OK."""
__faiss = super().__getattribute__(f"_{type(self).__name__}__faiss")

# If necessary, warn and load faiss
if __faiss is null:
msg = (
"On non-Linux platforms, the use of any `faiss`-dependant feature "
"is partially supported by `scio`: you might experience slowdowns "
"or even incorrect results! This is due to a non-Python dependency "
"conflict regarding OpenMP (see https://pypackaging-native.github"
".io/key-issues/native-dependencies for interesting ressources). "
"As a monkeypatch, we enable the `KMP_DUPLICATE_LIB_OK`."
)
warn(msg, stacklevel=2)
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"

if sys.modules.pop("faiss") is not self:
msg = "Dummy faiss module should only be defined during scio init"
raise RuntimeError(msg)

self.__faiss = __faiss = importlib.import_module("faiss")
sys.modules["faiss"] = __faiss

return __faiss.__getattribute__(attr)

sys.modules["faiss"] = DummyFaiss("faiss")
40 changes: 20 additions & 20 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.