How to Deploy a Model
Deploying a model on InfraMind involves preparing a self-contained execution environment, defining its runtime behavior in a manifest, publishing it to decentralized storage, and registering it with the protocol so that jobs can be routed to eligible nodes. The process is deterministic and reproducible, allowing models to be executed identically across hundreds or thousands of mesh nodes with no configuration drift.
This section outlines the standard deployment process using the CLI (infra
), but each step can also be done manually using Docker, IPFS, and curl.
Step 1: Containerize the Model
Start by creating a directory for the model container:
mkdir summarizer-v1 && cd summarizer-v1
Add your model serving script (e.g. serve.py
) and requirements.txt
:
# serve.py
from fastapi import FastAPI, Request
import uvicorn
app = FastAPI()
@app.post("/inference")
async def infer(req: Request):
data = await req.json()
input_text = data.get("text")
summary = input_text[:64] + "..." # Stub summarization
return {"summary": summary}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=9000)
# requirements.txt
fastapi
uvicorn
Write the Dockerfile
:
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 9000
CMD ["python", "serve.py"]
Build the container:
docker build -t summarizer-v1 .
Export it to a tarball:
docker save summarizer-v1 | gzip > summarizer-v1.tar.gz
Step 2: Write model.yaml
This manifest defines the model's runtime behavior, input/output schema, and resource requirements. Create a file model.yaml
:
name: summarizer-v1
version: 0.1.0
entrypoint: serve.py
runtime: python3.10
protocol: rest
port: 9000
resources:
cpu: 2
memory: 2Gi
gpu: false
input_schema:
type: object
properties:
text:
type: string
required: [text]
output_schema:
type: object
properties:
summary:
type: string
required: [summary]
InfraMind nodes use this file to validate input payloads, configure container limits, and expose the endpoint schema for automated documentation.
Step 3: Push to IPFS or Registry
Package the model directory for upload:
tar -czf model-bundle.tar.gz model.yaml summarizer-v1.tar.gz
Upload to IPFS:
ipfs add --wrap-with-directory model-bundle.tar.gz
Output:
added QmXab... model-bundle.tar.gz
added QmYuv... model-bundle.tar.gz/
Take the CID of the directory (QmYuv...
) as the canonical reference.
Alternatively, publish to the InfraMind-hosted registry:
infra publish --model model.yaml --image ./summarizer-v1.tar.gz
The CLI will push the image to the default storage backend and return the container hash.
Step 4: Register Endpoint
Once the image is hosted and the manifest is validated, register it to the InfraMind mesh:
infra register --name summarizer-v1 \
--cid ipfs://QmYuv... \
--entrypoint serve.py \
--version 0.1.0
This writes a model index entry:
{
"model_id": "summarizer-v1",
"version": "0.1.0",
"owner": "0xB1F...",
"container_ref": "ipfs://QmYuv...",
"entrypoint": "serve.py",
"created_at": 1720210900
}
The endpoint becomes active:
https://api.inframind.host/inference/v1/summarizer-v1
Test it:
curl -X POST https://api.inframind.host/inference/v1/summarizer-v1 \
-H "Content-Type: application/json" \
-d '{"text": "InfraMind is a protocol for decentralized AI model serving."}'
Expected result:
{"summary": "InfraMind is a protocol for decentralized AI model serving..."}
Container Update and Versioning
To deploy a new version:
docker build -t summarizer-v1:v0.1.1 .
docker save summarizer-v1:v0.1.1 | gzip > summarizer-v1-v0.1.1.tar.gz
infra publish --model model.yaml --image ./summarizer-v1-v0.1.1.tar.gz
infra register --name summarizer-v1 --version 0.1.1 --cid ipfs://QmNew...
Versioning is immutable. Each version receives its own hash and cannot be overwritten. Old versions remain active unless manually revoked.
Security and Authenticity
Each model is signed at registration using the deployer’s private key. Nodes verify:
Manifest digest
Image hash
Entry script existence
Schema compliance
Only models that pass full validation are scheduled for execution.
Summary
Deploying on InfraMind means turning your model into a verifiable runtime package, pushing it to decentralized storage, and exposing it to the global mesh through a signed registration. The process takes under 10 minutes and produces a portable container that can run anywhere in the world, on any compliant node, with no DevOps required.
Last updated