Skip to content
Draft
28 changes: 25 additions & 3 deletions genesis/engine/solvers/rigid/constraint/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def __init__(self, rigid_solver: "RigidSolver"):
self.mv = cs.mv
self.jv = cs.jv
self.quad_gauss = cs.quad_gauss

self.candidates = cs.candidates
self.ls_it = cs.ls_it
self.ls_result = cs.ls_result
Expand Down Expand Up @@ -188,6 +187,7 @@ def resolve(self):

func_solve_body(
self._solver.entities_info,
self._solver.dofs_info,
self._solver.dofs_state,
self.constraint_state,
self._solver._rigid_global_info,
Expand Down Expand Up @@ -2262,6 +2262,12 @@ def update_bracket_no_eval_local(
return flag, p_alpha, p_cost, p_grad, p_hess, p_next_alpha


@qd.func
def _log_scale(min_value: gs.qd_float, max_value: gs.qd_float, num_values: qd.i32, i: qd.i32) -> gs.qd_float:
step = (qd.log(max_value) - qd.log(min_value)) / qd.max(1.0, gs.qd_float(num_values - 1))
return qd.exp(qd.log(min_value) + gs.qd_float(i) * step)
Comment on lines +2265 to +2268
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved in generic quadrants kernel utils

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only for linesearch use. I intend to add a note to state it can be moved in generic quadrants kernel utils and do follow up PRs on it. How do you think?

Copy link
Collaborator

@duburcqa duburcqa Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If think it should either be inlined or move in generic quadrants kernel utils. No good reason to wait.



@qd.func
def func_linesearch_and_apply_alpha(
i_b,
Expand Down Expand Up @@ -2801,14 +2807,28 @@ def initialize_Ma(
# ======================================================= Core ========================================================


@qd.kernel(fastcache=gs.use_fastcache)
@qd.perf_dispatch(
get_geometry_hash=lambda *args, **kwargs: (*args, frozendict(kwargs)), warmup=3, active=3, repeat_after_seconds=0
)
def func_solve_init(
dofs_info: array_class.DofsInfo,
dofs_state: array_class.DofsState,
entities_info: array_class.EntitiesInfo,
constraint_state: array_class.ConstraintState,
rigid_global_info: array_class.RigidGlobalInfo,
static_rigid_sim_config: qd.template(),
) -> None: ...


@func_solve_init.register(is_compatible=lambda *args, **kwargs: True)
@qd.kernel(fastcache=gs.use_fastcache)
def func_solve_init_monolith(
dofs_info: array_class.DofsInfo,
dofs_state: array_class.DofsState,
entities_info: array_class.EntitiesInfo,
constraint_state: array_class.ConstraintState,
rigid_global_info: array_class.RigidGlobalInfo,
static_rigid_sim_config: qd.template(),
):
_B = dofs_state.acc_smooth.shape[1]
n_dofs = dofs_state.acc_smooth.shape[0]
Expand Down Expand Up @@ -3009,10 +3029,11 @@ def func_solve_iter(


@qd.perf_dispatch(
get_geometry_hash=lambda *args, **kwargs: (*args, frozendict(kwargs)), warmup=3, active=3, repeat_after_seconds=1.0
get_geometry_hash=lambda *args, **kwargs: (*args, frozendict(kwargs)), warmup=3, active=3, repeat_after_seconds=0
)
def func_solve_body(
entities_info: array_class.EntitiesInfo,
dofs_info: array_class.DofsInfo,
dofs_state: array_class.DofsState,
constraint_state: array_class.ConstraintState,
rigid_global_info: array_class.RigidGlobalInfo,
Expand All @@ -3024,6 +3045,7 @@ def func_solve_body(
@qd.kernel(fastcache=gs.use_fastcache)
def func_solve_body_monolith(
entities_info: array_class.EntitiesInfo,
dofs_info: array_class.DofsInfo,
dofs_state: array_class.DofsState,
constraint_state: array_class.ConstraintState,
rigid_global_info: array_class.RigidGlobalInfo,
Expand Down
Loading
Loading