"""Standard-library startup configuration; call before importing PyTorch."""
import os


def configure_cuda_workspace():
    """Default an absent workspace and preserve supported explicit overrides."""
    value = os.environ.get("CUBLAS_WORKSPACE_CONFIG")
    if value is None:
        value = ":4096:8"
        os.environ["CUBLAS_WORKSPACE_CONFIG"] = value
    if value not in (":4096:8", ":16:8"):
        raise ValueError(
            f"Unsupported CUBLAS_WORKSPACE_CONFIG={value!r}. Set "
            "CUBLAS_WORKSPACE_CONFIG=:4096:8 (or :16:8) before starting "
            "a fresh Python process; the leading colon is required."
        )
    return value
