Metadata-Version: 2.4
Name: unpu
Version: 0.1.2
Summary: Universal Edge Acceleration & Memory Sweep Engine for NVIDIA GPU, Intel XPU, and CPU
Author: 최운교
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.20.0
Requires-Dist: torch>=2.0.0
Provides-Extra: triton
Requires-Dist: triton>=2.0.0; extra == "triton"
Provides-Extra: fasthardware
Requires-Dist: fasthardware; extra == "fasthardware"
Provides-Extra: all
Requires-Dist: triton>=2.0.0; extra == "all"
Requires-Dist: fasthardware; extra == "all"
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

Markdown
# UNPU (Universal Numerical Processing Unit)

**UNPU**는 NVIDIA GPU(Triton/CUDA), Intel XPU(Arc/MKL), 그리고 pure CPU(NumPy C-BLAS) 환경을 동적으로 감지하여 최적의 연산 파이프라인으로 실시간 라우팅해 주는 통합 가속 및 메모리 관리 라이브러리입니다.

---

## ✨ 핵심 기능

- **자동 하드웨어 라우팅**: NVIDIA CUDA, Intel XPU, CPU(YPU 타일링 연산)를 자동 감지 및 지연 시간 최소화 실행
- **PyTorch & NumPy 교차 연산**: `torch.Tensor`와 `numpy.ndarray` 입력을 구분 없이 한 번에 가속
- **통합 메모리 스위프**: Context 종료 시 VRAM 캐시 정리는 물론 `fasthardware` OS 가비지 수거 및 WorkingSet 회수 자동화
- **실시간 추론 전용 KV Cache**: 엣지 디바이스 LLM 및 시계열 추론을 위한 최적화 메모리 버퍼 제공

---

## 📦 설치 (Installation)

```bash
# 기본 설치
pip install unpu

# Triton 및 외부 메모리 스위퍼 옵션 포함 설치
pip install unpu[all]
```
🚀 빠른 사용법 (Quick Start)
1. 기본 매트릭스 연산 (Matrix Multiplication)
```Python
import torch
import unpu

# 하드웨어 자동 디바이스 감지 및 Context 진입
with unpu.UNPUContext() as dev:
    print(f"Active Engine: {dev.backend_str}")

    a = torch.randn(512, 1024)
    b = torch.randn(1024, 2048)
    
    # NVIDIA Triton -> Intel XPU -> CPU YPU 순서로 자동 라우팅
    c = unpu.unpu_matmul(a, b)
```
# Context 블록 이탈 시 VRAM 및 CPU WorkingSet 자동 Sweep 수행
2. NumPy 배열 CPU C-BLAS 가속 (YPU Engine)
```Python
import numpy as np
import unpu

a_np = np.random.randn(512, 1024).astype(np.float32)
b_np = np.random.randn(1024, 2048).astype(np.float32)

# NumPy C-Contiguous 레이아웃 변환 및 BLAS 가속 연산
res = unpu.ypu_matmul(a_np, b_np)
```
3. PyTorch 가속 레이어 적용
```Python
import torch
import torch.nn as nn
import unpu

class EdgeModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = unpu.UNPULinear(1024, 512)

    def forward(self, x):
        return self.fc(x)
```
📜 License
MIT License
