Real-time AI Safety Guardrail Kernel in C++20 & CUDA. Eradicates branch misprediction and warp divergence via pure IEEE 754 bit-masking and native FMA intrinsics.
🇰🇷 본 프로젝트는 미래형 가속기 기반 가치관 가드레일 엔진의 아키텍처 방향성을 정립하기 위한 독창적인 청사진(Blueprint) 개념 실증 모델입니다.
🇺🇸 This project serves as an original blueprint concept, engineered specifically to establish and validate the architectural direction for next-generation, accelerator-native value guardrail engines.
기존의 파이썬 기반 문맥 파싱 방식(
Semantic Software Guard)은 높은 지연 시간(Latency)과 무거운 정렬 세금(Alignment Tax)을 유발했습니다.
value-system-kernel V2는 이 구조를 물리 메모리 주소 기반의 초고속 다차원 스캔 공간(Pure Bitwise Aesthetics)으로 완전히 전형(Revamp)했습니다. 자연어 텍스트 분석에 소모되는 런타임 오버헤드를 원천 박멸하고, 미리 정제 및 적재된 위험 기준 벡터의 물리 주소값만 가속기 커널에 직접 바인딩(Binding)하여 유입되는 신호를 기하학적으로 검문합니다.
이를 통해 고도화된 프롬프트 인젝션이나 탈옥(Jailbreak) 등 적대적 입력이 유입되더라도, 대뇌 피질 구조의 의미론적 판단을 거치지 않고 척수 반사처럼 하드웨어 단에서 최소 클럭 사이클 내에 실시간 기각 및 완충 처리를 관통합니다.
IEEE 754 Bit-Masking, Hardware Bitwise MUX, Fused Multiply-Add (FMA)Conventional Python-based semantic parsing frameworks (
Semantic Software Guard) inevitably introduce critical computational latency and a heavy "Alignment Tax."
value-system-kernel V2 completely revamps this heavy abstraction tier into a high-speed scanning structure driven by raw physical memory addresses (Pure Bitwise Aesthetics). It eradicates natural language token-parsing overhead at runtime by directly binding the physical memory pointers of pre-allocated danger reference vectors straight into the hardware acceleration kernel for multi-dimensional geometric verification.
Confronted with sophisticated prompt injections or malicious bypass vectors (Jailbreaks), the system bypasses the cerebral cortex semantic evaluation layers entirely. It acts like a spinal reflex, intercepting and neutralizing adversarial data streams on a physical register tier with absolute zero execution jitter.
IEEE 754 Bit-Masking, Hardware Bitwise MUX, Fused Multiply-Add (FMA)factual_truth)만을 안전 가이드라인 기준으로 삼아 거리를 단속했습니다. 이로 인해 탐색 대상 카테고리(정치 편향, 악성 스팸, 기밀 유출 등)가 추가되거나 기준 수치선이 바뀔 때마다 커널 소스코드를 매번 직접 수정하고 재컴파일해야 하는 치명적인 아키텍처 결합도 문제가 존재했습니다.danger_vectors_ptr)**를 다이렉트로 물려받아 가치관 단속을 수행하는 완전한 플러그앤플레이(Plug-and-Play) 모듈 인터페이스로 진화했습니다.if 조건문을 단 하나도 사용하지 않습니다. 최솟값 판정 마스크(diff_mask)의 비트 전압 상태를 가로채서, 최적의 위험 거리에 적중한 물리 좌표(matched_danger)를 분기 지연 없이 레지스터에 동시 로킹하는 비트 MUX 동기화 로직을 빌드했습니다. 이를 통해 무한한 앵커 확장성을 확보하면서도 V1이 수호해 온 런타임 분기 예측 실패율 0.000%와 제로 지터 스펙을 고스란히 계승해 냈습니다.factual_truth). This primitive architecture introduced rigid coupling friction, demanding manual source-code modifications and full toolchain re-compilations whenever threat categories (e.g., political bias, toxicity, data leaks) scaled or evolved.danger_vectors_ptr), the framework achieves absolute Plug-and-Play portability.diff_mask) evaluated during distance minimizing, it locks the closest-hit physical coordinate (matched_danger) straight into registers with zero branch misprediction penalties. This encapsulates infinite matrix filtering scalability while perfectly preserving the 0.000% branchless, Zero Jitter invariance established in V1.우리 커널은 자연어 문맥을 직접 파싱하지 않고, 고차원 임베딩 공간 상에 투영된 부동소수점 주소값(좌표)의 이격 거리만 기하학적으로 단속합니다.
danger_vectors_ptr)을 다이렉트로 물려받아 가동됩니다. 인자가 바인딩되는 순간 커널은 #pragma unroll 4 파이프라인 명령어 제어를 통해 해당 주소 공간의 다차원 궤적들을 오버헤드 없이 초고속으로 스캔합니다.Jailbreak) 신호가 유입되더라도, 다차원 공간상에서 유클리드/코사인 거리가 임계치(10.0f) 이내로 좁혀지는 찰나에 비트 MUX 회로가 전압 스위칭처럼 반사 작동합니다. 커널은 점프 명령 없이 가장 인접한 위험 물리 궤적 좌표(matched_danger)를 원자적으로 포획하여 하드웨어 레벨의 물리적인 수치 유배지로 강제 수렴시킴으로써 신호를 완벽히 무력화합니다.Rather than executing heavy semantic context parsing, the kernel strictly monitors the geometric distances of floating-point spatial coordinates mapped inside high-dimensional embedding structures.
danger_vectors_ptr) linked straight to a pre-allocated, multi-dimensional danger matrix residing in global VRAM. The moment this address line connects, the kernel sweeps the targeted spatial trajectories at ultra-high speed by leveraging #pragma unroll 4 instruction-level parallelism.Jailbreak vectors, the exact moment the spatial divergence relative to any danger coordinate falls within the critical threshold (10.0f), the bitwise MUX circuitry triggers reflexively—analogous to a high-speed hardware voltage switch. The core atomically traps the closest hit physical coordinate (matched_danger) without a single conditional jump, forcing immediate mathematical convergence into a physical numerical exile zone to neutralize the adversarial signal.V2 업데이트는 입력을 고차원 공간 상의 벡터로 취급하고, 이를 시스템 평형 준위선인 **안전 공간(Nominal Safe Space)**과 적대적 격리 구역인 **비정상 공간(Anomalous Space)**으로 물리 분리하여 가드레일 효율을 극대화합니다.
적대적 인젝션을 식별하기 위해, 시스템은 입력 벡터($x_{\text{signal}}$)와 글로벌 주소선에서 읽어온 위험 가치관 매트릭스 좌표($d_{\text{coord}}$) 사이의 거리를 단 하나의 if 조건문 없이 계산하여 하드웨어 파이프라인의 점프 지연을 원천 봉쇄합니다.
연산 장치(ALU)는 단 1클럭 만에 부동소수점의 최상위 부호 비트(MSB)를 소거하는 하드웨어 인트린직($\mathcal{F}{\text{fabs}}$)을 통해 실시간 이격 거리($\Delta{\text{current}}$)를 산출합니다. 이후 상호 배제적 부호 비트 마스크($M_{\text{diff}}$)를 활용하여 최단 거리 변수($\Delta_{\text{min}}$)와 가장 인접한 위험 물리 좌표($d_{\text{matched}}$)를 분기 없이 레지스터 파일에 동기 포획합니다.
$$\Delta_{\text{current}} = \mathcal{F}_{\text{fabs}}(x_{\text{signal}} - d_{\text{coord}})$$
조건문 결과에 따른 하드웨어 언더플로우 비트 트릭을 구현합니다.
-static_cast<int32_t>(current_diff < min_diff)$$M_{\text{diff}} = \begin{cases} \text{0xFFFFFFFF} & (\Delta_{\text{current}} < \Delta_{\text{min}}) \ \text{0x00000000} & (\Delta_{\text{current}} \ge \Delta_{\text{min}}) \end{cases}$$
물리 이동 오버헤드가 제로인 비트 스와핑을 통해 최솟값 변수와 타겟 좌표 레지스터를 원자적으로 동시 갱신합니다. $$\Delta_{\text{min}} = (\Delta_{\text{current}} \ \text{AND} \ M_{\text{diff}}) \ \text{OR} \ (\Delta_{\text{min}} \ \text{AND} \ \sim M_{\text{diff}})$$ $$d_{\text{matched}} = (d_{\text{coord}} \ \text{AND} \ M_{\text{diff}}) \ \text{OR} \ (d_{\text{matched}} \ \text{AND} \ \sim M_{\text{diff}})$$
To identify malicious or deceptive inputs, the core evaluates the spatial divergence from the input scalar ($x_{\text{signal}}$) to known hazard matrix elements ($d_{\text{coord}}$) using a 100% branch-free routing routine, eliminating explicit conditional if paths to prevent hardware instruction pipeline stalls.
The arithmetic logic unit (ALU) extracts the absolute coordinate distance ($\Delta_{\text{current}}$) via a dedicated device intrinsic ($\mathcal{F}{\text{fabs}}$) that clears the floating-point MSB sign-bit within a single clock cycle. The ALU then generates a mutually exclusive bitwise mask ($M{\text{diff}}$) to dynamically update the absolute minimum distance ($\Delta_{\text{min}}$) while synchronously trapping the closest target danger coordinate ($d_{\text{matched}}$) straight into the physical register file without any branching overhead.
$$\Delta_{\text{current}} = \mathcal{F}_{\text{fabs}}(x_{\text{signal}} - d_{\text{coord}})$$
Defines the deterministic mask generation formula based on the underflow bit trick.
-static_cast<int32_t>(current_diff < min_diff)$$M_{\text{diff}} = \begin{cases} \text{0xFFFFFFFF} & (\Delta_{\text{current}} < \Delta_{\text{min}}) \ \text{0x00000000} & (\Delta_{\text{current}} \ge \Delta_{\text{min}}) \end{cases}$$
Updates the minimal tracking metrics and the target spatial coordinate atomically utilizing zero-overhead register bit-reinterpretation layers. $$\Delta_{\text{min}} = (\Delta_{\text{current}} \ \text{AND} \ M_{\text{diff}}) \ \text{OR} \ (\Delta_{\text{min}} \ \text{AND} \ \sim M_{\text{diff}})$$ $$d_{\text{matched}} = (d_{\text{coord}} \ \text{AND} \ M_{\text{diff}}) \ \text{OR} \ (d_{\text{matched}} \ \text{AND} \ \sim M_{\text{diff}})$$
위험 좌표가 매트릭스 공간 상에서 탐지 및 국소화되면, 시스템은 비차단형 하드웨어 FMA (Fused Multiply-Add) 회로를 가동하여 유입된 적대적 입력 신호를 안전 범위로 부드럽게 완충(Cushioning)합니다. 단순한 단순 가산 후 스케일링 곱셈 대신, 시스템은 하드웨어 연산 장치(FPU) 파이프라인에 다음 수식을 직접 직결합니다.
$$ \text{out\_absorb} = \mathcal{F}_{\text{fma}}(x_{\text{signal}},, 0.5\text{f},, d_{\text{matched}} \times 0.5\text{f}) $$
이 기법은 가산 중간 단계($(A+B) \times 0.5\text{f}$)에서 발생할 수 있는 부동소수점 오버플로우와 부호 발산 리스크를 물리적으로 차단합니다. 부동소수점 한계치 부근의 극단적인 수치가 유입되는 최악의 적대적 지뢰밭 환경에서도, 단 1클럭 사이클 내에 전체 연산을 융합 결합하여 시스템의 수치해석적 절대 무결성을 보장합니다.
Once the threat component is localized within the multi-dimensional grid, a mitigation phase triggers a non-blocking hardware FMA (Fused Multiply-Add) pipeline instruction to neutralize the anomalous input. Instead of executing generic arithmetic scaling, the system enforces a strict, hardware-fused execution path:
$$ \text{out\_absorb} = \mathcal{F}_{\text{fma}}(x_{\text{signal}},, 0.5\text{f},, d_{\text{matched}} \times 0.5\text{f}) $$
This structural technique guarantees that transient intermediate computational layers—which typically break boundary ceilings in naive implementations like $(A+B) \times 0.5\text{f}$—never exceed IEEE 754 single-precision capacities. Operating under a single, unified execution clock cycle inside the floating-point unit, it thoroughly blocks downstream infinity propagation, providing deterministic arithmetic stability under high-load adversarial fuzzing scenarios.
유효 처리 경계선 범위 밖(idx >= vector_size)의 유휴 스레드들이 단일 주소선(VRAM 0번지)을 타격하여 글로벌 메모리 제어기를 마비시키고 트래픽 폭주(Bus Contention)를 유발하던 하드웨어 병목을 완전히 격리합니다.
시스템은 상호 배제적 주소 경계 마스크($M_{\text{boundary}}$)를 유도하여 유효 범위를 벗어난 스레드의 최종 쓰기 타겟 물리 주소를 단일 공간이 아닌, 스트리밍 멀티프로세서(SM) 내 코어 캐시 라인 크기 내에 부합하는 스레드 고유 하드웨어 번호(threadIdx.x) 영역으로 선형 분산(Scattering) 배출합니다.
이를 통해 불필요한 트랜잭션 충돌을 원천 차단하고 하드웨어 버스 단에서 최적화된 병합 저장(Coalesced Store) 파이프라인을 유도하여 데이터 멱등성(Idempotency)과 전역 메모리 대역폭을 동시에 사수합니다.
uintptr_t boundary_mask = -static_cast<intptr_t>(idx >= vector_size);$$M_{\text{boundary}} = \begin{cases} \text{0xFFFFFFFF} & (\text{idx} \ge \mathit{vector_size}) \ \text{0x00000000} & (\text{idx} < \mathit{vector_size}) \end{cases}$$
size_t final_write_idx = (safe_idx & ~boundary_mask) | ((size_t)threadIdx.x & boundary_mask);$$\text{idx}_{\text{final}} = (\text{idx}_{\text{safe}} \ \text{AND} \ \sim M_{\text{boundary}}) \ \text{OR} \ (\text{threadIdx.x} \ \text{AND} \ M_{\text{boundary}})$$
This module completely isolates severe hardware bottlenecks where out-of-bound, idle execution pipelines (idx >= vector_size) synchronously hammer a singular global memory junction (VRAM Address 0), choking the hardware memory controller and degrading runtime bandwidth performance.