Skip to content

object has no attribute 'precon' in pyamgx solvers #1199

@andrewsb8

Description

@andrewsb8

Hi,

As a minimum working example, I copied the following from the original example of using the amgx solver and run with FIPY_SOLVERS=pyamgx python3 fipy_trial.py.

from fipy.solvers.pyamgx.pyAMGXSolver import PyAMGXSolver

cfg_dict = {
	"config_version": 2,
	"determinism_flag": 1,
	"exception_handling": 1,
	"solver": {
	    "print_grid_stats": 1,
	    "store_res_history": 1,
	    "solver": "GMRES",
	    "print_solve_stats": 1,
	    "obtain_timings": 1,
	    "preconditioner": {
		"interpolator": "D2",
		"print_grid_stats": 1,
		"solver": "AMG",
		"smoother": "JACOBI_L1",
		"presweeps": 2,
		"selector": "PMIS",
		"coarsest_sweeps": 2,
		"coarse_solver": "NOSOLVER",
		"max_iters": 1,
		"interp_max_elements": 4,
		"min_coarse_rows": 2,
		"scope": "amg_solver",
		"max_levels": 24,
		"cycle": "V",
		"postsweeps": 2,
	    },
	    "max_iters": 100,
	    "monitor_residual": 1,
	    "gmres_n_restart": 10,
	    "convergence": "RELATIVE_INI_CORE",
	    "tolerance": 1e-06,
	    "norm": "L2",
	},
}

solver = PyAMGXSolver(cfg_dict)

I get the following stack trace Even though there is clearly a solver key in cfg_dict:

AMGX version 2.5.0
Built on May 26 2026, 10:05:58
Compiled with CUDA Runtime 12.8, using CUDA driver 12.8
The AMGX_initialize_plugins API call is deprecated and can be safely removed.
Traceback (most recent call last):
  File "[filename]", line 39, in <module>
    solver = PyAMGXSolver(cfg_dict)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/path/.conda/envs/pfc/lib/python3.11/site-packages/fipy/solvers/pyamgx/pyAMGXSolver.py", line 43, in __init__
    self.config_dict["solver"]["max_iters"] = self.iterations
    ~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'solver'
The AMGX_finalize_plugins API call is deprecated and can be safely removed.

I have also tried using other pyAMGXsolvers but any attempt to instantiate them runs into an issue where none of the solvers have the precon attribute, even if explicitly passed. I can provide more details for this if there is not a simple solution to the first issue.

Thanks for any help.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions