This section presents theDocumentation Index
Fetch the complete documentation index at: https://sdk.cerebras.ai/llms.txt
Use this file to discover all available pages before exploring further.
SdkRuntime Python host API reference and
associated utilities to develop kernels for the Cerebras Wafer-Scale Engine.
sdkruntimepybind module
Python API forSdkRuntime functions.
MemcpyDataType
Specifies the data size for transfers using
SdkRuntime.memcpy_d2h() and SdkRuntime.memcpy_h2d() copy mode.Values:
- MEMCPY_16BIT
- MEMCPY_32BIT
MemcpyOrder
Specifies mapping of data for transfers using
SdkRuntime.memcpy_d2h() and SdkRuntime.memcpy_h2d() copy mode.Values:
- ROW_MAJOR
- COL_MAJOR
SdkCompileArtifacts
Specifies compile artifacts for execution.
SdkExecutionPlatform
Specifies the simulator or system target and architecture for execution.
SdkRuntime
class cerebras.sdk.runtime.sdkruntimepybind.SdkRuntime(bindir: Union[pathlib.Path, str], **kwargs)
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
Specifies a target compilation architecture.
Values:
- WSE2
- WSE3
SimfabConfig
class cerebras.sdk.runtime.sdkruntimepybind.SimfabConfig(num_threads: int = 16, suppress_trace: bool = False, dump_core: bool = False, core_path: Optional[Union[pathlib.Path, str]] = None)
Bases: object
Specifies simfab configuration for simulator runs.
Task
class cerebras.sdk.runtime.sdkruntimepybind.Task
Handle to a task launched by
SdkRuntime.get_platform
cerebras.sdk.runtime.sdkruntimepybind.get_platform(cmaddr: Optional[str] = None, config: SimfabConfig = SimfabConfig(), target: SdkTarget = SdkTarget::WSE3) → SdkExecutionPlatform
Constructs an
SdkExecutionPlatform object configured by simulator or system settings and target architecture.
- Returns: A configured execution platform object.
- Return type:
SdkExecutionPlatform
get_simulator
cerebras.sdk.runtime.sdkruntimepybind.get_simulator(config: SimfabConfig = SimfabConfig(), target: SdkTarget = SdkTarget::WSE3) → SdkExecutionPlatform
Constructs an
SdkExecutionPlatform object for simulator.
- Returns: A configured execution platform object.
- Return type:
SdkExecutionPlatform
get_system
cerebras.sdk.runtime.sdkruntimepybind.get_system(cmaddr: str) → SdkExecutionPlatform
Constructs an
SdkExecutionPlatform object for a real system.
- Returns: A configured execution platform object.
- Return type:
SdkExecutionPlatform
sdk_utils module
Utility functions for common operations withSdkRuntime.
Import from cerebras.sdk.sdk_utils.
calculate_cycles
cerebras.sdk.sdk_utils.calculate_cycles(timestamp_buf: numpy.ndarray) → numpy.int64
Converts values in Then the elapsed cycles can be calculated on the host with:
timestamp_buf returned from device into a human-readable elapsed cycle count.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:
- Returns: Elapsed cycle count.
- Return type:
numpy.int64
input_array_to_u32
cerebras.sdk.sdk_utils.input_array_to_u32(arr: numpy.ndarray, sentinel: Optional[int], fast_dim_sz: int) → numpy.ndarray
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
arrwith specified numpy data type.- Return type:
numpy.ndarray.view
memcpy_view
cerebras.sdk.sdk_utils.memcpy_view(arr: numpy.ndarray, datatype: numpy.dtype) → numpy.ndarray.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).
Example:
- Returns: Numpy view into
arrwith specified numpy data type.- Return type:
numpy.ndarray.view
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 fromcerebras.sdk.debug.debug_util.
debug_util
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.
