deploy-edge-ai-phi4 — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited deploy-edge-ai-phi4 (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
# Download Phi-4 from HuggingFace
python scripts/download_model.py --model microsoft/phi-4 --output models/phi4-fp16
# Convert to ONNX
python -m optimum.exporters.onnx --model microsoft/phi-4 --task text-generation models/phi4-onnx/| Quantization | Model Size | RAM Required | Quality Loss | Speed |
|---|---|---|---|---|
| FP16 (original) | ~7.5 GB | ~8 GB | 0% | 1x |
| INT8 | ~3.8 GB | ~4 GB | 1-2% | 1.5x |
| INT4 (GPTQ) | ~2.0 GB | ~2.5 GB | 2-4% | 2x |
| INT4 (AWQ) | ~2.0 GB | ~2.5 GB | 1-3% | 2.2x |
# Quantize to INT4 with ONNX Runtime
python scripts/quantize.py --model models/phi4-onnx/ \
--output models/phi4-int4/ --bits 4 --method awqDevice compatibility matrix:
| Device | RAM | Storage | Recommended Quant |
|---|---|---|---|
| Raspberry Pi 5 (8GB) | 8 GB | 32 GB | INT4 (AWQ) |
| NVIDIA Jetson Nano | 4 GB | 16 GB | INT4 only |
| Laptop (16GB RAM) | 16 GB | 256 GB | INT8 or FP16 |
| Azure IoT Edge (VM) | 8+ GB | 64 GB | INT8 |
| Windows PC (32GB) | 32 GB | 512 GB | FP16 (full) |
import onnxruntime as ort
session_options = ort.SessionOptions()
session_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
session_options.intra_op_num_threads = 4 # Match device CPU cores
session_options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
# For GPU-enabled edge devices (Jetson, etc.)
providers = ['CUDAExecutionProvider', 'CPUExecutionProvider']
session = ort.InferenceSession("models/phi4-int4/model.onnx", session_options, providers=providers)# Register edge device
az iot hub device-identity create --hub-name $IOT_HUB --device-id edge-phi4-001
# Deploy model update via IoT Hub
az iot edge deployment create --hub-name $IOT_HUB \
--deployment-id phi4-v2 --content deployment.json --target-condition "tags.model='phi4'"# Offline inference (no cloud dependency)
def inference_offline(prompt, model_path="models/phi4-int4/"):
session = load_onnx_session(model_path)
tokens = tokenizer.encode(prompt)
output = session.run(None, {"input_ids": tokens})
return tokenizer.decode(output[0])
# With cloud fallback
def inference_hybrid(prompt):
try:
return inference_offline(prompt) # Try local first
except Exception:
return call_cloud_api(prompt) # Fallback to Azure OpenAI| Issue | Cause | Fix |
|---|---|---|
| OOM on device | Model too large for RAM | Use more aggressive quantization (INT4) |
| Slow inference (>5s) | CPU-only, no optimization | Enable graph optimization, reduce threads if IO-bound |
| ONNX load fails | Incompatible opset version | Re-export with matching ONNX Runtime version |
| Garbled output | Over-quantized | Switch from INT4 to INT8, check quality |
| IoT sync fails | Device offline too long | Increase queue buffer, implement reconnect |
| Model update stuck | Deployment not targeting device | Check IoT Hub target condition tag |
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.