Legacy Content Organization: ✅ MIGRATION EXAMPLES ARCHIVED: Moved legacy migration examples to documentation archive - docs/archive/migration_examples/: Moved from root directory for better organization - Contains GPU acceleration migration examples from CUDA to abstraction layer - Educational/reference material for historical context and migration procedures ✅ LEGACY CONTENT IDENTIFIED: - GPU Acceleration Migration: From CUDA-specific to backend-agnostic abstraction layer - Migration Patterns: BEFORE/AFTER code examples showing evolution - Legacy Import Paths: high_performance_cuda_accelerator, fastapi_cuda_zk_api - Deprecated Classes: HighPerformanceCUDAZKAccelerator, ProductionCUDAZKAPI ✅ DOCUMENTATION ARCHIVE CONTENTS: - MIGRATION_CHECKLIST.md: Step-by-step migration procedures - basic_migration.py: Direct CUDA calls to abstraction layer examples - api_migration.py: FastAPI endpoint migration examples - config_migration.py: Configuration migration examples ✅ ROOT DIRECTORY CLEANUP: Removed legacy examples from production directory - migration_examples/ moved to docs/archive/migration_examples/ - Root directory now contains only active production components - Legacy migration examples preserved for historical reference DIRECTORY STRUCTURE IMPROVEMENT: 📁 docs/archive/migration_examples/: Historical migration documentation 🏗️ Root Directory: Clean production structure with only active components 📚 Documentation Archive: Legacy content properly organized for reference BENEFITS: ✅ Clean Production Directory: No legacy examples in root ✅ Historical Preservation: Migration examples preserved for reference ✅ Better Organization: Legacy content grouped in documentation archive ✅ Clear Separation: Active vs legacy content clearly distinguished RESULT: Successfully moved legacy migration examples to docs/archive/migration_examples/ subdirectory, cleaning up the root directory while preserving historical migration documentation for future reference.
50 lines
1.4 KiB
Python
Executable File
50 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
API Migration Example
|
|
|
|
Shows how to migrate FastAPI endpoints to use the new abstraction layer.
|
|
"""
|
|
|
|
# BEFORE (CUDA-specific API)
|
|
# from fastapi_cuda_zk_api import ProductionCUDAZKAPI
|
|
#
|
|
# cuda_api = ProductionCUDAZKAPI()
|
|
# if not cuda_api.initialized:
|
|
# raise HTTPException(status_code=500, detail="CUDA not available")
|
|
|
|
# AFTER (Backend-agnostic API)
|
|
from fastapi import FastAPI, HTTPException
|
|
from pydantic import BaseModel
|
|
from gpu_acceleration import GPUAccelerationManager, create_gpu_manager
|
|
import numpy as np
|
|
|
|
app = FastAPI(title="Refactored GPU API")
|
|
|
|
# Initialize GPU manager (auto-detects best backend)
|
|
gpu_manager = create_gpu_manager()
|
|
|
|
class FieldOperation(BaseModel):
|
|
a: list[int]
|
|
b: list[int]
|
|
|
|
@app.post("/field/add")
|
|
async def field_add(op: FieldOperation):
|
|
"""Perform field addition with any available backend."""
|
|
try:
|
|
a = np.array(op.a, dtype=np.uint64)
|
|
b = np.array(op.b, dtype=np.uint64)
|
|
result = gpu_manager.field_add(a, b)
|
|
return {"result": result.tolist()}
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
@app.get("/backend/info")
|
|
async def backend_info():
|
|
"""Get current backend information."""
|
|
return gpu_manager.get_backend_info()
|
|
|
|
@app.get("/performance/metrics")
|
|
async def performance_metrics():
|
|
"""Get performance metrics."""
|
|
return gpu_manager.get_performance_metrics()
|