Skip to content

Getting Started

Install

pip install dense-armor                 # core: numpy + jax
pip install "dense-armor[quantum]"      # + Dense-Evolution (NISQ simulator)
pip install "dense-armor[audio,data]"   # + WAV, HDF5, NetCDF
# required before any import -- needed by the 64-bit gating
import jax
jax.config.update("jax_enable_x64", True)
# PowerShell equivalent, before launch
$env:JAX_ENABLE_X64="True"

To run the test suite locally (clone the repo first -- not needed if you only pip installed):

git clone https://github.com/tatopenn-cell/Dense-Armor.git
cd Dense-Armor && pip install -e ".[dev]"
pytest test/ -v

Quickstart

python -m dense_armor --json 1.2 1.3 9999 1.25 nan 1.3
> anomaly @ index 2 (spike 9999)
> anomaly @ index 4 (NaN)
> everything else: unchanged

Protecting a real model

from dense_armor.utility.orca import Orca

orca = Orca()
protected_output = orca.protect_and_forward(
    my_model,                                  # callable: x -> output (JAX/NumPy)
    corrupted_data,                            # tensor from the sensor/pipeline
    x_reference=known_clean_reference,         # optional but recommended
)

orca.margine_ingresso_medio, orca.margine_uscita_medio   # how much to trust the output

A 1D series (training loss, metrics, token stream)

from dense_armor import Armatura

a = Armatura(livello_ia=0.0)   # 0 = actively filter ยท 1 = mark only
pulito, K, anomalie = a.analizza(serie)

Standalone robust filters

from dense_armor.utility.robust_filters import pressure_valve

pulito, anomalie, pressione, soglia_effettiva = pressure_valve(serie)

No configuration needed beyond the defaults -- pressure_valve combines four classic detectors (Chauvenet, Tukey, Hampel, sigma-clipping) via a minimum-variance estimator and a Jensen-Shannon-modulated threshold. See Robust filters for the full math.

Standalone toolkit

A second, independent part of the package (core//utility/) -- none of it participates in the anomaly shield above. Two examples out of the 14 modules:

from dense_armor.core import DynamicAICodegen

codegen = DynamicAICodegen()
ops = codegen.compile_pipeline(["relu", "l2_normalize"])
out = codegen.run_dynamic_pipeline([-2.0, 3.0, -1.0, 4.0], ops)
# out -> [0. 0.6 0. 0.8]  (relu clips negatives, then L2-normalized)
from dense_armor.core import UniversalMemoryGuard

guard = UniversalMemoryGuard(min_free_ram_percentage=0.10)
guard.check_memory_safety()  # raises MemoryPressureError if RAM is too low

See Toolkit for the full list -- an op-compiler, chunking, hardware profiling, adversarial noise injection, presets, logging/provenance export, and audio/HDF5/ NetCDF I/O helpers.