Getting Started with Cerebras CSL¶
Cerebras CSL (Cerebras System Language) is a low-level kernel programming language designed for the Cerebras system. It enables users to write code that runs on individual Processing Elements (PEs) and to define the placement of programs and the routing of data on the Wafer-Scale Engine (WSE).
To develop programs for the Cerebras system, users create two main components:
- Device Code: Written in CSL, this code executes directly on the Cerebras system.
- Host Code: Written in Python, this code leverages Cerebras APIs to facilitate data movement and execute functions on the Cerebras system. CSL includes libraries for a variety of commonly used primitive operations, such as broadcasting, gathering, and scattering data across rows or columns of PEs.
The Cerebras SDK can be utilized in two primary modes: 1. Simulator Mode: For testing and debugging programs without access to physical hardware. 2. Appliance Mode: For executing programs on the actual Cerebras hardware.
For a comprehensive overview of the Cerebras SDK, refer to the Cerebras SDK Documentation.
SDK with Simulator¶
The Cerebras SDK relies on a Singularity container and associated scripts to execute CSL code on a simulator.
On a user node, the Cerebras SDK is available at /software/cerebras/cs_sdk for your convenience. You can copy it to your $HOME directory, add it to your $PATH, and you’re ready to get started.
To verify that the SDK is installed correctly, execute the command: cslc --help
Examples¶
We will use examples from the csl-examples repository provided by Cerebras. To get these examples, clone the repository into your desired directory:
Note: to access any external web resources from a Cerebras user node, you will need to have a proxy environment variable set (or equivalent). wget needs the lower-case proxy environment variable.
Sample output:
$ bash commands_wse3.sh
[INFO] === Beginning compilation ===
[INFO] Using SIF: ~/cs_sdk-1.4.0/sdk-cbcore-202505010205-2-ef181f81.sif
[INFO] CSL_IMPORT_PATH is not set
[INFO] CSL_IMPORT_PATH accepts colon separated list of paths generated by 'realpath <path>'
[INFO] Compilation successful
[INFO] === Calling container-hosted python ===
[INFO] Using SIF: ~/cs_sdk-1.4.0/sdk-cbcore-202505010205-2-ef181f81.sif
SUCCESS
SDK GUI¶
You can use the SDK Debug GUI to analyze and gain insights into your code execution. For detailed instructions, refer to the SDK GUI documentation.
To launch the SDK Debug GUI, run the following commands:
Sample output:
[INFO] Using SIF: /home/vsastry/CS3_system/cs_sdk-1.4.0/sdk-cbcore-202505010205-2-ef181f81.sif
[INFO] CSL_IMPORT_PATH is not set
[INFO] CSL_IMPORT_PATH accepts colon separated list of paths generated by 'realpath <path>'
Click this link to open URL: http://cer-anl-net001-us-sr01:8000/sdk-gui
Click this link to open URL: http://10.125.11.2:8000/sdk-gui
Press Ctrl-C to exit
To access the GUI from your local computer, forward port 8000 from the user node through a login node to a local machine port 8008.
Adjust one or both port numbers if they are already in use.
Example script to forward port 8000 to localhost 8008:
export SDK_PORT=8000
export LOCAL_PORT=8008
export ALCFUserID=<your alcf username>
ssh -L $LOCAL_PORT:localhost:$LOCAL_PORT $ALCFUserID@cer-login-04.ai.alcf.anl.gov -t ssh -L $LOCAL_PORT:localhost:$SDK_PORT -N cer-anl-net001-us-sr01
Then open the following URL in your web browser: http://localhost:8008/sdk-gui/

SDK with Appliance Mode¶
Appliance Mode enables running code directly on the Cerebras Wafer-Scale Cluster. In addition to the containerized Singularity build of the Cerebras SDK, the SDK also supports operations on Cerebras Wafer-Scale Clusters running in appliance mode. Please note that the compilation is performed on the worker/management node, hence there might not be enough resourses while compiling a model along with other jobs running. For more information on differences between the simulator code and changes needed to run on appliance, refer to Appliance Mode.
Setup¶
Create Virtual Environment: Follow these steps to set up the virtual environment for the Cerebras SDK:
Install SDK Packages: Install the cerebras_appliance and cerebras_sdk Python packages in the virtual environment, specifying the appropriate Cerebras Software release:
Examples¶
We will use examples from the csl-examples repository provided by Cerebras. To access these examples, clone the repository into your desired directory:
Compile Code¶
Use the following appliance_compile.py script to compile the code in the respective example directory:
Sample output:
$ python appliance_compile.py
INFO:cerebras.cluster.client:Appliance client semantic version: 1.1.0, cluster server semantic version: 1.1.2, job operator semantic version: 1.1.2
INFO:cerebras.cluster.client:Initiating a new SDK compile job against the cluster server
INFO:cerebras.cluster.client:Job id: wsjob-4mhdefdzswskmakfcp9hfe, workflow id: wflow-2ullyamqmrdi7nxodyl6f77xbi, namespace: job-operator, remote log path:
/n1/wsjob/workdir/job-operator/wsjob-4mhdefdzswskmakfcp9hfe
INFO:cerebras.cluster.client:Poll ingress status: Waiting for all Coordinator pods to be running, current running: 0/1.
INFO:cerebras.cluster.client:Recording the timestamp when jobs is scheduled.
WARNING:cerebras.cluster.client:Event 2025-10-23 19:49:54 +0000 UTC reason=InconsistentVersion wsjob=wsjob-4mhdefdzswskmakfcp9hfe message='Warning: client semantic version 1.1.0 is inconsistent with cluster server semantic version 1.1.2, there's a risk job could fail due to inconsistent setup.'
INFO:cerebras.cluster.client:Poll ingress status: Waiting for job ingress readiness.
INFO:cerebras.cluster.client:Poll ingress status: Job ingress ready, dashboard: https://grafana.anl0.cerebras.internal/d/WebHNShVz/wsjob-dashboard?orgId=1&var-wsjob=wsjob-
4mhdefdzswskmakfcp9hfe&from=1761248404000&to=now
INFO:cerebras.cluster.client:Poll ingress success: Job ingress ready, dashboard: https://grafana.anl0.cerebras.internal/d/WebHNShVz/wsjob-dashboard?orgId=1&var-
wsjob=wsjob-4mhdefdzswskmakfcp9hfe&from=1761248404000&to=now
2025-10-23 19:50:44,583 INFO CSL compiler output:
CSL compiler produced no messages. Compilation successful.
INFO:cerebras.sdk.client.sdk_appliance_client:CSL compiler output:
CSL compiler produced no messages. Compilation successful.
The only difference between CS-3 and simuator run is the fabric_dims. It should be set to minimum required for simulatored runs. Above script generates artifact.json which is used by the appliance_run.py script.
Run Code¶
Use the following appliance_run.py script to run the code in the respective example directory:
Sample output:
$ python appliance_run.py
INFO:cerebras.cluster.client:Appliance client semantic version: 1.1.0, cluster server semantic version: 1.1.2, job operator semantic version: 1.1.2
INFO:cerebras.cluster.client:Initiating a new SDK compile job against the cluster server
INFO:cerebras.cluster.client:Job id: wsjob-qqcsg8g5z66nknmk4d48gp, workflow id: wflow-kcrf2anv7zconl7xq2idceztdq, namespace: job-operator, remote log path:
/n1/wsjob/workdir/job-operator/wsjob-qqcsg8g5z66nknmk4d48gp
INFO:cerebras.cluster.client:Poll ingress status: Waiting for all Coordinator pods to be running, current running: 0/1.
INFO:cerebras.cluster.client:Recording the timestamp when jobs is scheduled.
WARNING:cerebras.cluster.client:Event 2025-10-23 19:54:55 +0000 UTC reason=InconsistentVersion wsjob=wsjob-qqcsg8g5z66nknmk4d48gp message='Warning: client semantic version 1.1.0 is inconsistent with cluster server semantic version 1.1.2, there's a risk job could fail due to inconsistent setup.'
INFO:cerebras.cluster.client:Poll ingress status: Waiting for job ingress readiness.
INFO:cerebras.cluster.client:Poll ingress status: Job ingress ready, dashboard: https://grafana.anl0.cerebras.internal/d/WebHNShVz/wsjob-dashboard?orgId=1&var-wsjob=wsjob- qqcsg8g5z66nknmk4d48gp&from=1761248705000&to=now
INFO:cerebras.cluster.client:Poll ingress success: Job ingress ready, dashboard: https://grafana.anl0.cerebras.internal/d/WebHNShVz/wsjob-dashboard?orgId=1&var-
wsjob=wsjob- qqcsg8g5z66nknmk4d48gp&from=1761248705000&to=now
SUCCESS!