mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-08-30 14:40:38 +02:00
feat: harden local runtime and verification
This commit is contained in:
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
set +x
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
||||
|
||||
if [[ -z "${OBLITERATUS_SECRET_COMMAND:-}" ]] && \
|
||||
[[ -x /home/roctinam/.local/bin/obliteratus-secret-broker ]]; then
|
||||
export OBLITERATUS_SECRET_COMMAND=/home/roctinam/.local/bin/obliteratus-secret-broker
|
||||
fi
|
||||
|
||||
# Avoid dynamic mixing between PyTorch's bundled cuDNN and a host cuDNN
|
||||
# installation. Causal convolutions and attention use other CUDA kernels.
|
||||
export OBLITERATUS_DISABLE_CUDNN="${OBLITERATUS_DISABLE_CUDNN:-1}"
|
||||
|
||||
exec .venv/bin/python app.py --host "${OBLITERATUS_HOST:-127.0.0.1}" \
|
||||
--port "${OBLITERATUS_PORT:-7860}"
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
set +x
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
||||
|
||||
uv sync --locked --extra spaces --extra dev --no-editable
|
||||
|
||||
enable_cuda="${ENABLE_CUDA:-auto}"
|
||||
if [[ "$enable_cuda" != "false" ]] && command -v nvidia-smi >/dev/null 2>&1; then
|
||||
torch_version="$(.venv/bin/python -c 'import torch; print(torch.__version__.split("+", 1)[0])')"
|
||||
UV_TORCH_BACKEND=cu130 uv pip install \
|
||||
--python .venv/bin/python \
|
||||
--reinstall-package torch \
|
||||
"torch==$torch_version"
|
||||
fi
|
||||
|
||||
uv pip check --python .venv/bin/python
|
||||
.venv/bin/python - <<'PY'
|
||||
import shutil
|
||||
import torch
|
||||
|
||||
if torch.cuda.is_available():
|
||||
probe = torch.arange(16, device="cuda", dtype=torch.float32).square().sum()
|
||||
assert probe.device.type == "cuda"
|
||||
torch.backends.cudnn.enabled = False
|
||||
torch.backends.cuda.enable_cudnn_sdp(False)
|
||||
conv_input = torch.randn(1, 8, 32, device="cuda", dtype=torch.float16)
|
||||
conv_weight = torch.randn(8, 8, 3, device="cuda", dtype=torch.float16)
|
||||
convolution = torch.nn.functional.conv1d(conv_input, conv_weight)
|
||||
q = torch.randn(1, 2, 32, 16, device="cuda", dtype=torch.float16)
|
||||
attention = torch.nn.functional.scaled_dot_product_attention(q, q, q, is_causal=True)
|
||||
torch.cuda.synchronize()
|
||||
assert convolution.device.type == "cuda" and torch.isfinite(convolution).all()
|
||||
assert attention.device.type == "cuda" and torch.isfinite(attention).all()
|
||||
elif shutil.which("nvidia-smi"):
|
||||
raise SystemExit("NVIDIA hardware detected but the installed PyTorch runtime cannot use CUDA")
|
||||
PY
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
set +x
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
||||
|
||||
.venv/bin/python - <<'PY'
|
||||
import os
|
||||
import shutil
|
||||
import torch
|
||||
|
||||
from obliteratus.credential_sources import secret_available
|
||||
|
||||
assert torch.ones(1).add(1).item() == 2
|
||||
if shutil.which("nvidia-smi"):
|
||||
assert torch.cuda.is_available(), "NVIDIA GPU detected but CUDA is unavailable"
|
||||
assert torch.ones(1, device="cuda").device.type == "cuda"
|
||||
torch.backends.cudnn.enabled = False
|
||||
torch.backends.cuda.enable_cudnn_sdp(False)
|
||||
conv_input = torch.randn(1, 8, 32, device="cuda", dtype=torch.float16)
|
||||
conv_weight = torch.randn(8, 8, 3, device="cuda", dtype=torch.float16)
|
||||
convolution = torch.nn.functional.conv1d(conv_input, conv_weight)
|
||||
q = torch.randn(1, 2, 32, 16, device="cuda", dtype=torch.float16)
|
||||
attention = torch.nn.functional.scaled_dot_product_attention(q, q, q, is_causal=True)
|
||||
torch.cuda.synchronize()
|
||||
assert convolution.device.type == "cuda" and torch.isfinite(convolution).all()
|
||||
assert attention.device.type == "cuda" and torch.isfinite(attention).all()
|
||||
|
||||
broker = os.environ.get("OBLITERATUS_SECRET_COMMAND")
|
||||
if broker:
|
||||
assert os.path.isabs(broker)
|
||||
assert secret_available("HF_TOKEN")
|
||||
assert secret_available("OPENROUTER_API_KEY")
|
||||
PY
|
||||
|
||||
.venv/bin/pytest -q --no-cov tests/test_device_boundaries.py tests/test_secrets.py \
|
||||
tests/test_abliterate.py::TestCoherenceScoring
|
||||
Reference in New Issue
Block a user