﻿# MACE force inference can require gradients with respect to positions

Distinguish frozen MACE parameters from coordinate derivatives, preserve energy-to-force computation, and avoid blindly wrapping atomistic inference in no-gradient modes.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-mace-force-inference-position-autograd/
Language: en

## Inference can include a derivative calculation

A general GPU-serving wrapper may disable automatic differentiation around every model call to reduce overhead. That assumption needs review for an energy-based atomistic model: requested forces can be calculated from derivatives of predicted energy with respect to atomic positions.

The [MACE calculator guide](https://mace-docs.readthedocs.io/en/latest/guide/ase.html) demonstrates using a trained model through an ASE calculator. An application should preserve the calculator computation rather than reducing the task to an unrelated scalar forward pass.

## Weight gradients and coordinate gradients are different

A trained model can keep its parameters fixed while still differentiating an output with respect to input coordinates. Parameter optimization is absent, but the derivative computation remains part of the requested inference result.

The [MACE calculation utilities](https://raw.githubusercontent.com/ACEsuit/mace/main/mace/modules/utils.py) implement force-related differentiation. The [autograd guide](/journal/autograd-chain-rule-neural-graphs/) explains the underlying chain-rule distinction: the existence of an inference request does not identify which variables need derivatives.

## Follow the actual calculator path

The [ASE calculator implementation](https://raw.githubusercontent.com/ACEsuit/mace/main/mace/calculators/mace.py) connects model outputs, requested properties, and unit conversion. Freezing model parameters is visible there; it should not be generalized into permission to detach every intermediate coordinate-dependent quantity.

Inspect the selected model type and exported interface. Some deployment paths can expose different property sets or implement derivatives differently. State what the loaded artifact actually returns rather than promising forces from any file carrying the family name.

## Validate physical units alongside derivatives

Force units involve both an energy and a length convention. Rescaling energy alone does not fully describe the conversion of its coordinate derivative. Preserve the coordinate unit, energy unit, and calculator conversion settings with exported results.

A reference check can compare analytical forces with appropriate finite differences on a small inspected structure. That test requires a deliberate perturbation scale and tolerance; it is a proposed verification procedure, not a measurement reported here.

## Benchmark the requested property set

Energy-only and energy-plus-force jobs are different workloads. Record requested properties and derivative settings when applying the [benchmark method](/journal/inference-benchmark-method/), so an apparent speedup does not merely reflect omission of force computation.

A valid derivative calculation establishes consistency with the learned energy model. It does not make that model an exact physical potential for every material or establish the accuracy of a simulation outside its evaluated scientific domain.
