NVIDIA / NVIDIA/AMGX

[Issue] When I set the convergence criterion to the absolute residual, the AMGX iteration log reports that “Relative residual has reached machine precision” and then stops further iterations.

Open
#350 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Cuda
Stars
692
Forks
197
PR merge metrics
No merged PRs in 30d

Description

When I set "convergence": "ABSOLUTE", "tolerance": 1e-7 in AMGX, the solver prints:

Relative residual has reached machine precision.

However, my stopping criterion is the absolute residual. Why is the relative residual being used? I would like the solver to use the absolute residual as the convergence criterion. Is it possible that my AMGX solver configuration is not actually taking effect?
I am using double precision, so the machine precision is about 1e-16.

AMGX solver configuration
CHECK_AMGX(AMGX_initialize());

AMGX_config_handle cfg;
CHECK_AMGX(AMGX_config_create_from_file(&cfg, "./amgx_SH.json"));

AMGX_resources_handle rsrc;
CHECK_AMGX(AMGX_resources_create_simple(&rsrc, cfg));

AMGX_matrix_handle A;
AMGX_vector_handle b, x;
AMGX_solver_handle solver;

CHECK_AMGX(AMGX_matrix_create(&A, rsrc, AMGX_mode_dDDI));
CHECK_AMGX(AMGX_vector_create(&b, rsrc, AMGX_mode_dDDI));
CHECK_AMGX(AMGX_vector_create(&x, rsrc, AMGX_mode_dDDI));
CHECK_AMGX(AMGX_solver_create(&solver, rsrc, AMGX_mode_dDDI, cfg));

CHECK_AMGX(AMGX_matrix_upload_all(
A, N, nnz,
1, 1,
row_ptr.data(),
col_ind.data(),
values.data(),
nullptr
));

CHECK_AMGX(AMGX_vector_upload(b, N, 1, rhs.data()));
std::vector h_x0(N, 0.0);
CHECK_AMGX(AMGX_vector_upload(x, N, 1, h_x0.data()));

CHECK_AMGX(AMGX_solver_setup(solver, A));
CHECK_AMGX(AMGX_solver_solve(solver, b, x));

AMGX_SOLVE_STATUS status;
CHECK_AMGX(AMGX_solver_get_status(solver, &status));
int iters = 0;
CHECK_AMGX(AMGX_solver_get_iterations_number(solver, &iters));

Configuration: amgx_SH.json:
{
"config_version": 2,
"determinism_flag": 1,

"solver": {
"solver": "FGMRES",
"scope": "main",

"preconditioner": {
  "solver": "AMG",
  "scope": "amg",

  "algorithm": "AGGREGATION",
  "cycle": "V",
  "max_levels": 30,
  "max_iters": 1,

  "smoother": "JACOBI_L1",
  "presweeps": 1,
  "postsweeps": 1,
  "coarsest_sweeps": 1,
  "selector": "SIZE_2"
},

"print_solve_stats": 1,
"obtain_timings": 1,
"monitor_residual": 1,

"max_iters": 1000,
"convergence": "ABSOLUTE",
"tolerance": 1e-7,
"norm": "L2"

}
}

Run log
Output around the end of the solve:
AMGX_solver_get_status(solver, &status):
669 16.2383 5.897965e-04 0.9862
670 16.2383 5.758887e-04 0.9764
671 16.2383 5.513113e-04 0.9573
672 16.2383 5.288395e-04 0.9592
673 16.2383 5.166605e-04 0.9770
674 16.2383 5.016301e-04 0.9709
675 16.2383 4.859083e-04 0.9687
676 16.2383 4.735401e-04 0.9745
677 16.2383 4.577987e-04 0.9668
678 16.2383 4.396150e-04 0.9603
679 16.2383 4.195545e-04 0.9544
Relative residual has reached machine precision
680 16.2383 4.045309e-04 0.9642
----------------------------------------------------------------------
Total Iterations: 681
Avg Convergence Rate: 0.9602
Final Residual: 4.045309e-04
Total Reduction in Residual: 9.873147e-13
Maximum Memory Usage: 16.238 GB
----------------------------------------------------------------------
Total Time: 13.1027
setup: 0.502298 s
solve: 12.6004 s
solve(per iteration): 0.0185028 s

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with amgx_SH.json and the AMGX_solver_solve and AMGX_solver_get_status entry points, then compare the configured ABSOLUTE criterion with the residual and iteration messages in the supplied run log. Done means determining why the machine-precision message appears and confirming whether absolute-residual stopping is honored.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.