Use this file to discover all available pages before exploring further.
This section presents the SDK Appliance API reference for running SDK
programs on a Cerebras Wafer-Scale Cluster (WSC).See Running SDK on a Wafer-Scale Cluster for an introduction to running in appliance mode
on a Wafer-Scale Cluster.
If True, ignore version differences between appliance client and server.
Example:In the following example, an SdkCompiler object is instantiated
via a context manager.
The SdkCompiler.compile() function takes four arguments:
the directory containing the CSL code files,
the name of the top level CSL code file that contains the layout block,
the compiler arguments,
and the output directory or output file for the compile artifacts.
import jsonfrom cerebras.sdk.client import SdkCompiler# Instantiate compiler using a context managerwith SdkCompiler(disable_version_check=True) as compiler: # Launch compile job artifact_path = compiler.compile( ".", "layout.csl", "--fabric-dims=8,3 --fabric-offsets=4,1 --memcpy --channels=1 -o out", "." ) # Write the artifact_path to a JSON file with open("artifact_path.json", "w", encoding="utf8") as f: json.dump({"artifact_path": artifact_path,}, f)
class cerebras.sdk.client.SdkLauncher(artifact_path: str, **kwargs)
Bases: object
The SdkLauncher API can be used to upload artifacts, run custom commands in
the appliance, and use custom scripts written as if the system was not in
appliance mode and the user were running directly from a worker node.The user must use the %CMADDR% template string to pass the system address
to a run script.
If True, ignore version differences between appliance client and server.
Example:In the following example, an SdkLauncher object is instantiated via a
context manager, with path to compile artifacts given by artifact_path.
launcher.stage transfers an additional file additional_artifact.txt
to the appliance. Next, launcher.run runs a command on the appliance
worker node which writes the contents of that file to stdout.
We then use launcher.run to run a host Python script run.py.
Notice that we specify the system’s CM address passed to this script via
the template string %CMADDR, which will be evaluated at runtime based
on the system allocated to this job. We then use download_artifact
to transfer a file back from the appliance.
import jsonimport osfrom cerebras.sdk.client import SdkLauncher# read the compile artifact_path from the json filewith open("artifact_path.json", "r", encoding="utf8") as f: data = json.load(f) artifact_path = data["artifact_path"]# artifact_path contains the path to the compiled artifact.# It will be transferred and extracted in the appliance.# The extracted directory will be the working directory.# Set simulator=False if running on CS system within appliance.with SdkLauncher(artifact_path, simulator=False, disable_version_check=True) as launcher: # Transfer an additional file to the appliance, # then write contents to stdout on appliance launcher.stage("additional_artifact.txt") response = launcher.run( "echo \"ABOUT TO RUN IN THE APPLIANCE\"", "cat additional_artifact.txt", ) print("Test response: ", response) # Run the original host code as-is on the appliance, # using the same cmd as when using the Singularity container response = launcher.run("cs_python run.py --name out --cmaddr %CMADDR%") print("Host code execution response: ", response) # Fetch files from the appliance launcher.download_artifact("out.txt", "./output_dir/out.txt")
One or more command strings. Use the special placeholder
%CMADDR% wherever a CS system address should be substituted.
All positional arguments must be strings.
class cerebras.sdk.client.SdkRuntime(artifact_path: str, **kwargs)
Bases: object
Manages the execution of SDK programs on the Cerebras Wafer-Scale Cluster
appliance. The constructor analyzes the WSE ELFs in the bindir
and prepares the WSE or simfabric for a run.SdkRuntime must be used via a context manager.
Path to ELF files compiled by SdkCompiler.
The runtime collects the I/O and fabric parameters
automatically, including height, width, number of
channels, width of buffers, etc.
If True, ignore version differences between appliance client and server.
Example:In the following example, an SdkRuntime runner object is instantiated
via a context manager, with path to compile artifacts given by
artifact_path. The compiled kernel code has exported symbols
my_fn, which names a function defined on all PEs in the program, and
A, which points to an array on all PEs. The context manager loads and
starts the program. Then, the function my_fn is launched. After this
function is launched, A on the device is copied back into data
on the host.
import jsonimport osfrom cerebras.sdk.client import SdkRuntime# Read the artifact_path from the JSON filewith open("artifact_path.json", "r", encoding="utf8") as f: data = json.load(f) artifact_path = data["artifact_path"]# Instantiate a runner object using a context manager.# Set simulator=False if running on CS system within appliance.with SdkRuntime(artifact_path, simulator=False, disable_version_check=True) as runner: # Launch my_fn on device runner.launch('my_fn', nonblock=False) # Copy A back from device symbol_A = runner.get_id("A") runner.memcpy_d2h(data, symbol_A, px, py, w, h, l, streaming=False, data_type=memcpy_dtype, order=memcpy_order, nonblock=False)