Learn R Programming

ggmlR (version 0.8.4)

ggml_test_adamw_steps: Compare the AdamW Optimizer Step Across Backends

Description

Runs ggml_opt_step_adamw() for several steps on backend and on the CPU from the same starting weights and the same gradients, and reports the weight checksum after each step.

Usage

ggml_test_adamw_steps(backend)

Value

A data frame with step, w_cpu, w_backend and

abs_diff, or a one-column data frame with note when the op could not be run.

Arguments

backend

Backend pointer to compare against the CPU.

Details

This needs its own function rather than a case in ggml_test_backend_ops: the op updates the weights and both moment buffers in place, so step N depends on every step before it, and the bias-correction terms it receives change every step. Comparing a single execution proves nothing here -- the first Adam step agrees bit-for-bit on both backends and the disagreement only starts at the second.

See Also

ggml_test_backend_ops

Examples

Run this code
# \donttest{
if (ggml_vulkan_available()) {
  be <- ggml_vulkan_init(0)
  print(ggml_test_adamw_steps(be))
  ggml_backend_free(be)
}
# }

Run the code above in your browser using DataLab