cuOpt Developer Skill
Contribute to the NVIDIA cuOpt codebase. This skill is for modifying cuOpt itself, not for using it.
If you just want to USE cuOpt, switch to the appropriate problem skill (cuopt-routing, cuopt-lp-milp, etc.)
Developer Behavior Rules
These rules are specific to development tasks. They differ from user rules.
1. Ask Before Assuming
Clarify before implementing:
- •What component? (C++/CUDA, Python, server, docs, CI)
- •What's the goal? (bug fix, new feature, refactor, docs)
- •Is this for contribution or local modification?
2. Verify Understanding
Before making changes, confirm:
"Let me confirm: - Component: [cpp/python/server/docs] - Change: [what you'll modify] - Tests needed: [what tests to add/update] Is this correct?"
3. Follow Codebase Patterns
- •Read existing code in the area you're modifying
- •Match naming conventions, style, and patterns
- •Don't invent new patterns without discussion
4. Ask Before Running — Modified for Dev
OK to run without asking (expected for dev work):
- •
./build.shand build commands - •
pytest,ctest(running tests) - •
pre-commit run,./ci/check_style.sh(formatting) - •
git status,git diff,git log(read-only git)
Still ask before:
- •
git commit,git push(write operations) - •Package installs (
pip,conda,apt) - •Any destructive or irreversible commands
5. No Privileged Operations
Same as user rules — never without explicit request:
- •No
sudo - •No system file changes
- •No writes outside workspace
Before You Start: Required Questions
Ask these if not already clear:
- •
What are you trying to change?
- •Solver algorithm/performance?
- •Python API?
- •Server endpoints?
- •Documentation?
- •CI/build system?
- •
Do you have the development environment set up?
- •Built the project successfully?
- •Ran tests?
- •
Is this for contribution or local modification?
- •If contributing: will need to follow DCO signoff
Project Architecture
cuopt/ ├── cpp/ # Core C++ engine │ ├── include/cuopt/ # Public C/C++ headers │ ├── src/ # Implementation (CUDA kernels) │ └── tests/ # C++ unit tests (gtest) ├── python/ │ ├── cuopt/ # Python bindings and routing API │ ├── cuopt_server/ # REST API server │ ├── cuopt_self_hosted/ # Self-hosted deployment │ └── libcuopt/ # Python wrapper for C library ├── ci/ # CI/CD scripts ├── docs/ # Documentation source └── datasets/ # Test datasets
Supported APIs
| API Type | LP | MILP | QP | Routing |
|---|---|---|---|---|
| C API | ✓ | ✓ | ✓ | ✗ |
| C++ API | (internal) | (internal) | (internal) | (internal) |
| Python | ✓ | ✓ | ✓ | ✓ |
| Server | ✓ | ✓ | ✗ | ✓ |
Safety Rules (Non-Negotiable)
Minimal Diffs
- •Change only what's necessary
- •Avoid drive-by refactors
- •No mass reformatting of unrelated code
No API Invention
- •Don't invent new APIs without discussion
- •Align with existing patterns in
docs/cuopt/source/ - •Server schemas must match OpenAPI spec
Don't Bypass CI
- •Never suggest
--no-verifyor skipping checks - •All PRs must pass CI
CUDA/GPU Hygiene
- •Keep operations stream-ordered
- •Follow existing RAFT/RMM patterns
- •No raw
new/delete- use RMM allocators
Build & Test
Build Everything
./build.sh
Build Specific Components
./build.sh libcuopt # C++ library ./build.sh cuopt # Python package ./build.sh cuopt_server # Server ./build.sh docs # Documentation
Run Tests
# C++ tests ctest --test-dir cpp/build # Python tests pytest -v python/cuopt/cuopt/tests # Server tests pytest -v python/cuopt_server/tests
Before You Commit
Run Style Checks
./ci/check_style.sh # or pre-commit run --all-files --show-diff-on-failure
Sign Your Commits (DCO Required)
git commit -s -m "Your message"
Coding Conventions
C++ Naming
| Element | Convention | Example |
|---|---|---|
| Variables | snake_case | num_locations |
| Functions | snake_case | solve_problem() |
| Classes | snake_case | data_model |
| Test cases | PascalCase | SolverTest |
| Device data | d_ prefix | d_locations_ |
| Host data | h_ prefix | h_data_ |
| Template params | _t suffix | value_t |
| Private members | _ suffix | n_locations_ |
File Extensions
| Extension | Usage |
|---|---|
.hpp | C++ headers |
.cpp | C++ source |
.cu | CUDA source (nvcc required) |
.cuh | CUDA headers with device code |
Include Order
- •Local headers
- •RAPIDS headers
- •Related libraries
- •Dependencies
- •STL
Python Style
- •Follow PEP 8
- •Use type hints
- •Tests use pytest
Error Handling
Runtime Assertions
CUOPT_EXPECTS(condition, "Error message");
CUOPT_FAIL("Unreachable code reached");
CUDA Error Checking
RAFT_CUDA_TRY(cudaMemcpy(...));
Memory Management
// ❌ WRONG int* data = new int[100]; // ✅ CORRECT - use RMM rmm::device_uvector<int> data(100, stream);
- •All operations should accept
cuda_stream_view - •Views (
*_viewsuffix) are non-owning
Test Impact Check
Before any behavioral change, ask:
- •What scenarios must be covered?
- •What's the expected behavior contract?
- •Where should tests live?
- •C++ gtests:
cpp/tests/ - •Python pytest:
python/.../tests/
- •C++ gtests:
Add at least one regression test for new behavior.
Key Files Reference
| Purpose | Location |
|---|---|
| Main build script | build.sh |
| Dependencies | dependencies.yaml |
| C++ formatting | .clang-format |
| Conda environments | conda/environments/ |
| Test data | datasets/ |
| CI scripts | ci/ |
Common Tasks
Adding a Solver Parameter
- •Add to settings struct in
cpp/include/cuopt/ - •Expose in Python bindings
python/cuopt/ - •Add to server schema if applicable
- •Add tests
- •Update documentation
Adding a Server Endpoint
- •Add route in
python/cuopt_server/cuopt_server/webserver.py - •Update OpenAPI spec
docs/cuopt/source/cuopt_spec.yaml - •Add tests in
python/cuopt_server/tests/ - •Update documentation
Modifying CUDA Kernels
- •Edit kernel in
cpp/src/ - •Follow stream-ordering patterns
- •Run C++ tests:
ctest --test-dir cpp/build - •Run benchmarks to check performance
Common Pitfalls
| Problem | Solution |
|---|---|
| Cython changes not reflected | Rerun: ./build.sh cuopt |
Missing nvcc | Set $CUDACXX or add CUDA to $PATH |
| CUDA out of memory | Reduce problem size |
| Slow debug library loading | Device symbols cause delay |
Canonical Documentation
- •Contributing/build/test:
CONTRIBUTING.md - •CI scripts:
ci/README.md - •Release scripts:
ci/release/README.md - •Docs build:
docs/cuopt/README.md
Security Rules
- •No shell commands by default - provide instructions, only run if asked
- •No package installs by default - ask before pip/conda/apt
- •No privileged changes - never use sudo without explicit request
- •Workspace-only file changes - ask for permission for writes outside repo