sneppx-alg 1.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. sneppx-alg-1.5.1/PKG-INFO +364 -0
  2. sneppx-alg-1.5.1/README.md +340 -0
  3. sneppx-alg-1.5.1/SneppX_ALG/__init__.py +73 -0
  4. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/__init__.py +1813 -0
  5. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/acvp_kat.py +255 -0
  6. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/advanced_ops.py +1606 -0
  7. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/adversarial.py +370 -0
  8. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/ai_safety_ext.py +215 -0
  9. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/algo_arc.py +138 -0
  10. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/algo_fm.py +120 -0
  11. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/algo_hss.py +95 -0
  12. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/algo_npe.py +144 -0
  13. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/algo_ser.py +107 -0
  14. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/amp.py +156 -0
  15. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/api_gateway.py +234 -0
  16. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/api_key_manager.py +131 -0
  17. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/api_key_store.py +240 -0
  18. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/artifact_integrity.py +86 -0
  19. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/asm_bridge.py +150 -0
  20. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/audit_logger.py +1073 -0
  21. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/augmentation.py +711 -0
  22. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/autograd.py +430 -0
  23. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/autograd_ops.py +4215 -0
  24. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/benchmark.py +536 -0
  25. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/benchmarking.py +746 -0
  26. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/benchmarks.py +658 -0
  27. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/c_arch.py +75 -0
  28. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/c_attention.py +67 -0
  29. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/c_loader.py +119 -0
  30. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/c_logger.py +85 -0
  31. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/c_memory.py +83 -0
  32. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/c_simd_gemm.py +94 -0
  33. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/c_tensor_bridge.py +187 -0
  34. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/c_tensor_expr.py +108 -0
  35. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/c_thread.py +120 -0
  36. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/c_types.py +71 -0
  37. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/checkpoint.py +542 -0
  38. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/checkpoint_manager.py +322 -0
  39. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/container_security.py +989 -0
  40. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/continuous_batching.py +179 -0
  41. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/crypto_asm.py +257 -0
  42. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/crypto_hash.py +138 -0
  43. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/crypto_kdf.py +106 -0
  44. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/crypto_kem.py +90 -0
  45. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/crypto_sign.py +185 -0
  46. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/crypto_symmetric.py +127 -0
  47. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/crypto_util.py +177 -0
  48. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/cuda_device.py +211 -0
  49. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/cuda_kernels.py +644 -0
  50. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/data.py +121 -0
  51. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/data_loader.py +304 -0
  52. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/ddos_mitigation.py +501 -0
  53. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/differential_privacy.py +373 -0
  54. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/distillation.py +650 -0
  55. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/distributed.py +177 -0
  56. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/distributed_wrapper.py +97 -0
  57. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/driver_bindings.py +255 -0
  58. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/edge_runtime.py +474 -0
  59. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/eval_cli.py +43 -0
  60. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/eval_harness.py +302 -0
  61. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/experiment.py +256 -0
  62. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/experiment_cli.py +137 -0
  63. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/experiment_tracker.py +467 -0
  64. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/firewall.py +189 -0
  65. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/firewall_application.py +206 -0
  66. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/firewall_network.py +232 -0
  67. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/firewall_transport.py +98 -0
  68. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/formal_verify.py +116 -0
  69. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/forward_ad.py +411 -0
  70. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/fsdp.py +284 -0
  71. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/functional.py +140 -0
  72. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/generation.py +601 -0
  73. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/grad_checkpoint.py +113 -0
  74. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/graph_compiler.py +642 -0
  75. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/graph_optimizer.py +109 -0
  76. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/hf_integration.py +339 -0
  77. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/hparams.py +461 -0
  78. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/hpo.py +532 -0
  79. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/hw_backends.py +463 -0
  80. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/inference_server.py +956 -0
  81. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/init.py +166 -0
  82. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/jit.py +652 -0
  83. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/keras_api.py +807 -0
  84. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/key_vault.py +139 -0
  85. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/llama_models.py +966 -0
  86. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/lora.py +467 -0
  87. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/mlflow_like.py +738 -0
  88. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/model.py +647 -0
  89. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/model_implementations.py +1675 -0
  90. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/model_zoo.py +1576 -0
  91. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/mx_formats.py +236 -0
  92. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/nccl.py +308 -0
  93. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/net_bindings.py +330 -0
  94. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/nn.py +2920 -0
  95. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/nn_functional.py +1081 -0
  96. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/nn_init.py +121 -0
  97. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/obfuscation_bridge.py +147 -0
  98. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/onnx_check.py +645 -0
  99. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/onnx_cli.py +35 -0
  100. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/onnx_export.py +1279 -0
  101. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/optim.py +597 -0
  102. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/optim_advanced.py +692 -0
  103. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/optim_extra.py +638 -0
  104. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/paged_attention.py +427 -0
  105. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/pen_testing.py +123 -0
  106. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/profiler.py +192 -0
  107. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/pruning.py +545 -0
  108. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/pytorch_api.py +537 -0
  109. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/quantization.py +510 -0
  110. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/quantize_cli.py +64 -0
  111. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/quantized_serve.py +79 -0
  112. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/rlhf_cli.py +59 -0
  113. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/rng.py +23 -0
  114. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/runtime_monitor.py +122 -0
  115. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/s4_network.py +116 -0
  116. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/s5_safety.py +603 -0
  117. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/schedulers.py +460 -0
  118. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/secrets_redact.py +87 -0
  119. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/secure_memory.py +133 -0
  120. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/secure_updates.py +118 -0
  121. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/security_middleware.py +495 -0
  122. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/serve_cli.py +278 -0
  123. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/serving_client.py +128 -0
  124. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/serving_engine.py +815 -0
  125. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/sparse.py +487 -0
  126. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/tensor.py +1036 -0
  127. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/tokenizer.py +185 -0
  128. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/train.py +406 -0
  129. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/train_cli.py +142 -0
  130. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/trainer_v2.py +471 -0
  131. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/trainer_v3.py +718 -0
  132. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/usage_tracker.py +141 -0
  133. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/user_store.py +147 -0
  134. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/vision_transformers.py +954 -0
  135. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/vizmon.py +324 -0
  136. sneppx-alg-1.5.1/SneppX_ALG/interface_bindings/watermark.py +234 -0
  137. sneppx-alg-1.5.1/pyproject.toml +55 -0
  138. sneppx-alg-1.5.1/setup.cfg +4 -0
  139. sneppx-alg-1.5.1/setup.py +85 -0
  140. sneppx-alg-1.5.1/sneppx_alg.egg-info/PKG-INFO +364 -0
  141. sneppx-alg-1.5.1/sneppx_alg.egg-info/SOURCES.txt +144 -0
  142. sneppx-alg-1.5.1/sneppx_alg.egg-info/dependency_links.txt +1 -0
  143. sneppx-alg-1.5.1/sneppx_alg.egg-info/entry_points.txt +7 -0
  144. sneppx-alg-1.5.1/sneppx_alg.egg-info/not-zip-safe +1 -0
  145. sneppx-alg-1.5.1/sneppx_alg.egg-info/requires.txt +12 -0
  146. sneppx-alg-1.5.1/sneppx_alg.egg-info/top_level.txt +1 -0
@@ -0,0 +1,364 @@
1
+ Metadata-Version: 2.1
2
+ Name: sneppx-alg
3
+ Version: 1.5.1
4
+ Summary: Next-generation AI architecture with security built into the foundation
5
+ Author-email: "Ammar [SNEPPX]" <algoSNEPPX@gmail.com>
6
+ License: MIT
7
+ Project-URL: Source, https://github.com/SneppX/sneppx-alg
8
+ Keywords: ai,machine-learning,deep-learning,neural-networks,security,post-quantum,cryptography,distributed-training,cuda,tensor,state-space,mixture-of-experts,adversarial,model-zoo,quantization,llama,mistral,attention,mamba,transformer,formal-verification,differential-privacy,npu,nccl
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Security :: Cryptography
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ Provides-Extra: dev
22
+ Provides-Extra: hf
23
+ Provides-Extra: serve
24
+
25
+ # SNEPPX-Alg ๐Ÿค– โ€” The Universal Open-Source AI Algorithm Framework
26
+
27
+ <p align="center">
28
+ <b>A universal, open-source AI algorithm framework in C/C++ &amp; CUDA</b> โ€” tensor engine, autograd, MoE/SSM transformers, LLM model zoo, quantization, distributed-training primitives &amp; 10-layer AI security.
29
+ </p>
30
+
31
+ <p align="center">
32
+ <a href="https://github.com/SneppX/sneppx-alg/stargazers"><img src="https://img.shields.io/github/stars/SneppX/sneppx-alg?style=social" alt="Stars"></a>
33
+ <a href="https://github.com/SneppX/sneppx-alg/network/members"><img src="https://img.shields.io/github/forks/SneppX/sneppx-alg?style=social" alt="Forks"></a>
34
+ <a href="https://github.com/SneppX/sneppx-alg/issues"><img src="https://img.shields.io/github/issues/SneppX/sneppx-alg" alt="Issues"></a>
35
+ <a href="https://github.com/SneppX/sneppx-alg/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
36
+ </p>
37
+
38
+ [![Version](https://img.shields.io/badge/version-1.5.0-blue.svg)]() [![C/C++](https://img.shields.io/badge/language-C%2FC%2B%2B-00599C.svg)]() [![Python](https://img.shields.io/badge/language-Python-3776AB.svg)]() [![CUDA](https://img.shields.io/badge/CUDA-ff00e6.svg)]() [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/SneppX/sneppx-alg/pulls) [![Discussions](https://img.shields.io/badge/Join-Discussions-ff66cc)](https://github.com/SneppX/sneppx-alg/discussions) [![Awesome](https://img.shields.io/badge/awesome-SNEPPX-99ccff)](https://github.com/SneppX/sneppx-alg)
39
+
40
+ > **SneppX-ALG** โ€” A secure, composable, production-grade AI algorithm pipeline with 10 security layers (S0โ€“S9), model zoo, distributed-training primitives, quantization, and advanced architectures.
41
+
42
+ **โญ Star this repo** to support the project and help us reach 1,000+ stars!
43
+
44
+ ## ๐Ÿ“‘ Table of Contents
45
+ - [Overview](#overview)
46
+ - [By the numbers](#by-the-numbers)
47
+ - [Why SNEPPX-Alg?](#why-sneppx-alg)
48
+ - [Architecture](#architecture)
49
+ - [Component Status](#component-status)
50
+ - [The 5-Stage Pipeline](#the-5-stage-pipeline)
51
+ - [Security Layers (S0โ€“S9)](#security-layers-s0s9)
52
+ - [Model Zoo](#model-zoo)
53
+ - [C HTTP REST API](#c-http-rest-api)
54
+ - [Python Bindings](#python-bindings)
55
+ - [Python Quickstart](#python-quickstart)
56
+ - [Build & Quickstart](#build--quickstart)
57
+ - [Documentation](#documentation)
58
+ - [Contributing](#contributing)
59
+ - [Star History](#-star-history)
60
+ - [License](#license)
61
+
62
+ ## Overview
63
+
64
+ SNEPPX-Alg (under the SneppX organization) is a universal, MIT-licensed AI algorithm framework written primarily in **C11 / C++20 with CUDA**. It organizes model construction and inference as a composable, secure **5-stage pipeline** and wraps it with a layered security model (S0โ€“S9). The codebase is large (~183K LOC) and spans a core tensor/autograd substrate, algorithm implementations, accelerator drivers, a security stack, an HTTP serving layer, and Python bindings.
65
+
66
+ Design goals:
67
+ - **Auditable native core** โ€” the hot path lives in C/CUDA you can read and verify.
68
+ - **Composable pipeline** โ€” HSS โ†’ SER โ†’ ARC โ†’ NPE โ†’ FM stages are independently testable.
69
+ - **Security by design** โ€” ten layers from crypto to pentest are built into the framework.
70
+ - **Open & extensible** โ€” opt-in backends, a model zoo, and a Python API on top of the native core.
71
+
72
+ ## By the numbers
73
+
74
+ - **~183K lines** of C11 / C++20 / CUDA / Python across a single auditable codebase
75
+ - **300+ tests** (Python autograd, NN, optimizers, losses, sparse, higher-order AD, security)
76
+ - **10 security layers** (S0โ€“S9): classical + post-quantum crypto, memory hardening, obfuscation, monitoring, network, AI sanitizer, key vault, signed updates, formal verification, pentest
77
+ - **5-stage pipeline**: HSS โ†’ SER โ†’ ARC โ†’ NPE โ†’ FM
78
+ - **40+ autograd ops** with higher-order AD (`create_graph=True`), plus `jvp` / `vjp`
79
+ - **~70 differentiable functional ops** (`F.*`), 14 loss Module wrappers, 30+ optimizers
80
+ - **Quantization**: INT8 / INT4 / FP8 / AWQ / GPTQ
81
+ - **Distributed**: DDP, ZeRO-1/2/3, tensor / pipeline / expert parallelism (NCCL + CPU fallback)
82
+ - **Model zoo**: LLaMA 2/3, Mistral, Qwen 2, DeepSeek V2 presets
83
+ - **MIT licensed**, maintained by Ammar [SNEPPX]
84
+
85
+ ## Why SNEPPX-Alg?
86
+
87
+ Honest positioning โ€” SNEPPX-Alg is **not** a PyTorch replacement for training at scale. It is a **native, security-first AI substrate** you can read, audit, and compose: a C/C++/CUDA tensor engine, a composable 5-stage pipeline, and ten security layers (S0โ€“S9) including post-quantum crypto and signed updates.
88
+
89
+ | | SNEPPX-Alg | PyTorch | JAX |
90
+ |---|---|---|---|
91
+ | Core implementation | C / C++ / CUDA (auditable) | C++ / Python | Python โ†’ XLA |
92
+ | Python API | NumPy-backed `Tensor` / `nn` | Native tensors | `jax.numpy` |
93
+ | Built-in security | 10 layers (S0โ€“S9) + PQC | none | none |
94
+ | Post-quantum crypto | Kyber / Dilithium / SPHINCS+ (FIPS 203/204/205) | none | none |
95
+ | Signed model updates | Ed25519 over BLAKE3 | none | none |
96
+ | Quantization | INT8 / INT4 / FP8 / AWQ / GPTQ | INT8 / FP8 | limited |
97
+ | Distributed | DDP / ZeRO / TP / PP / EP (NCCL) | DDP / FSDP | pmap / pjit |
98
+ | License | MIT | BSD-3 | Apache 2.0 |
99
+
100
+ If you want a drop-in PyTorch experience today, use PyTorch. If you want a **readable native core with security built in**, SNEPPX-Alg is for you.
101
+
102
+ ## Architecture
103
+
104
+ The framework is structured as a secure pipeline. Each stage consumes the previous stage's output and the whole flow is observed by the security layers.
105
+
106
+ ```mermaid
107
+ flowchart LR
108
+ IN([Input]) --> HSS
109
+ subgraph Pipeline
110
+ HSS["HSS<br/>(State-Space Model)"]
111
+ SER["SER<br/>(Mixture-of-Experts)"]
112
+ ARC["ARC<br/>(Adversarial Guard)"]
113
+ NPE["NPE<br/>(Neural VM)"]
114
+ FM["FM<br/>(Fractal Memory)"]
115
+ end
116
+ HSS --> SER --> ARC --> NPE --> FM
117
+ FM --> OUT([Output])
118
+ SEC["Security Layers S0โ€“S9<br/>(crypto, memory, monitor,<br/>AI sanitizer, updates, ...)"]
119
+ SEC -.observes.-> Pipeline
120
+ ```
121
+
122
+ ### Directory layout
123
+
124
+ | Path | Purpose |
125
+ |------|---------|
126
+ | `kernel/` | Core tensor / autograd / optimizer / trainer / attention substrate, `distributed/`, `quantization/` |
127
+ | `algorithms/` | HSS, SER, ARC, NPE, FM, Transformer, ViT, GCN, RNN, GAN, Diffusion, RL, `model_zoo/` |
128
+ | `drivers/` | Accelerator backends (CUDA, ROCm, Vulkan, TPU, HTTP, ZK, Metal*, oneAPI*) |
129
+ | `security/` | S0โ€“S9 security layers (crypto, memory, monitor, network, AI, vault, updates, formal, obfuscation, pentest) |
130
+ | `net/` | HTTP serving, distributed (NCCL), gRPC, QUIC, RDMA, WebSocket |
131
+ | `bindings/python/` | `SneppX_ALG` Python package + pybind wrappers |
132
+ | `docs/` | ~70 reference docs (see [Documentation](#documentation)) |
133
+ | `tests/` `examples/` `scripts/` `tools/` | Test suite, demos, dev tooling |
134
+
135
+ `*` Metal and oneAPI are reference-compute backends enabled via `SNEPPX_BUILD_METAL` / `SNEPPX_BUILD_ONEAPI`. Vulkan/TPU/HTTP/ZK do real reference computation and are enabled via `SNEPPX_BUILD_VULKAN` / `SNEPPX_BUILD_TPU` / `SNEPPX_BUILD_HTTP` / `SNEPPX_BUILD_ZK`.
136
+
137
+ ## Component Status
138
+
139
+ We label maturity honestly so contributors know where to focus. Status: ๐ŸŸข Stable ยท ๐ŸŸก Experimental ยท ๐Ÿ”ด Known gap / under remediation.
140
+
141
+ | Component | Status | Notes |
142
+ |-----------|--------|-------|
143
+ | HSS (SSM) | ๐ŸŸข Stable | Selective-scan recurrence, layer norm, discretize implemented (`algorithms/hss/core`) |
144
+ | SER (MoE) | ๐ŸŸข Stable | Gating, expert routing, capacity balance (`algorithms/ser/core`) |
145
+ | ARC (Adversarial Guard) | ๐ŸŸข Stable | Input guard + output verifier + security metrics (`algorithms/arc/core`) |
146
+ | NPE (Neural VM) | ๐ŸŸข Stable | 16-register / 32-opcode dispatch with tensor kernels (`algorithms/npe/core/vm.c`) |
147
+ | FM (Fractal Memory) | ๐ŸŸข Stable | Memory-bank read/write + EWM combine (`algorithms/fm/core`) |
148
+ | CUDA kernels | ๐ŸŸก Experimental | Real `.cu` files; compiled only with `-DSNEPPX_BUILD_CUDA=ON` (OFF by default) |
149
+ | Crypto core (S0, classical) | ๐ŸŸข Stable | Ed25519, X25519, ChaCha20-Poly1305, SHA-3, AES-GCM, Argon2id, HMAC-DRBG |
150
+ | PQC (Kyber/Dilithium/SPHINCS+) | ๐ŸŸก Experimental | Implemented, with deterministic self-generated regression vectors in `tests/python/test_crypto_kat.py`; **not yet validated against official NIST ACVP / FIPS 203-205 known-answer vectors** |
151
+ | Signed updates (S7) | ๐ŸŸก Partial | Ed25519 sign/verify over a BLAKE3 update hash, enforced when a trusted key is configured; a constant-time unsigned hash-equality fallback remains for dev builds |
152
+ | Formal verification (S8) | ๐ŸŸก Partial | Reachable-state graph + deadlock scan + invariant walk; bounded safety LTL (`G !deadlock`, `AG !deadlock`, `F deadlock`) โ€” unsupported properties report "not verified" rather than false-positiving; state-space minimization is a stub |
153
+ | Memory / Obfuscation / Monitor / Vault / Pentest | ๐ŸŸข Stable | Substantial implementations in `security/` |
154
+ | Model Zoo `from_pretrained()` | ๐ŸŸก Experimental | Resolves architecture configs + builds skeleton; weight download unwired |
155
+ | C HTTP REST API | ๐ŸŸก Experimental | `/v1/health`, `/v1/models` real; `/v1/generate` is a demo scaffold |
156
+ | Distributed training | ๐ŸŸก Experimental | Gradient collectives in DDP/ZeRO/TP/PP/EP/grad-comm are wired to the NCCL binding (`net/distributed/nccl.c`), which falls back to a CPU path so single-process runs stay correct; control-plane pieces (checkpoint/elastic/heartbeat/sampler) remain scaffolded |
157
+ | Python bindings | ๐ŸŸข Stable | NumPy-backed `Tensor`/`nn`/`Trainer`; C `_Tensor` reachable via pybind |
158
+
159
+ ## The 5-Stage Pipeline
160
+
161
+ ```mermaid
162
+ flowchart TD
163
+ A[Raw sequence / tokens] --> B[HSS<br/>compress with SSM]
164
+ B --> C[SER<br/>route tokens to experts]
165
+ C --> D[ARC<br/>guard input + verify output]
166
+ D --> E[NPE<br/>execute neural program]
167
+ E --> F[FM<br/>store / recall memory]
168
+ F --> G[Trained model / inference result]
169
+ ```
170
+
171
+ - **HSS โ€” Hierarchical State-Space model** (`algorithms/hss/`): SSM front-end for long-range sequence modeling. Entry points `SNEPPX_hss_model_create`, `SNEPPX_hss_forward`.
172
+ - **SER โ€” Sparse Expert Router** (`algorithms/ser/`): Mixture-of-Experts with gating, capacity balancing, and expert forwarding. Entry points `SNEPPX_ser_model_create`, `SNEPPX_ser_forward`, `SNEPPX_ser_gate_forward`.
173
+ - **ARC โ€” Adversarial Robustness guard** (`algorithms/arc/`): input guard, output verifier, and gradient obfuscation that report security metrics. Entry point `SNEPPX_arc_forward`.
174
+ - **NPE โ€” Neural Processing Engine** (`algorithms/npe/`): a 16-register, 32-opcode neural VM (`SNEPPX_npe_vm_run`, `SNEPPX_npe_vm_step`) executing tensor operations as programs.
175
+ - **FM โ€” Fractal Memory** (`algorithms/fm/`): layered memory banks with a controller and EWM combine (`SNEPPX_fm_forward`).
176
+
177
+ ## Security Layers (S0โ€“S9)
178
+
179
+ Ten layers wrap the pipeline:
180
+
181
+ | ID | Layer | Status |
182
+ |----|-------|--------|
183
+ | S0 | Cryptography core (classical + PQC) | Classical ๐ŸŸข / PQC ๐ŸŸก |
184
+ | S1 | Secure memory hardening | ๐ŸŸข |
185
+ | S2 | Code obfuscation | ๐ŸŸข |
186
+ | S3 | Behavioral monitoring | ๐ŸŸข |
187
+ | S4 | Network security | ๐ŸŸก |
188
+ | S5 | AI sanitizer (prompt filter, DP) | ๐ŸŸก |
189
+ | S6 | Key vault & audit logging | ๐ŸŸข |
190
+ | S7 | Signed updates | ๐ŸŸก (Ed25519 live; dev fallback pending removal) |
191
+ | S8 | Formal verification | ๐ŸŸก (bounded safety LTL; full LTL pending) |
192
+ | S9 | Penetration testing / self-audit | ๐ŸŸข |
193
+
194
+ > Honest note: several layers are substantial, and the project openly tracks what is still partial โ€” **S7 signed-update verification and S8 formal verification are implemented but bounded** (Ed25519 with a dev-build fallback; safety-LTL properties only), and the post-quantum primitives are not yet FIPS-KAT validated. See `docs/security_layers.md` for the full mapping.
195
+
196
+ ## Model Zoo
197
+
198
+ The model zoo provides architecture presets and a `from_pretrained()` entry point.
199
+
200
+ - **Supported families (config presets):** LLaMA 2 / 3, Mistral, Qwen 2, DeepSeek V2 โ€” resolved via `SNEPPX_llm_config_from_name` (`algorithms/model_zoo/`).
201
+ - **`from_pretrained()`** (`bindings/python/.../model_zoo.py`): maps a model id โ†’ (family, size), builds the architecture skeleton, and returns a config. End-to-end pretrained-weight download/conversion is **in progress**; the safetensors / PyTorch `.bin` parsers in `hf_integration.py` are real but not yet wired into the loader.
202
+
203
+ ```python
204
+ # Illustrative โ€” resolves config + builds skeleton (weights download in progress)
205
+ from SneppX_ALG.interface_bindings.model_zoo import from_pretrained
206
+ model = from_pretrained("meta-llama/Llama-3-8b")
207
+ ```
208
+
209
+ ## C HTTP REST API
210
+
211
+ A real cross-platform socket server (`net/http/http_server.c`) with a route table. **Opt-in** via `-DSNEPPX_BUILD_HTTP=ON` (OFF by default).
212
+
213
+ | Endpoint | Status | Description |
214
+ |----------|--------|-------------|
215
+ | `GET /v1/health` | ๐ŸŸข | Liveness check |
216
+ | `GET /v1/models` | ๐ŸŸข | List preset model configs |
217
+ | `GET /v1/models/{id}` | ๐ŸŸข | Fetch one model config |
218
+ | `POST /v1/generate` | ๐ŸŸก | **Demo scaffold** โ€” deterministic token generator, no model forward pass yet |
219
+
220
+ Run the demo:
221
+
222
+ ```powershell
223
+ cmake -B build -DSNEPPX_BUILD_HTTP=ON
224
+ cmake --build build --config Release
225
+ # see examples/http_server_demo.c
226
+ ```
227
+
228
+ ## Python Bindings
229
+
230
+ The `SneppX_ALG` package exposes a NumPy-backed `Tensor`, `nn` modules, and trainers (`Trainer`, `UltraTrainer`, LoRA/DPO/GRPO). The C `_Tensor` engine is wrapped via pybind (`_SNEPPX_c.Tensor`) and used internally by the C algorithm cores.
231
+
232
+ ```python
233
+ # Illustrative โ€” NumPy-backed tensor math
234
+ import numpy as np
235
+ from SneppX_ALG import Tensor
236
+
237
+ x = Tensor(np.random.randn(4, 8))
238
+ w = Tensor(np.random.randn(8, 16))
239
+ y = x @ w
240
+ print(y.shape)
241
+ ```
242
+
243
+ ## Python Quickstart
244
+
245
+ Verified runnable (loss drops from ~7.4 to ~0.04 in 200 steps):
246
+
247
+ ```python
248
+ import numpy as np
249
+ from SneppX_ALG import Tensor
250
+ from SneppX_ALG.interface_bindings import nn, optim
251
+
252
+ np.random.seed(0)
253
+
254
+ class MLP(nn.Module):
255
+ def __init__(self):
256
+ super().__init__()
257
+ self.fc1 = nn.Linear(4, 8)
258
+ self.fc2 = nn.Linear(8, 2)
259
+ def forward(self, x):
260
+ return self.fc2(nn.functional.relu(self.fc1(x)))
261
+
262
+ model = MLP()
263
+ opt = optim.Adam(model.parameters(), lr=1e-2)
264
+
265
+ for step in range(200):
266
+ x = Tensor(np.random.randn(32, 4).astype(np.float32))
267
+ y = Tensor((2.0 * x.data[:, :2]).astype(np.float32))
268
+ loss = nn.functional.mse_loss(model(x), y)
269
+ loss.backward()
270
+ opt.step()
271
+ opt.zero_grad()
272
+
273
+ print("final loss:", round(float(np.asarray(loss.data).reshape(-1)[0]), 4)) # ~0.04
274
+ ```
275
+
276
+ Run with `PYTHONPATH=bindings/python python quickstart.py`. More runnable examples in [`examples/python_api/`](examples/python_api/).
277
+
278
+ ## Extended Python Utilities
279
+
280
+ Additional pragmatic packages (pure NumPy/Python, fully tested):
281
+
282
+ ```text
283
+ sampling, regularization, callbacks, linalg, signal, graph,
284
+ stats, structured_output, rag, agents, observability, speculative
285
+ ```
286
+
287
+ Import as:
288
+
289
+ ```python
290
+ from SneppX_ALG import sampling, regularization, ...
291
+ ```
292
+
293
+ ## Recent framework capabilities (v1.5.0)
294
+
295
+ - **Higher-order autograd**: `create_graph=True` through 40+ ops incl. Conv1d, layer/rms norm, all losses; plus `jvp` / `vjp` forward/reverse mode helpers.
296
+ - **Functional API**: `sneppx_ALG.nn.functional` (aliased `F`) with ~70 differentiable ops (conv, pool, norm, pad, unfold/fold, embedding, losses, interpolate).
297
+ - **nn modules**: Conv1d/Conv3d, ConvTranspose1d/2d/3d, MaxPool1d/2d/3d, AvgPool1d/2d/3d, adaptive pools, InstanceNorm*, Upsample, Unfold/Fold, MaxUnpool*, EmbeddingBag, ChannelShuffle/PixelShuffle, Bilinear, Flatten, ParameterList/Dict.
298
+ - **Optimizers**: SGD, Adam, AdamW, NAdam, Rprop, ASGD, LBFGS, SparseAdam, plus classic/extras.
299
+ - **Sparse tensors**: `SparseTensor` (COO/CSR/CSC/BSR), `sparse_mm`, `sparse_addmm`, `sparse_conv2d`.
300
+ - **Init utils**: `nn.init` (xavier/kaiming/orthogonal/...), differentiable pooling autograd functions.
301
+ - **Serialization**: strict `load_state_dict`, persistent/non-persistent buffers.
302
+ - **Distributed C kernels**: NCCL-wired DDP/tensor/expert/pipeline/ZeRO/gradient-comm; deterministic distributed sampler.
303
+
304
+ ## Build & Quickstart
305
+
306
+ ```powershell
307
+ cmake -B build -DCMAKE_BUILD_TYPE=Release
308
+ cmake --build build --config Release
309
+ cd build && ctest -C Release --output-on-failure
310
+ ```
311
+
312
+ Opt-in backends โ€” real reference implementations, **OFF by default**. Each performs genuine computation via the shared reference-compute path and reports `DRIVER_UNSUPPORTED` when its flag is off:
313
+
314
+ ```powershell
315
+ cmake -B build -DSNEPPX_BUILD_VULKAN=ON # Vulkan โ€” real GEMM / elementwise reference compute
316
+ cmake -B build -DSNEPPX_BUILD_TPU=ON # TPU โ€” real GEMM reference + device emulation
317
+ cmake -B build -DSNEPPX_BUILD_HTTP=ON # HTTP โ€” real BSD-socket transport (GET/POST)
318
+ cmake -B build -DSNEPPX_BUILD_ZK=ON # ZK โ€” real Schnorr proof over Curve25519 (p = 2^255 - 19)
319
+ cmake -B build -DSNEPPX_BUILD_METAL=ON # Apple Metal reference backend
320
+ cmake -B build -DSNEPPX_BUILD_ONEAPI=ON # Intel oneAPI/SYCL reference backend
321
+ ```
322
+
323
+ Build everything (all opt-in backends + tests) and run the full suite:
324
+
325
+ ```powershell
326
+ cmake -B build -DCMAKE_BUILD_TYPE=Release -DSNEPPX_BUILD_TESTS=ON `
327
+ -DSNEPPX_BUILD_VULKAN=ON -DSNEPPX_BUILD_TPU=ON -DSNEPPX_BUILD_HTTP=ON -DSNEPPX_BUILD_ZK=ON
328
+ cmake --build build --config Release
329
+ cd build && ctest -C Release --output-on-failure
330
+ ```
331
+
332
+ ## Documentation
333
+
334
+ | Area | Where to start |
335
+ |------|----------------|
336
+ | Quick start & build | [`docs/index.md`](docs/index.md) ยท [`QUICKSTART.md`](QUICKSTART.md) |
337
+ | Contribution framework | [`docs/CONTRIBUTOR_TIERS.md`](docs/CONTRIBUTOR_TIERS.md) |
338
+ | Good first issues | [`docs/GOOD_FIRST_ISSUES.md`](docs/GOOD_FIRST_ISSUES.md) |
339
+ | Branching strategy | [`docs/BRANCHING_STRATEGY.md`](docs/BRANCHING_STRATEGY.md) |
340
+ | Code review guide | [`docs/CODE_REVIEW_GUIDE.md`](docs/CODE_REVIEW_GUIDE.md) |
341
+ | Python features | [`docs/python_features.md`](docs/python_features.md) |
342
+ | API reference | [`docs/API.md`](docs/API.md) ยท [`docs/api/python.md`](docs/api/python.md) |
343
+ | Architecture | [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) |
344
+ | Security layers | [`docs/security_layers.md`](docs/security_layers.md) |
345
+ | Development workflow | [`docs/DEVELOPMENT.md`](docs/DEVELOPMENT.md) |
346
+ | All docs | [`docs/README.md`](docs/README.md) |
347
+
348
+ ## Contributing
349
+
350
+ We run a five-tier contribution framework and label good entry points:
351
+
352
+ - ๐Ÿท๏ธ `good first issue` ยท `help wanted` ยท `documentation` โ€” see the [open issues](https://github.com/SneppX/sneppx-alg/issues)
353
+ - ๐Ÿ’ฌ [Discussions](https://github.com/SneppX/sneppx-alg/discussions) โ€” announcements, Q&A, ideas, show-and-tell
354
+ - ๐Ÿ“š Learning paths & tier system in [`docs/CONTRIBUTOR_TIERS.md`](docs/CONTRIBUTOR_TIERS.md)
355
+
356
+ PRs are welcome.
357
+
358
+ ## โญ Star History
359
+
360
+ [![Star History Chart](https://api.star-history.com/svg?repos=SneppX/sneppx-alg&type=Date)](https://www.star-history.com/#SneppX/sneppx-alg&Date)
361
+
362
+ ## License
363
+
364
+ MIT โ€” see [`LICENSE`](./LICENSE). Maintained by **Ammar**.