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
12 changes: 8 additions & 4 deletions gptqmodel/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
_TRUTHY = {"1", "true", "yes", "on", "y"}


def env_flag(name: str, default: str | None = "0") -> bool:
def env_flag(name: str, default: str | bool | None = "0") -> bool:
"""Return ``True`` when an env var is set to a truthy value."""

value = os.getenv(name, default)
value = os.getenv(name)
if value is None:
return False
return value.strip().lower() in _TRUTHY
if default is None:
return False
if isinstance(default, bool):
return default
value = default
return str(value).strip().lower() in _TRUTHY


__all__ = ["env_flag"]
2 changes: 1 addition & 1 deletion gptqmodel/utils/looper_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from ..utils.torch import ALL_DEVICES, CPU, torch_sync


USE_TORCH_REPLICATE = env_flag("GPTQMODEL_USE_TORCH_REPLICATE")
USE_TORCH_REPLICATE = env_flag("GPTQMODEL_USE_TORCH_REPLICATE", True)


_THREAD_SAFE_PARALLEL = ThreadSafe(torch_parallel)
Expand Down
3 changes: 3 additions & 0 deletions tests/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ norecursedirs = tasks evalplus_results
markers =
ci: CPU-only CI regression coverage for DeviceThreadPool affinity behaviour
cuda: Requires CUDA device
inference: Inference workloads that replicate models across devices
filterwarnings =
ignore:Warning only once for all operators.*:UserWarning