cuopt-debugging

bởi nvidia

Khắc phục sự cố bài toán cuOpt LP/MILP bao gồm lỗi, kết quả sai, giải pháp không khả thi, vấn đề hiệu suất và mã trạng thái. Sử dụng khi người dùng nói…

npx skills add https://github.com/nvidia/cuopt-examples --skill cuopt-debugging

cuOpt Debugging Skill

Diagnose and fix issues with cuOpt LP/MILP solutions, errors, and performance.

Before You Start: Required Questions

Ask these to understand the problem:

  1. What's the symptom?

    • Error message?
    • Wrong/unexpected results?
    • Empty solution?
    • Performance too slow?
  2. What's the status?

    • problem.Status.name — what value does it show?
  3. Can you share?

    • The error message (exact text)
    • The code that produces it
    • Problem size (variables, constraints)

Quick Diagnosis by Symptom

"Solution is empty/None but status looks OK"

Most common cause: Wrong status string case

# ❌ WRONG - "OPTIMAL" never matches, silently fails
if problem.Status.name == "OPTIMAL":
    print(problem.ObjValue)  # Never runs!

# ✅ CORRECT - use PascalCase
if problem.Status.name in ["Optimal", "FeasibleFound"]:
    print(problem.ObjValue)

Diagnostic code:

print(f"Actual status: '{problem.Status.name}'")
print(f"Matches 'Optimal': {problem.Status.name == 'Optimal'}")
print(f"Matches 'OPTIMAL': {problem.Status.name == 'OPTIMAL'}")

"Objective value is wrong/zero"

Check if variables are actually used:

for var in problem.getVariables():
    print(f"{var.VariableName} = {var.Value}")
print(f"Objective: {problem.ObjValue}")

# Or with direct variable references
for var in [x, y, z]:
    print(f"{var.VariableName}: {var.getValue()}")

Common causes:

  • Constraints too restrictive (all zeros is feasible)
  • Objective coefficients have wrong sign
  • Wrong variable in objective

"Infeasible" status

For LP/MILP:

if problem.Status.name in ["PrimalInfeasible", "Infeasible"]:
    print("Problem has no feasible solution")
    # Review constraints for conflicts
    for c in problem.getConstraints():
        print(f"{c.ConstraintName}")

Common causes:

  • Conflicting constraints (x <= 5 AND x >= 10)
  • Bounds too tight
  • Missing a "slack" variable for soft constraints

"Integer variable has fractional value"

# Check how variable was defined
int_var = problem.addVariable(
    lb=0, ub=10,
    vtype=INTEGER,  # Must be INTEGER, not CONTINUOUS
    name="count"
)

# Also check if status is actually optimal
if problem.Status.name == "FeasibleFound":
    print("Warning: not fully optimal, may have fractional intermediate values")

"Unbounded" status

Problem has no finite optimum:

if problem.Status.name in ["DualInfeasible", "Unbounded"]:
    print("Problem is unbounded - objective can improve infinitely")

Common causes:

  • Missing variable upper/lower bounds
  • Constraint direction wrong (>= instead of <=)
  • Missing constraints

"Maximum recursion depth exceeded" when building expressions

Building large objectives or constraints with many chained + operations can hit Python recursion limits. Use LinearExpression instead:

from cuopt.linear_programming.problem import LinearExpression

# Instead of: expr = c1*v1 + c2*v2 + ... + cn*vn (many terms)
vars_list = [v1, v2, v3, ...]
coeffs_list = [c1, c2, c3, ...]
expr = LinearExpression(vars_list, coeffs_list, constant=0.0)
problem.setObjective(expr, sense=MINIMIZE)

See the LP/MILP "Building large expressions" section and reference models in the project for examples.

OutOfMemoryError

Check problem size:

print(f"Variables: {len(problem.getVariables())}")
print(f"Constraints: {len(problem.getConstraints())}")

Mitigations:

  • Reduce problem size
  • Use sparse constraint matrix
  • Set time limit to get partial solution

Status Code Reference

LP Status Values

StatusMeaning
OptimalFound optimal solution
PrimalFeasibleFound feasible but may not be optimal
PrimalInfeasibleNo feasible solution exists
DualInfeasibleProblem is unbounded
TimeLimitStopped due to time limit
IterationLimitStopped due to iteration limit
NumericalErrorNumerical issues encountered
NoTerminationSolver didn't converge

MILP Status Values

StatusMeaning
OptimalFound optimal solution
FeasibleFoundFound feasible, within gap tolerance
InfeasibleNo feasible solution exists
UnboundedProblem is unbounded
TimeLimitStopped due to time limit
NoTerminationNo solution found yet

Performance Debugging

Slow LP/MILP Solve

settings = SolverSettings()
settings.set_parameter("log_to_console", 1)  # See progress
settings.set_parameter("time_limit", 60)      # Don't wait forever

# For MILP, accept good-enough solution
settings.set_parameter("mip_relative_gap", 0.05)  # 5% gap

Check Solve Time

problem.solve(settings)
print(f"Solve time: {problem.SolveTime:.2f} seconds")

Diagnostic Checklist

□ Status checked with correct case (PascalCase)?
□ All variables have correct vtype (INTEGER vs CONTINUOUS)?
□ Constraint directions correct (<= vs >= vs ==)?
□ Objective sense correct (MINIMIZE vs MAXIMIZE)?
□ Variable bounds specified where needed?

Diagnostic Code Snippets

See resources/diagnostic_snippets.md for copy-paste diagnostic code:

  • Status checking
  • Variable inspection
  • Constraint analysis
  • Memory and performance checks

Interpreting Dual Values & Reduced Costs

When an LP/QP solve returns dual values and you need the decision read — which constraint is the binding bottleneck, what relaxing it is worth, and which unused option is the closest near-miss — see resources/interpreting_duals.md. (Integer models / MILP — and quadratic constraints — return no usable duals; that reference covers the fallback.)

When to Escalate

File a GitHub issue if:

  • Reproducible bug with minimal example
  • Include: cuOpt version, CUDA version, error message, minimal repro code

Thêm skills từ nvidia

compileiq-debug
nvidia
Sử dụng khi có điều gì đó không ổn: Search() bị treo, tất cả các đánh giá đều trả về INVALID_SCORE, điểm số không cải thiện, mọi cấu hình đều trả về cùng một số, lỗi ptxas…
create-github-pr
nvidia
Tạo pull request GitHub bằng cách sử dụng gh CLI. Sử dụng khi người dùng muốn tạo PR mới, gửi mã để xem xét, hoặc mở pull request. Từ khóa kích hoạt -…
nemoclaw-maintainer-cross-issue-sweep
nvidia
Quét các vấn đề đang mở khác để tìm những vấn đề mà một PR nhất định có thể sửa hoặc vô tình làm hỏng. Đưa ra các cơ hội sửa lỗi liền kề và rủi ro mâu thuẫn với file:dòng…
fhir-basics
nvidia
Dạy các tác nhân cách hoạt động của API FHIR R4, những tài nguyên có sẵn, cách truy vấn chúng với tham số tìm kiếm, và cách phân tích chính xác tất cả các định dạng phản hồi…
compileiq-validate-result
nvidia
Sử dụng SAU KHI tìm kiếm hoàn tất và TRƯỚC KHI yêu cầu tăng tốc hoặc gửi ACF. Tải tệp CSV dump_results, trích xuất các ứng viên top-K (đơn mục tiêu)…
changelog-audit
nvidia
Kiểm tra Warp CHANGELOG.md trước khi phát hành: khôi phục các mục bị mất, sắp xếp theo tác động người dùng, tinh chỉnh ngôn ngữ mục, xuống dòng và (chế độ nhánh phát hành) so sánh bump…
maintain-dynamic-plugins
nvidia
Duy trì các bộ nạp plugin động NeMo Relay, tệp kê khai, SDK gốc Rust, giao thức worker gRPC, SDK worker Python, tài liệu, kiểm thử và phạm vi quy trình phát hành
dgx-diagnose
nvidia
Chẩn đoán các sự cố thường gặp của DGX Station GB300 — lỗi CUDA, nhắm sai GPU, lỗi container vLLM/SGLang, vấn đề trạng thái MIG, lỗi NVLink/Fabric Manager,…