feat: Safety wrapper and constant-time implementation (#55)
All checks were successful
Smoke Test / smoke (pull_request) Successful in 14s
All checks were successful
Smoke Test / smoke (pull_request) Successful in 14s
Safety wrapper (llama-turbo.h, llama-turbo.cpp): - Input validation (dimension must be power of 2, 16-4096) - Null pointer checks - Invalid norm detection (NaN/Inf/negative) - Error codes for all failure modes - Safe API: polar_quant_encode_turbo4_safe() Constant-time quantization: - ct_fabsf: bitwise absolute value (no branches) - ct_select: bitwise selection (no branches) - Always examines all 16 centroids - No data-dependent branches in packing Metal shader (ggml-metal-turbo.metal): - Buffer bounds checking on all accesses - Invalid norm handling (outputs zeros) - Thread ID validation - Constant-time dequantization kernel Tests (tests/test_safety.py): - 15 tests, all passing - Power of 2 validation - Dimension bounds checking - Buffer size verification - Packing correctness Closes #55
This commit is contained in:
BIN
tests/__pycache__/test_safety.cpython-312-pytest-9.0.2.pyc
Normal file
BIN
tests/__pycache__/test_safety.cpython-312-pytest-9.0.2.pyc
Normal file
Binary file not shown.
Reference in New Issue
Block a user