### Initial Setup Commands Source: https://github.com/ai-dynamo/modelexpress/blob/main/CONTRIBUTING.md Initial setup commands for cloning the repository, installing pre-commit hooks, building the project, running tests, and optionally installing the Python P2P client for development. ```bash git clone cd modelexpress # Install pre-commit hooks pip install pre-commit pre-commit install # Build the project cargo build # Run tests cargo test # (Optional) Install the Python P2P client for development pip install -e modelexpress_client/python[dev] ``` -------------------------------- ### Start server with configuration file Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Start the server using a configuration file. Backend environment variables are still required. ```bash # With a configuration file (backend env vars still required) MX_METADATA_BACKEND=redis REDIS_URL=redis://localhost:6379 \ cargo run --bin modelexpress-server -- --config model-express.yaml ``` -------------------------------- ### Quick Start: Clone, install, and serve with ModelExpress P2P Source: https://github.com/ai-dynamo/modelexpress/blob/main/README.md Sets up the P2P path for ModelExpress with NIXL and a metadata backend. Requires vLLM 0.23.0+, the ModelExpress Python package, NIXL-compatible GPU nodes, and a reachable metadata backend. JIT artifact transfer needs MX_P2P_METADATA=1, a central-coordinator backend (redis or kubernetes), and writable target staging and runtime cache directories; omit MX_ARTIFACT_TRANSFER for weight-only transfer or when using the decentralized k8s-service backend. ```bash git clone https://github.com/ai-dynamo/modelexpress.git cd modelexpress python -m pip install ./modelexpress_client/python export MX_SERVER_ADDRESS=modelexpress-server:8001 export MX_P2P_METADATA=1 export MX_ARTIFACT_TRANSFER=1 vllm serve deepseek-ai/DeepSeek-V4-Pro \ --load-format modelexpress \ --tensor-parallel-size 8 \ --trust-remote-code ``` -------------------------------- ### Install and run pre-commit hooks Source: https://github.com/ai-dynamo/modelexpress/blob/main/README.md Install and run pre-commit hooks for this project. Run these commands from the repository root after cloning. ```bash pip install pre-commit && pre-commit install pre-commit run --all-files ``` -------------------------------- ### Install prometheus-client via modelexpress[metrics] Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/METRICS.md Install the 'metrics' extra to get prometheus-client, required for client metrics. Engine images like vLLM, SGLang, and TensorRT-LLM already include it, so this is only needed for custom images. If missing, the collector disables itself and the symptom is up == 0. ```bash pip install "modelexpress[metrics]" ``` -------------------------------- ### Start server with CLI overrides Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Start the server with CLI overrides for port and log level. Backend environment variables are still required. ```bash # With CLI overrides MX_METADATA_BACKEND=redis REDIS_URL=redis://localhost:6379 \ cargo run --bin modelexpress-server -- --port 8080 --log-level debug ``` -------------------------------- ### Start server with Redis backend Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Start the ModelExpress server with the Redis metadata backend. Requires MX_METADATA_BACKEND and REDIS_URL environment variables. ```bash # Redis backend export MX_METADATA_BACKEND=redis export REDIS_URL=redis://localhost:6379 cargo run --bin modelexpress-server ``` -------------------------------- ### Install ModelExpress Helm Chart Source: https://github.com/ai-dynamo/modelexpress/blob/main/helm/README.md Basic Helm installation command for the ModelExpress chart from the ./helm directory. ```bash helm install modelexpress ./helm ``` -------------------------------- ### Start vLLM server with modelexpress plugin Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/S3_DELTA_WEIGHT_REFIT.md Starts vLLM with the modelexpress plugin. Requires VLLM_SERVER_DEV_MODE=1, VLLM_PLUGINS=modelexpress, and MX_SERVER_ADDRESS set. The weight-transfer-config backend must be 'modelexpress'. ```bash export VLLM_SERVER_DEV_MODE=1 export VLLM_PLUGINS=modelexpress export MX_SERVER_ADDRESS=modelexpress:8001 vllm serve /models/Qwen3-30B-A3B \ --tensor-parallel-size 4 \ --weight-transfer-config '{"backend":"modelexpress"}' ``` -------------------------------- ### Start server with Kubernetes backend Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Start the ModelExpress server with the Kubernetes metadata backend, typically only useful in-cluster. Requires MX_METADATA_BACKEND and POD_NAMESPACE (or MX_METADATA_NAMESPACE) environment variables. ```bash # Kubernetes backend (typically only useful in-cluster) export MX_METADATA_BACKEND=kubernetes export POD_NAMESPACE=default # or MX_METADATA_NAMESPACE cargo run --bin modelexpress-server ``` -------------------------------- ### Run the Dynamo + vLLM S3 delta-refit example Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/rl/dynamo_vllm_s3_delta_refit/README.md Sets environment variables and runs the example script. Requires a unique namespace (e.g., zheng) and the images visible to the cluster. A successful run ends with both 'E2E PASS: ...' and 'RESTART ...'. ```bash export NAMESPACE=zheng export RUN_ID=mx-s3-$(date +%s) export MODEL_NAME=Qwen/Qwen3-0.6B export MODEL_SUBPATH=Qwen/Qwen3-0.6B export WORKER_IMAGE="$REGISTRY/modelexpress-dynamo-vllm:$MX_COMMIT-s3-refit" export DYNAMO_FRONTEND_IMAGE=nvcr.io/nvidia/ai-dynamo/dynamo-frontend-nightly:20260909-c3e05f0 examples/rl/dynamo_vllm_s3_delta_refit/run.sh ``` -------------------------------- ### Deploy Dynamo model cache example Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Deploys ModelExpress alongside Dynamo with a vLLM worker using the example manifest. ```bash kubectl apply -f examples/dynamo_model_cache_k8s/agg.yaml ``` -------------------------------- ### SGLang launch with ModelExpress backend Source: https://github.com/ai-dynamo/modelexpress/blob/main/modelexpress_client/python/README.md Starts an SGLang server using the ModelExpress remote_instance loader. Requires an SGLang image with upstream sgl-project/sglang#24723, such as lmsysorg/sglang:v0.5.13.post1, and the ModelExpress package installed. Sets MX_SERVER_ADDRESS to the ModelExpress server and uses the modelexpress weight loader backend with NIXL transport. ```bash export MX_SERVER_ADDRESS="modelexpress-server:8001" python -m sglang.launch_server \ --model-path deepseek-ai/DeepSeek-V3 \ --tp 8 \ --load-format remote_instance \ --remote-instance-weight-loader-backend modelexpress \ --modelexpress-config '{"transport": "nixl"}' ``` -------------------------------- ### Set environment variables and run the example script Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/rl/vime_dynamo_delta_refit/README.md Exports namespace, worker image, trainer image, and model subpath, then runs the run.sh script. The script prints the trainer log and ends with 'TRAINING COMPLETE'. ```bash export NAMESPACE="" export WORKER_IMAGE="registry.example.com/team/vime-dynamo-mx-worker:delta-refit" export TRAINER_IMAGE="registry.example.com/team/vime-dynamo-mx-trainer:delta-refit" export MODEL_SUBPATH="" examples/rl/vime_dynamo_delta_refit/run.sh ``` -------------------------------- ### Install modelexpress vLLM plugin entry point Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/S3_DELTA_WEIGHT_REFIT.md TOML configuration for the vLLM plugin entry point. Install the modelexpress package in the same environment as vllm serve to enable the plugin. ```toml [project.entry-points."vllm.general_plugins"] modelexpress = "modelexpress:register_modelexpress" ``` -------------------------------- ### Deploy multi-GPU-per-pod (primary) Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/k8s_service_sources/README.md Apply the multi-GPU-per-pod deployment manifest, wait for the pod to be ready, get the service, and scale to add replicas. New replicas pull via P2P from existing ones. ```bash kubectl apply -f sources-tp2-single-pod.yaml kubectl wait --for=condition=Ready pod -l app=mx-sources --timeout=15m kubectl get svc mx-sources # Scale to add more replicas (new ones pull via P2P from existing). kubectl scale deployment mx-sources --replicas=4 ``` -------------------------------- ### Build and push SGLang client image Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Builds and pushes a custom client image for GPU-to-GPU weight transfers with SGLang. The image starts from lmsysorg/sglang:v0.5.13.post1 and installs the ModelExpress Python package with --no-deps to preserve the base CUDA/NIXL/Torch stack. Add --build-arg INSTALL_MOONCAKE=true to install mooncake-transfer-engine-cuda13. ```bash docker build -f examples/p2p_transfer_k8s/client/sglang/Dockerfile \ -t your-registry/sglang-modelexpress:TAG . docker push your-registry/sglang-modelexpress:TAG ``` -------------------------------- ### Advanced CLI Usage Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/CLI.md Examples of using custom endpoints, timeouts, verbose logging, custom cache paths, and file payloads. ```bash # Connect to remote server with custom timeout modelexpress-cli --endpoint https://my-server.com:8001 \ --timeout 60 \ health # Download model with verbose logging modelexpress-cli -vv model download microsoft/DialoGPT-small \ --strategy server-only # Download model with custom storage path modelexpress-cli --cache-path /custom/storage/path \ model download google-t5/t5-small # Send API request with file payload and JSON output modelexpress-cli --format json api send process-batch \ --payload-file batch-data.json # Get model storage statistics in JSON format modelexpress-cli --format json model stats --detailed ``` -------------------------------- ### Install ModelExpress via pip Source: https://github.com/ai-dynamo/modelexpress/blob/main/modelexpress_client/python/README.md Commands to install the ModelExpress package from PyPI, source, or with specific development and code generation dependencies. ```bash # From PyPI (coming soon) pip install modelexpress # Editable install from source pip install -e . # With test dependencies pip install -e ".[dev]" # Additionally install the pinned protobuf code generator when changing protobuf APIs pip install -e ".[codegen]" ``` -------------------------------- ### Example ModelExpress URI Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/model_streamer_k8s/client/vllm/README.md Example ModelExpress URI for the DeepSeek-V3 model with the given container and prefix. ```bash az://models/models/deepseek-ai/DeepSeek-V3 ``` -------------------------------- ### Install ModelExpress CRDs Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/dynamo_p2p_transfer_k8s/README.md Installs the ModelMetadata and ModelCacheEntry CRDs in one pass. Requires cluster-admin privileges. ```bash kubectl apply -f examples/crds.yaml ``` -------------------------------- ### Query download start and error rates with mx_registry_status_transitions_total Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/METRICS.md Two PromQL queries showing the rate of downloads starting and ending in error over a 5-minute window. These transition counters answer flow rather than level. ```promql sum(rate(mx_registry_status_transitions_total{to="downloading"}[5m])) ``` ```promql sum(rate(mx_registry_status_transitions_total{to="error"}[5m])) ``` -------------------------------- ### Validate configuration without starting Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Validate the configuration file without starting the server. Backend environment variables are still required because the validator parses the full startup path including MX_METADATA_BACKEND. ```bash # Validate config without starting (backend env vars still required — the validator # parses the full startup path including MX_METADATA_BACKEND) MX_METADATA_BACKEND=redis REDIS_URL=redis://localhost:6379 \ cargo run --bin modelexpress-server -- --config model-express.yaml --validate-config ``` -------------------------------- ### Run ModelExpress with Docker Compose Source: https://github.com/ai-dynamo/modelexpress/blob/main/README.md Builds and starts the ModelExpress Docker Compose stack. Use this for local development or testing. ```bash docker compose -f docker/docker-compose.yml up --build ``` -------------------------------- ### Run Redis and ModelExpress server locally Source: https://github.com/ai-dynamo/modelexpress/blob/main/CONTRIBUTING.md Starts a local Redis container and runs the ModelExpress server with the Redis metadata backend. Requires Docker and a Rust toolchain with cargo. ```bash docker run --rm -d -p 6379:6379 --name mx-redis redis:7-alpine MX_METADATA_BACKEND=redis REDIS_URL=redis://localhost:6379 cargo run -p modelexpress-server ``` -------------------------------- ### Build and push trainer and worker images Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/rl/vime_dynamo_delta_refit/README.md Uses docker buildx to build and push the trainer and worker images from the example Dockerfile. The worker build uses a local dynamo checkout as a build context. ```bash docker buildx build \ -f examples/rl/vime_dynamo_delta_refit/Dockerfile \ --target trainer --push \ -t registry.example.com/team/vime-dynamo-mx-trainer:delta-refit . docker buildx build \ -f examples/rl/vime_dynamo_delta_refit/Dockerfile \ --build-context dynamo=../dynamo --target worker --push \ -t registry.example.com/team/vime-dynamo-mx-worker:delta-refit . ``` -------------------------------- ### Install ModelExpress Helm Chart Source: https://github.com/ai-dynamo/modelexpress/blob/main/helm/README.md Installs the ModelExpress Helm chart with default values, custom values file, or in a specific namespace. The namespace variant creates the namespace if it does not exist. ```bash # Install with default values helm install my-modelexpress ./helm # Install with custom values helm install my-modelexpress ./helm -f values.yaml # Install in a specific namespace helm install my-modelexpress ./helm --namespace modelexpress --create-namespace ``` -------------------------------- ### Example GCS model URLs Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/GCS_PROVIDER.md Example GCS model URLs that follow the required format. The bucket component must be a single path segment. ```text gs://model-bucket/deepseek-ai/DeepSeek-V3/rev-1 gs://model-bucket/org/model/snapshots/2026-04-29 ``` -------------------------------- ### Dockerfile: Install local ModelExpress package Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/SGLANG.md Dockerfile for installing a local ModelExpress package into a custom SGLang image built from a local PR branch. ```dockerfile FROM sglang-source:modelexpress COPY modelexpress_client/python /tmp/modelexpress_client_python RUN python3 -m pip install --no-cache-dir --no-deps /tmp/modelexpress_client_python ``` -------------------------------- ### Monitor Model Express Server Logs Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/dynamo_model_cache_k8s/README.md Monitor the Model Express server logs. The sample output shows the server starting, downloading the Qwen/Qwen3-0.6B model from HuggingFace, and creating a symlink. ```bash kubectl logs -f vllm-agg-modelexpressserver-544b666cbc-2ll6d ``` ```text Starting Model Express Server... Server started with PID: 7 Setting up Model Express configuration... Waiting for server to be ready... Server is ready! Downloading Qwen/Qwen3-0.6B model... Model Download Model: Qwen/Qwen3-0.6B Provider: HuggingFace Strategy: ServerOnly SUCCESS Model 'Qwen/Qwen3-0.6B' downloaded successfully Created symlink: latest -> c1899de289a04d12100db370d81485cdf75e47ca ``` -------------------------------- ### ServerConfig YAML example Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/ARCHITECTURE.md Example ServerConfig YAML for the Rust server. Shows the default configuration structure with environment variable overrides for host, port, cache directory, eviction, and logging. Note that distributed backend selection (MX_METADATA_BACKEND, REDIS_URL, POD_NAMESPACE) is configured via environment variables, not in this YAML. ```yaml server: host: "0.0.0.0" # MODEL_EXPRESS_SERVER_HOST port: 8001 # MODEL_EXPRESS_SERVER_PORT cache: directory: "./cache" # MODEL_EXPRESS_CACHE_DIRECTORY max_size_bytes: null eviction: enabled: true # MODEL_EXPRESS_CACHE_EVICTION_ENABLED policy: type: lru unused_threshold: "7d" max_models: null min_free_space_bytes: null check_interval: "1h" logging: level: info # MODEL_EXPRESS_LOG_LEVEL format: pretty # MODEL_EXPRESS_LOG_FORMAT file: null structured: false ``` -------------------------------- ### Build and test commands for modelexpress Source: https://github.com/ai-dynamo/modelexpress/blob/main/AGENTS.md Common build, test, lint, run, and benchmark commands for the modelexpress project. Use `cargo clippy` with no warnings, and `./run_integration_tests.sh` to start the server for integration tests. ```bash cargo build # Build cargo build --release # Release build cargo test # Run all tests cargo clippy # Lint (must pass, no warnings) cargo run --bin modelexpress-server # Run server cargo run --bin config_gen -- --output model-express.yaml # Generate config cargo run --bin test_client -- --test-model "google-t5/t5-small" # Test client cargo run --bin fallback_test # Fallback test cargo bench # Criterion benchmarks ./run_integration_tests.sh # Integration tests (starts server) ``` -------------------------------- ### Regenerate Go bindings with protoc plugins Source: https://github.com/ai-dynamo/modelexpress/blob/main/modelexpress_client/go/README.md Installs the pinned protoc plugins and runs the generator script. Execute these commands from the modelexpress_client/go directory to regenerate the bindings and run tests. ```bash go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.11 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.6.0 cd modelexpress_client/go ./generate_proto.sh go test ./... ``` -------------------------------- ### Build the TensorRT-LLM ModelExpress Docker image Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/p2p_transfer_k8s/client/trtllm/README.md Builds the example Docker image from the repository root, using a TensorRT-LLM release image as the base. Override TRTLLM_IMAGE to use a different release. The image uses the release's NIXL bindings, so no PYTHONPATH or LD_LIBRARY_PATH configuration is needed. ```bash docker build \ --build-arg TRTLLM_IMAGE=nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc22 \ -f examples/p2p_transfer_k8s/client/trtllm/Dockerfile \ -t /trtllm-modelexpress:latest \ . ``` -------------------------------- ### Generated configuration file (model-express.yaml) Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Example YAML configuration file generated by config_gen, showing server, cache, and logging settings with defaults. ```yaml server: host: "0.0.0.0" port: 8001 cache: directory: "./cache" max_size_bytes: null eviction: enabled: true policy: type: lru unused_threshold: "7d" max_models: null min_free_space_bytes: null check_interval: "1h" logging: level: info format: pretty file: null structured: false ``` -------------------------------- ### ModelCacheEntry CRD Example Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/metadata.md A sample YAML definition for a ModelCacheEntry resource, showing the model name, provider, and current lifecycle status. ```yaml apiVersion: modelexpress.nvidia.com/v1alpha1 kind: ModelCacheEntry metadata: name: mx-cache-huggingface--deepseek-ai--deepseek-v3- spec: modelName: deepseek-ai/DeepSeek-V3 provider: HuggingFace status: phase: Downloaded createdAt: "2026-04-29T22:00:00Z" lastUsedAt: "2026-04-29T22:10:00Z" message: Model download completed successfully ``` -------------------------------- ### ModelMetadata CRD Example Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/metadata.md A sample YAML definition for a ModelMetadata resource, illustrating the owner reference to a Pod and the status fields for a ready worker. ```yaml apiVersion: modelexpress.nvidia.com/v1alpha1 kind: ModelMetadata metadata: name: mx-source-a1b2c3d4e5f67890-f3a2b1c4 ownerReferences: - apiVersion: v1 kind: Pod name: mx-vllm-7d9f8f6c8b-k2m4p uid: 8c69d55f-3e40-4b6e-a16b-6f0c1168e171 controller: false blockOwnerDeletion: false labels: modelexpress.nvidia.com/mx-source-id: a1b2c3d4e5f67890 modelexpress.nvidia.com/mx-worker-id: f3a2b1c4 spec: modelName: deepseek-ai/DeepSeek-V3 status: worker: workerRank: 0 backendType: nixl nixlMetadata: tensorCount: 1327 tensorConfigMap: mx-source-a1b2c3d4e5f67890-f3a2b1c4-tensors-worker-0 accelerator: cuda status: Ready updatedAt: "2025-11-14T22:13:20Z" conditions: - type: Ready status: "True" reason: WorkerReady message: Worker is ready lastTransitionTime: "2025-11-14T22:13:20Z" observedGeneration: 1 publishedAt: "2025-11-14T22:13:20Z" ``` -------------------------------- ### Monitor Deployment with kubectl get po Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/dynamo_model_cache_k8s/README.md Monitor the deployment by listing pods. The sample output shows all pods running, including the Model Express server and VLLM worker. ```bash kubectl get po ``` ```text NAME READY STATUS RESTARTS AGE dynamo-platform-dynamo-operator-controller-manager-54d48f4vdkh8 2/2 Running 8 (12d ago) 15d dynamo-platform-etcd-0 1/1 Running 4 (12d ago) 15d dynamo-platform-nats-0 2/2 Running 8 (12d ago) 15d dynamo-platform-nats-box-5dbf45c748-vstcm 1/1 Running 4 (12d ago) 15d vllm-agg-frontend-569757b8f5-brnbq 1/1 Running 0 23m vllm-agg-modelexpressserver-544b666cbc-2ll6d 1/1 Running 0 23m vllm-agg-vllmdecodeworker-69dcddfc85-zcwd7 1/1 Running 0 23m ``` -------------------------------- ### P2P diagnostics commands Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/TROUBLESHOOTING.md Confirm source and target have ModelExpress runtime integration, NIXL and fabric resources, a reachable metadata path, compatible model revision and parallelism, and matching dtype, quantization, and accelerator identity. The first replica must reach readiness and publish before the target starts. These commands inspect ModelMetadata resources, server logs, and target runtime container logs. ```bash kubectl get modelmetadatas -A kubectl logs -n deploy/modelexpress-server kubectl logs -n -c ``` -------------------------------- ### JSON processing with jq Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/CLI.md Examples of parsing JSON output from the CLI using jq to extract server status, storage statistics, and model information. ```bash # Get server uptime in a script UPTIME=$(modelexpress-cli --format json health | jq -r '.uptime') echo "Server has been running for $UPTIME seconds" # Check if server is healthy STATUS=$(modelexpress-cli --format json health | jq -r '.status') if [ "$STATUS" = "ok" ]; then echo "Server is healthy" else echo "Server is not healthy: $STATUS" exit 1 fi # Get model storage statistics TOTAL_MODELS=$(modelexpress-cli --format json model stats | jq -r '.total_models') TOTAL_SIZE=$(modelexpress-cli --format json model stats | jq -r '.total_size') echo "Storage contains $TOTAL_MODELS models using $TOTAL_SIZE" # Check if specific model is stored MODEL_EXISTS=$(modelexpress-cli --format json model validate "google-t5/t5-small" | jq -r '.exists') if [ "$MODEL_EXISTS" = "true" ]; then echo "Model is available in storage" else echo "Model not found in storage" fi # List all stored model names modelexpress-cli --format json model list | jq -r '.models[].name' ``` -------------------------------- ### Example GCS cache path Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/GCS_PROVIDER.md Example cache path for the model gs://model-bucket/deepseek-ai/DeepSeek-V3/rev-1. ```text /gcs/model-bucket/deepseek-ai/DeepSeek-V3/rev-1/ ``` -------------------------------- ### Copy and customize production values Source: https://github.com/ai-dynamo/modelexpress/blob/main/helm/README.md Use this bash snippet to copy the production values file and install the Helm chart with your customized values. The source warns that values-production.yaml contains placeholders that must be overridden for your environment. ```bash # Copy and customize production values cp helm/values-production.yaml helm/my-production-values.yaml # Edit my-production-values.yaml with your actual values helm install modelexpress ./helm -f helm/my-production-values.yaml ``` -------------------------------- ### Perform an RDMA transfer with NIXL agent Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/ARCHITECTURE.md This snippet shows the essential steps to use NIXL for GPU-to-GPU transfers: creating an agent, registering memory, sharing metadata, preparing descriptors for a remote agent, executing a READ transfer, and checking its state. It assumes UCX is available and each GPU worker has its own agent. The code illustrates the full flow from setup to completion, including the need to share the metadata and remote tensors between source and target. ```python # 1. Create NIXL agent (one per GPU worker) from nixl._api import nixl_agent, nixl_agent_config config = nixl_agent_config(backends=["UCX"]) agent = nixl_agent("worker-0", config) # 2. Register GPU tensors for RDMA access tensors = [(tensor.data_ptr(), tensor.numel() * tensor.element_size(), device_id, "")] agent.register_memory(tensors, "VRAM") # NIXL accelerator memory segment # 3. Get metadata for remote agent connection metadata = agent.get_local_md() # Share this with target # 4. On target: connect to source and transfer agent.add_remote_agent("source-worker-0", source_metadata) src_descs = agent.prep_xfer_dlist("source-worker-0", source_tensors, "VRAM", ["UCX"]) dst_descs = agent.prep_xfer_dlist("", local_tensors, "VRAM", ["UCX"]) handle = agent.make_prepped_xfer("READ", dst_descs, indices, src_descs, indices, ["UCX"]) agent.transfer(handle) # 5. Wait for completion while agent.check_xfer_state(handle) not in ("DONE", "SUCCESS"): time.sleep(0.001) agent.release_xfer_handle(handle) ``` -------------------------------- ### Run vLLM with modelexpress load format Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/integrations/runtimes/vllm.md For vLLM 0.23.0 and newer, install the ModelExpress Python client and run these commands to serve a model with the modelexpress load format. MX_SERVER_ADDRESS must point to the modelexpress server. The mx command remains a backward-compatible alias. ```bash export MX_SERVER_ADDRESS=modelexpress-server:8001 vllm serve my-org/my-model --load-format modelexpress ``` -------------------------------- ### Serve DeepSeek-V4-Pro with vLLM P2P transfer Source: https://github.com/ai-dynamo/modelexpress/blob/main/README.md Starts a vLLM server with the ModelExpress load format for P2P GPU transfer. Requires vLLM 0.23.0 or later and the ModelExpress Python package in the runtime image. The first instance loads from disk; subsequent instances receive weights via RDMA. Set MX_ARTIFACT_TRANSFER=1 to also transfer compatible JIT caches. ```bash vllm serve deepseek-ai/DeepSeek-V4-Pro \ --load-format modelexpress \ --tensor-parallel-size 8 \ --trust-remote-code ``` -------------------------------- ### Minimal server environment with Redis backend Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/CONFIGURATION.md Sets the metadata backend to Redis and provides the Redis URL, then runs the ModelExpress server. Requires REDIS_URL or both MX_REDIS_HOST and MX_REDIS_PORT; older REDIS_HOST and REDIS_PORT aliases remain valid. ```bash export MX_METADATA_BACKEND=redis export REDIS_URL=redis://localhost:6379 cargo run --bin modelexpress-server ``` -------------------------------- ### Deploy P2P with Kubernetes CRD backend Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Deploy a ModelExpress P2P server using the Kubernetes CRD backend and a multi-node vLLM client (TP=8, PP=2, 2 nodes). Requires NAMESPACE to be set and the CRDs and RBAC installed first. ```bash # Install CRDs and RBAC kubectl apply -f examples/crds.yaml kubectl -n $NAMESPACE apply -f examples/p2p_transfer_k8s/server/kubernetes_backend/rbac-modelmetadata.yaml # Deploy server with CRD backend kubectl -n $NAMESPACE apply -f examples/p2p_transfer_k8s/server/kubernetes_backend/modelexpress-server-kubernetes.yaml # Deploy multi-node vLLM (TP=8, PP=2, 2 nodes) kubectl -n $NAMESPACE apply -f examples/p2p_transfer_k8s/client/vllm/vllm-multi-node.yaml ``` -------------------------------- ### Basic CLI Usage Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/CLI.md Common commands for checking server health, initializing storage, downloading models, and testing API connectivity. ```bash # Check if server is running modelexpress-cli health # Initialize model storage modelexpress-cli model init # Download a model with automatic storage modelexpress-cli model download google-t5/t5-small # Check model storage status modelexpress-cli model status # Test API connectivity modelexpress-cli api send ping ``` -------------------------------- ### Run vLLM with ModelExpress Source: https://github.com/ai-dynamo/modelexpress/blob/main/modelexpress_client/python/README.md Configure the ModelExpress server address and launch vLLM using the modelexpress load format for efficient weight transfer. ```bash export MX_SERVER_ADDRESS="modelexpress-server:8001" vllm serve deepseek-ai/DeepSeek-V4-Pro \ --load-format modelexpress \ --tensor-parallel-size 8 \ --trust-remote-code ``` -------------------------------- ### Build and run ModelExpress with Docker Source: https://github.com/ai-dynamo/modelexpress/blob/main/CONTRIBUTING.md Builds the production image, runs the docker-compose stack, and builds the P2P client image. The SGLang and TensorRT-LLM deployment paths are documented under examples/p2p_transfer_k8s/client/. ```bash docker build -f docker/Dockerfile -t model-express . ``` ```bash docker compose -f docker/docker-compose.yml up --build ``` ```bash docker build -f examples/p2p_transfer_k8s/client/vllm/Dockerfile \ -t your-registry/IMAGE_NAME:TAG . ``` -------------------------------- ### Check vLLM cache effectiveness line Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Look for this effectiveness line in the vLLM loader output to confirm a transferred cache was actually used. A WARNING naming a different directory means the installed artifact was inert and the worker recompiled. ```text vLLM selected torch.compile cache directory , which ModelExpress installed ``` -------------------------------- ### Enable VMM Arena with UCX workaround Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Recommended source-worker setting for VMM Arena single-MR registration. MX_VMM_ARENA=1 installs a CUDAPluggableAllocator that routes weight allocations into a CUDA VMM arena; UCX_CUDA_COPY_REG_WHOLE_ALLOC=off is required on UCX predating the cuda_copy_md length-truncation fix (openucx/ucx#11461). ```bash MX_VMM_ARENA=1 UCX_CUDA_COPY_REG_WHOLE_ALLOC=off ``` -------------------------------- ### Deploy DGD and RL job with envsubst and kubectl Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/rl/dynamo_vllm_reshard_refit/README.md Sets environment variables for namespace, model, and images, then applies server.yaml and dgd.yaml, waits for the DGD to be ready, creates a configmap for the coordinator, applies rl-job.yaml, waits for job completion, and prints logs. Requires the Dynamo operator and hf-token-secret. ```bash export NAMESPACE=your-namespace export MODEL_NAME=Qwen/Qwen3-0.6B export MX_SERVER_IMAGE="$REGISTRY/modelexpress-server:$MX_COMMIT-dynamo-refit" export VLLM_ENGINE_IMAGE="$REGISTRY/modelexpress-vllm:a9a17e7-$MX_COMMIT-dynamo-refit" export DYNAMO_SIDECAR_IMAGE="$REGISTRY/dynamo-vllm-sidecar:ff95985" envsubst < examples/rl/dynamo_vllm_reshard_refit/server.yaml | kubectl apply -n "$NAMESPACE" -f - envsubst < examples/rl/dynamo_vllm_reshard_refit/dgd.yaml | kubectl apply -n "$NAMESPACE" -f - kubectl wait -n "$NAMESPACE" --for=condition=Ready \ dgd/mx-vllm-refit --timeout=15m kubectl create configmap mx-vllm-rl-coordinator -n "$NAMESPACE" \ --from-file=rl_coordinator.py=examples/rl/dynamo_vllm_reshard_refit/rl_coordinator.py \ --dry-run=client -o yaml | kubectl apply -n "$NAMESPACE" -f - envsubst < examples/rl/dynamo_vllm_reshard_refit/rl-job.yaml | kubectl apply -n "$NAMESPACE" -f - kubectl wait -n "$NAMESPACE" --for=condition=complete \ job/mx-vllm-rl-job --timeout=15m kubectl logs -n "$NAMESPACE" job/mx-vllm-rl-job ``` -------------------------------- ### Run server registry, build info, and config wiring tests Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/METRICS.md Runs the server registry, build info, and config wiring tests using cargo. ```bash cargo test --package modelexpress-server metrics ``` -------------------------------- ### Launch SGLang with ModelExpress loader (nixl transport) Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/SGLANG.md Sets MX_SERVER_ADDRESS and launches SGLang with the modelexpress weight loader backend and a `modelexpress-config` of `{"transport": "nixl"}`. Use the same command for first and later replicas; later replicas discover the source and load via ModelExpress transport. ```bash export MX_SERVER_ADDRESS=modelexpress-server:8001 python -m sglang.launch_server \ --model-path deepseek-ai/DeepSeek-V3 --tp 8 --port 30000 \ --load-format remote_instance \ --remote-instance-weight-loader-backend modelexpress \ --modelexpress-config '{"transport": "nixl"}' ``` -------------------------------- ### XOR_DELTA global index example Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/S3_DELTA_WEIGHT_REFIT.md Example of the global JSON index for a weight version with delta_encoding 'xor'. The generator requires all five metadata fields and weight_map, with delta_encoding='xor' and checksum_format='adler32'. ```json { "metadata": { "version": "v1", "base_version": "v0", "delta_encoding": "xor", "compression_format": "zstd", "checksum_format": "adler32" }, "weight_map": { "model.layers.0.example.weight": "model-00000-of-00004.safetensors" } } ``` -------------------------------- ### Verify InfiniBand is working Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/p2p_transfer_k8s/README.md Verify InfiniBand is working by running ibstat inside the vLLM container. ```bash kubectl exec -it deployment/mx-vllm -c vllm -- ibstat ``` -------------------------------- ### Build and push vLLM client image Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/DEPLOYMENT.md Builds and pushes a custom client image for GPU-to-GPU weight transfers with vLLM. ```bash docker build -f examples/p2p_transfer_k8s/client/vllm/Dockerfile \ -t your-registry/mx-client:TAG . docker push your-registry/mx-client:TAG ``` -------------------------------- ### Apply CRDs from source checkout Source: https://github.com/ai-dynamo/modelexpress/blob/main/helm/templates/NOTES.txt Use this command to apply the CRDs shipped with the chart when installing on a cluster with an older ModelExpress installation or before upgrading. The chart does not update existing CRDs. ```bash kubectl apply -f helm/crds/modelexpress-crds.yaml ``` -------------------------------- ### Dockerfile: Install ModelExpress into SGLang image Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/SGLANG.md Base Dockerfile for installing the ModelExpress Python package into an SGLang image. Uses --no-deps to avoid downgrading engine-provided runtime packages. ```dockerfile FROM lmsysorg/sglang:v0.5.13.post1 RUN python3 -m pip install --no-cache-dir --no-deps \ "modelexpress @ git+https://github.com/ai-dynamo/modelexpress.git#subdirectory=modelexpress_client/python" ``` -------------------------------- ### PromQL: artifact_install step fraction and extraction throughput Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/METRICS.md Two PromQL queries: the first computes the fraction of the artifact_install phase spent on extraction, and the second computes extraction throughput by dividing total bytes by extract step seconds, grouped by artifact and archive. Use these to separate slow disks from large caches. ```promql # Of the artifact_install phase, how much was the target unpacking the archive? sum(mx_artifact_install_step_seconds_sum) / sum(mx_load_phase_seconds_sum{phase="artifact_install"}) # Extraction throughput. Separates a slow disk from a large cache: a ten-second # extract is fine for 4 GiB on a healthy volume and alarming for 200 MiB on an # overlay filesystem, and only the ratio tells them apart. sum by (artifact, archive) (mx_artifact_install_bytes_total) / sum by (artifact, archive) (mx_artifact_install_step_seconds_sum{step="extract"}) ``` -------------------------------- ### Run tests and benchmarks Source: https://github.com/ai-dynamo/modelexpress/blob/main/README.md Commands for running unit tests, integration tests, a test client with a specific model, a shell script for integration tests, and benchmarks. ```bash cargo test cargo test --test integration_tests cargo run --bin test_client -- --test-model "google-t5/t5-small" ./run_integration_tests.sh cargo bench ``` -------------------------------- ### Dockerfile: Install ModelExpress with Mooncake CUDA 13 Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/SGLANG.md Dockerfile for installing the CUDA 13 Mooncake package and ModelExpress into an SGLang image. Use this for Mooncake TransferEngine with the CUDA 13 SGLang image. ```dockerfile FROM lmsysorg/sglang:v0.5.13.post1 RUN python3 -m pip install --no-cache-dir mooncake-transfer-engine-cuda13 RUN python3 -m pip install --no-cache-dir --no-deps \ "modelexpress @ git+https://github.com/ai-dynamo/modelexpress.git#subdirectory=modelexpress_client/python" ``` -------------------------------- ### XOR_DELTA shard safetensors metadata example Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/S3_DELTA_WEIGHT_REFIT.md Example of a delta shard's safetensors __metadata__ containing Adler-32 checksums for each reconstructed full tensor. The shard contains compressed U8 XOR bytes. ```json { "__metadata__": { "model.layers.0.example.weight": "12ab34cd" }, "model.layers.0.example.weight": { "dtype": "U8", "shape": [1234], "data_offsets": [0, 1234] } } ``` -------------------------------- ### FULL_HF_CHECKPOINT shard safetensors metadata example Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/S3_DELTA_WEIGHT_REFIT.md Example of a full checkpoint shard's safetensors __metadata__ with checksums keyed by tensor name when the index declares checksum_format='adler32'. When the index omits checksum_format, checksum verification is skipped. ```json { "__metadata__": { "format": "pt", "model.layers.0.example.weight": "12ab34cd" }, "model.layers.0.example.weight": { "dtype": "F32", "shape": [2], "data_offsets": [0, 8] } } ``` -------------------------------- ### Initialize trainer client with ModelExpressTrainerClient.initialize Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/S3_DELTA_WEIGHT_REFIT.md Initializes the trainer client on each distributed rank. Requires a Gloo process group for control plane collectives. The seed checkpoint path provides the real weights; the base version URI is not downloaded. Call prepare_delta_base once before the first optimizer update. ```python import torch.distributed as dist trainer = ModelExpressTrainerClient.initialize( ModelExpressTrainerConfig( model_name="Qwen/Qwen3-30B-A3B", staging_mode=TrainerStagingMode.WRITE_TO_STORAGE, payload_format=WeightPayloadFormat.XOR_DELTA, server_url="modelexpress:8001", process_group=..., # Gloo process group for control plane object_storage=ObjectStorageConfig( storage_type=ObjectStorageType.S3, uri_prefix=S3_URI_PREFIX, initial_base_version_id="v0", seed_checkpoint_path="/models/Qwen3-30B-A3B", region_name="us-west-2", ), ) ) # Call once before the first optimizer update. trainer.prepare_delta_base(hf_tensor_iter=hf_tensor_buckets()) ``` -------------------------------- ### Deploy ModelExpress with Helm Source: https://github.com/ai-dynamo/modelexpress/blob/main/README.md Creates a Kubernetes secret for the Hugging Face token and installs the ModelExpress Helm chart in a new namespace. The secret is created in the specified namespace, and the Helm install creates the 'modelexpress' namespace if it does not exist. ```bash kubectl create secret generic hf-token-secret --from-literal=HF_TOKEN=${HF_TOKEN} -n helm install modelexpress ./helm --namespace modelexpress --create-namespace ``` -------------------------------- ### Deploy 1-GPU-per-pod Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/k8s_service_sources/README.md Apply the 1-GPU-per-pod deployment manifest, wait for the pod to be ready, and then apply the target manifest. ```bash kubectl apply -f sources-tp2.yaml kubectl wait --for=condition=Ready pod -l app=mx-sources --timeout=15m kubectl apply -f target.yaml ``` -------------------------------- ### Troubleshoot server connection issues Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/CLI.md Use the direct download strategy or check model status when the server is unreachable. ```bash # Try direct download instead modelexpress-cli model download my-model --strategy direct # Check model storage status without server connection modelexpress-cli model status ``` -------------------------------- ### FULL_HF_CHECKPOINT global JSON index example Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/S3_DELTA_WEIGHT_REFIT.md Example of a standard Hugging Face safetensors index for a full checkpoint. The generator requires a non-empty weight_map covering exactly the local checkpoint tensors. The index metadata field is optional; when it contains checksum_format, only 'adler32' is supported. ```json { "metadata": { "total_size": 8, "checksum_format": "adler32" }, "weight_map": { "model.layers.0.example.weight": "model-00001-of-00004.safetensors" } } ``` -------------------------------- ### Minimal server environment with Kubernetes backend Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/CONFIGURATION.md Sets the metadata backend to Kubernetes and provides the pod namespace, then runs the ModelExpress server. Requires POD_NAMESPACE or MX_METADATA_NAMESPACE. There is no production fallback to localhost Redis or the default namespace. ```bash export MX_METADATA_BACKEND=kubernetes export POD_NAMESPACE=modelexpress cargo run --bin modelexpress-server ``` -------------------------------- ### MxClient: Query metadata and wait for readiness Source: https://github.com/ai-dynamo/modelexpress/blob/main/modelexpress_client/python/README.md Create an MxClient pointing at the ModelExpress server, query metadata for a source model, and wait for source readiness with a 7200-second timeout. The wait_for_ready call blocks until the source is ready or the timeout expires, returning success, session_id, and metadata_hash. ```python from modelexpress import MxClient client = MxClient(server_url="modelexpress-server:8001") # Query for a source model response = client.get_metadata("deepseek-ai/DeepSeek-V4-Pro") if response.found: for worker in response.workers: print(f"Worker rank {worker.worker_rank}: {len(worker.tensors)} tensors") # Wait for source readiness (blocks until ready or timeout) success, session_id, metadata_hash = client.wait_for_ready( model_name="deepseek-ai/DeepSeek-V4-Pro", worker_id=0, timeout_seconds=7200, ) client.close() ``` -------------------------------- ### View health check output Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/CLI.md Example output returned by the health check command. ```text Server Health Status Status: ok Version: 0.4.0 Uptime: 120 seconds ``` -------------------------------- ### Build the SGLang ModelExpress Docker image Source: https://github.com/ai-dynamo/modelexpress/blob/main/examples/model_streamer_k8s/client/sglang/README.md Builds the Docker image from the repository root using the provided Dockerfile. Replace with your registry and push the image. ```bash docker buildx build --platform linux/amd64 \ -f examples/model_streamer_k8s/client/sglang/Dockerfile \ -t /modelexpress-sglang:latest --push . ``` -------------------------------- ### Error Handling with Exit Codes Source: https://github.com/ai-dynamo/modelexpress/blob/main/docs/CLI.md Example of handling connection errors by checking the exit status of the health command. ```bash # Handle connection errors gracefully if ! modelexpress-cli health >/dev/null 2>&1; then echo "Server is not available, trying direct download..." modelexpress-cli model download my-model --strategy direct fi ```