Snakepit.Error.Device (Snakepit v0.8.7)

View Source

Device error creation helpers.

Provides functions for creating device-related errors with telemetry emission and helpful suggestions.

Summary

Functions

Creates a device mismatch error.

Creates a device unavailable error.

Creates an out of memory error with recovery suggestions.

Functions

device_mismatch(expected, got, operation)

@spec device_mismatch(term(), term(), String.t()) :: Snakepit.Error.DeviceMismatch.t()

Creates a device mismatch error.

Examples

error = Device.device_mismatch(:cpu, {:cuda, 0}, "matmul")

device_unavailable(device, operation)

@spec device_unavailable(term(), String.t()) :: Snakepit.Error.DeviceMismatch.t()

Creates a device unavailable error.

Examples

error = Device.device_unavailable({:cuda, 2}, "matrix_multiply")

out_of_memory(device, requested_bytes, available_bytes, operation \\ nil)

@spec out_of_memory(term(), non_neg_integer(), non_neg_integer(), String.t() | nil) ::
  Snakepit.Error.OutOfMemory.t()

Creates an out of memory error with recovery suggestions.

Examples

error = Device.out_of_memory({:cuda, 0}, 1024 * 1024 * 1024, 512 * 1024 * 1024)