How nvidia/cuopt works
Project Type and Purpose
• GPU-accelerated optimization engine (cuOpt) implemented in C++/CUDA.
• Solves linear programming (LP), mixed-integer linear programming (MILP), and vehicle routing problems (VRP).
• Exposes functionality via multiple APIs: C API (libcuopt), Python API (Cython), Server API (HTTP), plus CLI tools.
• Distributed as pip/conda packages and Docker containers.
File Structure Breakdown
• cpp/
• src/: core solver modules (linear_programming, mip, routing, utilities)
• /: public C++ and C API headers
• libmps_parser/: MPS file parsing submodule
• tests/benchmarks: C++ unit tests and performance benchmarks
• python/
• libcuopt/: low-level C API loader and CLI wrapper
• cuopt/: high-level Python package (Cython bindings for distance_engine, linear_programming, routing)
• cuopt_server/: microservice implementation (HTTP endpoints, job queue, data validation, result store, webserver.py)
• cuopt_self_hosted/: thin client for self-hosted server with secure communication
• docs/
• docs/cuopt/: Sphinx source for C API, Python API, CLI, server quickstarts
• benchmarks/, datasets/: performance and sample data for LP, MILP, routing
• ci/, conda/, cmake/: build scripts, CI/CD workflows, packaging recipes
Insights from README
• Multi-API support: C, C++, Python, Server
• Installation via pip (cuopt-server, cuopt-sh-client), conda, or Docker image
• Build‐from‐source via CMake and conda recipes
• Requires CUDA ≥12.0, Linux (WSL2 supported)
Main Components & Their Relationships
a. Core Compute Layer
• CUDA kernels and C++ host code (cpp/src)
• MPS Parser (cpp/libmps_parser)
b. C API Layer
• libcuopt: C bindings wrapping core C++ functionality
c. Python Binding Layer
• Cython modules in python/cuopt/* invoking C API
d. High-Level Python & CLI Layer
• python/cuopt package for end-users
• C++ cuopt_cli tool and python/libcuopt CLI wrapper
e. Service Layer
• python/cuopt_server: HTTP webserver, request validation, job queue, solver invocation, result storage
f. Client Layer
• python/cuopt_self_hosted: thin client calling server via secure RPC/HTTP
• Interactive notebooks and example scripts
g. Packaging & Deployment
• pip and conda packages, Docker image (nvidia/cuopt:…)
• CI/CD pipelines (GitHub Actions) produce build artifacts
Data and Control Flow
• Client (CLI, notebook, thin client) → HTTP or function call → cuOpt Server
• Server validates input → enqueues job → calls high-level Python API
• Python Cython binding → C API → Core Compute Engine on GPU
• Compute result → propagate back through C API → Python wrapper → Server → Client response
• Packaging workflows consume compiled libraries and Python wheels to publish pip/conda artifacts and Docker images
Architectural Patterns
• Layered architecture: Compute → C API → Python API → Service → Client
• Adapter pattern: Cython modules adapt Python data models to C API calls
• Microservice pattern: stateless HTTP server with job queue and result store
• Strategy modularity in core engine: separate modules for LP, MILP, VRP