Skip to main content

sdkruntimepybind module

Python API for SdkRuntime functions.

MemcpyDataType

Bases: Enum
Specifies the data size for transfers using SdkRuntime.memcpy_d2h() and SdkRuntime.memcpy_h2d() copy mode.
Values:
  • MEMCPY_16BIT
  • MEMCPY_32BIT

MemcpyOrder

Bases: Enum
Specifies mapping of data for transfers using SdkRuntime.memcpy_d2h() and SdkRuntime.memcpy_h2d() copy mode.
Values:
  • ROW_MAJOR
  • COL_MAJOR

SdkCompileArtifacts

Bases: object
Specifies compile artifacts for execution.

SdkExecutionPlatform

Bases: object
Specifies the simulator or system target and architecture for execution.

SdkRuntime

Bases: object
Manages the execution of SDK programs on the Cerebras Wafer Scale Engine (WSE) or simfabric. The constructor analyzes the WSE ELFs in the bindir and prepares the WSE or simfabric for a run. Requires CM IP address and port for WSE runs.

SdkTarget

Bases: Enum
Specifies a target compilation architecture.
Values:
  • WSE2
  • WSE3

SimfabConfig

Bases: object
Specifies simfab configuration for simulator runs.

Task

Handle to a task launched by SdkRuntime.

get_platform

Constructs an SdkExecutionPlatform object configured by simulator or system settings and target architecture.

get_simulator

Constructs an SdkExecutionPlatform object for simulator.

get_system

Constructs an SdkExecutionPlatform object for a real system.

sdk_utils module

Utility functions for common operations with SdkRuntime. Import from cerebras.sdk.sdk_utils.

calculate_cycles

Converts values in timestamp_buf returned from device into a human-readable elapsed cycle count.
  • Returns: Elapsed cycle count.
  • Return type: numpy.int64
Example:Consider the following CSL snippet which records timestamps and produces a single array to copy back to the host, to generate an elapsed cycle count:
Then the elapsed cycles can be calculated on the host with:

input_array_to_u32

Converts a 16-bit tensor to a 32-bit tensor of type u32 for use with memcpy. The parameter sentinel distinguishes two different extensions of 16-bit data. If sentinel is None, zero-pad the upper 16 bits. If sentinel is not None, pack the index of the innermost dimension of the array into the upper 16-bits.
  • Returns: Numpy view into arr with specified numpy data type.
  • Return type: numpy.ndarray.view

memcpy_view

Returns a 32, 16 or 8 bit view of a 32 bit numpy array (only the lower 16 or 8 bits of each 32 bit word in the last two cases).
  • Returns: Numpy view into arr with specified numpy data type.
  • Return type: numpy.ndarray.view
Example:memcpy_view() simplifies the use of various precision data types when copying between host and device. Consider the following Python host code which creates a float16 view into a numpy array. Note that this array must be 32-bit. The user can fill the array with float16 data, and copy it to an array on the device with CSL data type f16.

debug_util module

Utilities for parsing debug output and core files of a simulator run. Import from cerebras.sdk.debug.debug_util.

debug_util

Bases: object
Loads ELF files in bindir in order to dump symbols for debugging.The user does not need to export the symbols in the kernel. debug_util dumps the core and looks for the symbols in the ELFs. If the symbol at Px.y is not found in the corresponding ELF, debug_util emits an error.The most common errors are either: 1) a wrong coordinate passed in debug_util.get_symbol(), or 2) a correct coordinate, but the symbol has been removed due to compiler optimization. One can use readelf to check if the symbol exists or not. If not, the user can export the symbol in the kernel to keep the symbol in the ELF.The functionality of this class is only supported in the simulator.