File size: 11,240 Bytes
506ca47 99f62cc ac4ea8b 99f62cc 506ca47 99f62cc 506ca47 99f62cc 506ca47 99f62cc 3a2c6b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
---
title: RustVital-AMD
emoji: π₯
colorFrom: blue
colorTo: purple
sdk: docker
pinned: true
---
<div align="center">
<img src="https://img.shields.io/badge/Rust-1.95-dea584?logo=rust&logoColor=white" alt="Rust"/>
<img src="https://img.shields.io/badge/AMD-ROCm-ED1C24?logo=amd&logoColor=white" alt="AMD ROCm"/>
<img src="https://img.shields.io/badge/Model-Qwen2.5_7B-615EFF?logo=huggingface&logoColor=white" alt="Qwen2.5"/>
<img src="https://img.shields.io/badge/Chain-Base_Sepolia-0052FF?logo=ethereum&logoColor=white" alt="Base Sepolia"/>
<img src="https://img.shields.io/badge/Audit-Filecoin_CID-0090FF?logo=ipfs&logoColor=white" alt="Filecoin CID"/>
</div>
# π₯ RustVitalβAMD β ZeroβTrust Medical AI Triage Gateway
**Pure Rust β’ AMD MI300X GPU β’ Real Web3 Audit Trail**
RustVitalβAMD is a productionβgrade, zeroβtrust medical triage agent that **never exposes raw patient data to the AI model**. It accepts clinical notes, strips personally identifiable information (PII) before the GPU ever sees them, runs inference on a real **Qwen2.5β7B** model backed by an **AMD MI300X** GPU, and rehydrates the response so the clinician sees a perfectly normal clinical report. Every triage is cryptographically proven and permanently anchored onβchain via **Filecoin CID** and **Base Sepolia**.
π **Live Demo:** [Launch on Hugging Face Spaces](https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/rustvital-amd)
---
## 𧬠Key Features
- **π‘οΈ ZeroβTrust PII Shield** β Deterministic, preβGPU redaction of names, ages, SSN, MRN, insurance IDs, and more.
- **π§ Real AMD MI300X Inference** β Calls a live vLLM endpoint running Qwen2.5β7B on ROCm, with graceful CPU fallback.
- **π‘ Streaming Agent Observability** β WebSocket + SSE endpoint show every pipeline step in real time.
- **π PubMed Enrichment** β Queries NCBI Eβutilities for relevant biomedical literature after each triage.
- **π©» DICOM Surrogate Redaction** β Demonstrates multiβmodal PII removal from medical imaging headers and burnedβin text.
- **π Cryptographic Audit** β A ZKβsimulated proof of correct redaction is generated and verified on every request.
- **βοΈ Blockchain Immutability** β Each triage produces a Filecoin CID and an onβchain transaction on Base Sepolia (via alloyβrs).
- **π₯ Consortium Attestations** β Simulates three independent hospital attestations, creating a decentralised trust model.
- **βοΈ Federated FineβTuning Trigger** β Exposes an endpoint that launches a LoRA fineβtuning job on MI300X, using only redacted data.
- **π¨ Professional Dark UI** β Built with HTMX + Alpine.js + Tailwind CSS, served from Axum with no JavaScript build step.
---
## π How It Works
```
βββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββββ
β Clinician β β RustVital-AMD β β AMD MI300X GPU β
β (Browser) β β (Axum Server) β β (vLLM + ROCm HIP) β
βββββββββ¬ββββββββ ββββββββββββ¬βββββββββββ βββββββββββββ¬ββββββββββββ
β Submit consent form β β
ββββββββββββββββββββββββββΊβ β
β β (1) PII Shield β
β β Redact PHI from note β
β β Generate ZKβstyle proof β
β β β
β β (2) Send redacted prompt β
β βββββββββββββββββββββββββββββββΊβ
β β β Run Qwen2.5β7B
β ββββββββββββββββββββββββββββββββ
β β (3) Clinical synthesis β
β β β
β β (4) Enrich with PubMed β
β β (5) Compute CID + anchor β
β β on Base Sepolia β
β β (6) Simulate consortium β
β β attestations β
β β β
βββββββββββββββββββββββββββ (7) Return rehydrated resultβ
β View real report β β
β (PII never revealed) β β
```
---
## π οΈ Technology Stack
| Layer | Technology |
|---------------------|-------------------------------------|
| **Language** | Rust (edition 2021) |
| **Web Framework** | Axum + Tower + Tokio |
| **Inference** | vLLM (OpenAIβcompatible) on AMD ROCm|
| **LLM** | Qwen2.5β7BβInstruct |
| **PII Shield** | Custom regex engine (deterministic) |
| **Crypto** | SHAβ256, ECDSA (k256), ZKβsimulated |
| **Blockchain** | alloyβrs β Base Sepolia testnet |
| **CID** | cid + sha2 β Filecoinβcompatible |
| **Medical APIs** | NCBI Eβutilities (PubMed) |
| **UI** | HTMX + Alpine.js + Tailwind CSS |
| **Observability** | WebSocket + ServerβSent Events |
| **Deployment** | Docker, Hugging Face Spaces |
---
## π Use Cases
### π Emergency Room Triage
A clinician pastes a raw ambulance report. The system redacts patient identity, runs the case through the MI300X, and instantly returns a structured clinical assessment with PubMed references β all while **maintaining HIPAA compliance** and **creating an immutable legal audit trail**.
### π₯ MultiβHospital Consortium
Three independent hospitals can run RustVitalβAMD nodes. After each triage, they attest to the correctness of the redaction proof. The onβchain record shows consensus, giving regulators and insurers **cryptographic proof that PII was never exposed**.
### π Continuous Federated Learning
Hospitals trigger fineβtuning jobs on their own AMD GPUs using only **deβidentified logs**. The model improves without any raw patient data leaving the gateway. The system logs every training event, creating a **fully auditable model lineage** onβchain.
---
## βοΈ Quick Start (Local Development)
### Prerequisites
- Rust 1.90+ (stableβtoolchain)
- An AMD MI300X instance running vLLM (or the [Hugging Face Space](https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/rustvital-amd) for immediate testing)
- Base Sepolia wallet (optional, for onβchain transactions)
### 1. Clone the repository
```bash
git clone https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/rustvital-amd
cd rustvital-amd
```
### 2. Configure environment
Create a `.env` file:
```env
VLLM_URL=http://129.212.188.154:8000/v1/chat/completions
PUBMED_EMAIL=you@example.com
PRIVATE_KEY=your_base_sepolia_private_key_hex
PORT=7860
```
### 3. Build & Run
```bash
cargo build --release
cargo run
```
The server will start on `http://localhost:7860`. Open the URL in your browser.
### 4. Connect to real GPU
If you have a droplet running vLLM, expose it with Cloudflare Tunnel:
```bash
cloudflared tunnel --url http://localhost:8000
```
Then update `VLLM_URL` with the generated `https://*.trycloudflare.com/v1/chat/completions` address.
---
## π‘ API Endpoints
| Method | Path | Description |
|--------|---------------------------|-------------|
| `GET` | `/` | Serves the interactive UI |
| `GET` | `/health` | Liveness check (`healthy`) |
| `GET` | `/status` | GPU status, model info, triage count |
| `POST` | `/triage/html` | Formβencoded triage request (returns HTML) |
| `POST` | `/triage` | JSON triage request (`TriageRequest` β `TriageResponse`) |
| `GET` | `/triage/stream` | SSE stream of agent events (Shield β Triage β Audit) |
| `GET` | `/agents/status` | WebSocket for realβtime agent states |
| `POST` | `/dicom/redact` | Upload a DICOM file for metadata / burnedβin text redaction |
| `GET` | `/medical/enrich` | Fetch PubMed evidence for a given clinical note |
| `POST` | `/trigger-federated-tune` | Launch a simulated federated LoRA fineβtuning job |
| `GET` | `/federation/round` | Show current federated learning round and nodes |
| `GET` | `/dashboard` | HTML fragment of recent triage history |
| `GET` | `/history` | JSON list of all triage records |
---
## βοΈ Deployment
The project is containerised with Docker. A preβbuilt image is automatically deployed to Hugging Face Spaces on every push.
### Dockerfile (production)
```dockerfile
FROM rust:1.95-slim-bookworm AS builder
RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY Cargo.toml Cargo.lock* ./
COPY src src
COPY static static
COPY contracts contracts
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/rustvital-amd /usr/local/bin/rustvital-amd
EXPOSE 7860
ENV PORT=7860
CMD ["rustvital-amd"]
```
### Hugging Face Space Secrets
Set these in **Settings β Secrets**:
| Key | Value |
|-----|-------|
| `VLLM_URL` | `https://*.trycloudflare.com/v1/chat/completions` |
| `PUBMED_EMAIL` | Your email for NCBI rate limits |
| `PRIVATE_KEY` | Base Sepolia hex private key (without `0x`) |
---
## π Hackathon Tracks
- **AI Agents & Agentic Workflows** (main)
- **FineβTuning on AMD GPUs** (LoRA on MI300X)
- **Hugging Face Challenge** (Space deployed)
- **Qwen Challenge** (Qwen2.5β7B via vLLM)
- **Build in Public** (updates on [X/Twitter](https://x.com/MoonloungeBrain))
---
## π€ Contributing
This project was built solo for the AMD Developer Hackathon (May 2026). Contributions are welcome via pull requests. Please discuss major changes first in the [Hugging Face Community tab](https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/rustvital-amd/discussions).
---
## π License
MIT License β see the `LICENSE` file (if present) or the [Hugging Face Space page](https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/rustvital-amd) for details.
---
**Built with β€οΈ, Rust, and AMD ROCm for the AMD Developer Hackathon 2026.**
```
|