Documentation Index Fetch the complete documentation index at: https://sdk.cerebras.ai/llms.txt
Use this file to discover all available pages before exploring further.
This section presents the SdkLayout program layout specification Python API.
Note that this API is part of the sdkruntimepybind module documented in
SdkRuntime API Reference .
CodeRegion
class cerebras.sdk.runtime.sdkruntimepybind.CodeRegion
Specifies a code region. Create and return a new color that is scoped within a region. Name to be assigned to the color.
Returns : A new color scoped within this region.
Return type : Color
color (name: str, value: int) → Color
Create and return a new color (with a value) that is scoped within a region. Name to be assigned to the color.
Value to be assigned to the color.
Returns : A new color scoped within this region.
Return type : Color
Given a color, an orientation (i.e., edge), a set of output routes, a size, and an
optional prefix, create and return a new input communication port. The optional prefix
can be used to create unique ports with the same color. Ports must be unique, otherwise an
exception is thrown. Edge on which to create the input port.
List of output routes for the input port.
The size of the port’s data, used to verify port compatibility.
Optional prefix to port’s name, which allows creation of unique ports with the same color.
Returns : Handle to the created input port.
Return type : PortHandle
Given a color, an orientation (i.e., edge), a set of input routes, a size, and an
optional prefix, create and return a new output communication port. The optional prefix
can be used to create unique ports with the same color. Ports must be unique, otherwise an
exception is thrown. Color of the output port.
Edge on which to create the output port.
List of input routes for the output port.
The size of the port’s data, used to verify port compatibility.
Optional prefix to port’s name, which allows creation of unique ports with the same color.
Returns : Handle to the created output port.
Return type : PortHandle
Set the routing for a given color on a single PE within this region. Coordinate on which color will be painted.
Color to be painted on this coordinate.
List of routing positions which will be applied to this color.
Set the routing for a given color on all PEs of the region. Color to be painted on this region.
List of routing positions which will be applied to this color.
Set the routing for a given color on all PEs of the region with special routing on one or
all region edges. Color to be painted on this region.
List of routing positions which will be applied to this color.
List of routing positions to be applied to this color on the region’s edges.
Set the routing for a given color on a contiguous rectangular subset of PEs within this region. Rectangular subset of PEs within this region on which color will be painted.
Color to be painted on this rectangle.
List of routing positions which will be applied to this color.
Place code region at specific coordinates (x, y). x-coordinate at which core region will be placed.
y-coordinate at which core region will be placed.
set_param (coord: IntVector , name: str, value: int)
Set an unsigned integer parameter on a single PE within this region. Coordinate on which parameter will be set.
Unsigned integer value of the parameter.
Set a color parameter on a single PE within this region. Coordinate on which parameter will be set.
Color value of the parameter.
Set the value of parameter name on a single PE within this region with the value of
color value. Coordinate on which parameter will be set.
Color value of the parameter.
set_param_all (name: str, value: int)
Set an unsigned integer parameter on all PEs of the region. Unsigned integer value of the parameter.
set_param_all (color: Color )
Set a color parameter on all PEs of the region. Color value of the parameter.
set_param_all (name: str, value: Color )
Set the value of parameter name on all PEs of the region with the value of color value. Color value of the parameter.
Set an unsigned integer parameter on a contiguous rectangular subset of PEs within this region. Rectangular subset of PEs within this region on which parameter will be set.
Unsigned integer value of the parameter.
Set a color parameter on a contiguous rectangular subset of PEs within this region. Rectangular subset of PEs within this region on which parameter will be set.
Color value of the parameter.
Set the value of parameter name on a contiguous rectangular subset of PEs within this
region with the value of color value. Rectangular subset of PEs within this region on which parameter will be set.
Color value of the parameter.
set_symbol_all (symbol: str, data: np.ndarray, width: int, height: int)
Given a symbol name symbol and data with a given 2D shape specified by width
and height, store data uniformly across the PEs of this code region. The 2D shape of
data must be a multiple of the code region’s dimensions or an error will be emitted. 2D data array to be applied to the symbol. Data must be of type np.int32,
np.uint32, np.float32, np.int16, or np.uint16.
Color
class cerebras.sdk.runtime.sdkruntimepybind.Color (name: str, value: Optional[int] = None)
Represents a color with an optional user-specified physical value. Objects of this class can be
used for routing and can also be used to set microcode parameter values. If a physical value is
not provided, then a physical value will be allocated automatically by the compiler. Physical value given to the color. If not provided, then a value will be allocated
automatically by the compiler. The maximum value is 23.
Returns the global name of the color. If this color is attached to a region, then the name
returned takes the form region_name + _ + name.
Returns : Global name of the color.
Return type : str
get_local_param_name () → str
Returns the name of the color.
Returns : Name of the color.
Return type : str
get_value () → Optional[int]
Returns the color’s physical value if one has been assigned. Otherwise, returns None.
Returns : Physical value of the color.
Return type : Optional[int]
Edge
class cerebras.sdk.runtime.sdkruntimepybind.Edge
Represents edge positions along the boundary of a code region.
Values :
EdgeRouteInfo
class cerebras.sdk.runtime.sdkruntimepybind.EdgeRouteInfo
For a given code region, represents the routing positions in one of the region’s four edges.
FP16TYPE
class cerebras.sdk.runtime.sdkruntimepybind.FP16TYPE
Specifies the 16-bit floating point format for compilation.
Values :
F16 : IEEE 754 half-precision (f16)
BF16 : Brain floating point (bf16)
CB16 : Cerebras 16-bit floating point (cb16)
SdkLayout
Specifies a program layout. This API allows the user to define rectangular code regions, define
color routing and switching, automatically allocate colors, and automatically route between code
regions. Execution platform specification.
Message logging output level. Available output levels are DEBUG,
INFO, WARNING, and ERROR. Default value is WARNING.
__init__ (fabric_file: Union[pathlib.Path, str], **kwargs)
Constructor variant that takes a path to a fabric JSON file which is used to define the
compile target and execution platform. Takes same kwargs as above. fabric_file (Union[pathlib.Path, str])
Path to a fabric JSON file.
Constructor variant that takes a target architecture. Takes same kwargs as above. Target architecture for compilation.
compile (out_prefix: str, libs: List[str] = [], cslc_prefix: str = "", save_port_map: bool = False, f16_type: FP16TYPE = FP16TYPE.F16) → SdkCompileArtifacts
Compile this layout and produce artifacts with a given path prefix. Path to which artifacts will be produced.
List of additional library search paths for the compiler.
Path prefix for the CSL compiler. If empty, the default compiler is used.
If True, saves the port mapping to a file.
Specifies the 16-bit floating point format for compilation.
Automatically connect two ports. Transmitting output data port which will send data to rx.
Receiving input data port which will receive data from tx.
create_code_region (source: str, name: str, width: int, height: int) → CodeRegion
Create a code region. Path to code source file.
Name of the created code region.
Width in PEs of the created code region.
Height in PEs of the created code region.
Returns : The created code region object.
Return type : CodeRegion
create_input_stream (port: PortHandle , io_loc: Optional[IntVector ] = None, io_buffer_size: int = 1024) → str
Sets up an input stream from the host to a 1-PE region at io_loc and then to input port
port. If io_loc is not provided, an available location will be automatically picked.
io_buffer_size can be provided to specify the buffer size at io_loc. Returns the name
of the stream’s port which can be used by the SdkRuntime direct link API method
SdkRuntime.send() . PE location on wafer which receives input stream data. If not provided, a
location is automatically chosen.
Buffer size allocated at io_loc. Default is 1024.
Returns : Name of created input stream’s port.
Return type : str
create_input_stream_from_loc (loc: IntVector , color: Color , prefix: str = '') → str
Sets up an input stream from the host to loc on a given color color assuming that
a code region is already defined at loc to consume the incoming data. An optional
prefix can be provided to uniquely identify the stream in case of naming conflicts. Returns
the name of the stream’s port which can be used by the SdkRuntime direct link API
method SdkRuntime.send() . PE location of existing input port into which data will be streamed.
Color on which stream transmits data.
Optional prefix prepended to created stream’s name.
Returns : Name of created input stream’s port.
Return type : str
create_output_stream (port: PortHandle , io_loc: IntVector = None, io_buffer_size: int = 1024) → str
Sets up an output stream from output port port to a 1-PE region at io_loc and then
to the host. If io_loc is not provided, an available location will be automatically
picked. io_buffer_size can be provided to specify the buffer size at io_loc. Returns
the name of the stream’s port which can be used by the SdkRuntime direct link API
methods SdkRuntime.receive() and SdkRuntime.receive_tofile() . PE location on wafer which sends out output stream data. If not provided, a
location is automatically chosen.
Buffer size allocated at io_loc. Default is 1024.
Returns : Name of created output stream’s port.
Return type : str
create_output_stream_from_loc (loc: IntVector , color: Color , prefix: str = '') → str
Sets up an output stream to the host from loc on a given color color assuming that
a code region is already defined at loc to produce the outgoing data. An optional
prefix can be provided to uniquely identify the stream in case of naming conflicts. Returns
the name of the stream’s port which can be used by the SdkRuntime direct link API
methods SdkRuntime.receive() and SdkRuntime.receive_tofile() . PE location of existing output port from which data will be streamed.
Color on which stream transmits data.
Optional prefix prepended to created stream’s name.
Returns : Name of created output stream’s port.
Return type : str
Place child code regions horizontally and relative to the first child in the given list, and
return the width of the resulting code region. Code regions to be placed.
Returns : Width of resulting code region.
Return type : int
Place child code regions horizontally and relative to a specified origin, and return the
width of the resulting code region. Code regions to be placed.
PE coordinate which serves as origin for placed code regions.
Returns : Width of resulting code region.
Return type : int
Place child code regions vertically and relative to the first child in the given list, and
return the height of the resulting code region. Code regions to be placed.
Returns : Height of resulting code region.
Return type : int
Place child code regions vertically and relative to a specified origin, and return the
height of the resulting code region. Code regions to be placed.
PE coordinate which serves as origin for placed code regions.
Returns : Height of resulting code region.
Return type : int
PortHandle
class cerebras.sdk.runtime.sdkruntimepybind.PortHandle
Handle to a program input or output data port.
Route
class cerebras.sdk.runtime.sdkruntimepybind.Route
Represents route directions.
Values :
RAMP
EAST
WEST
NORTH
SOUTH
RoutingPosition
class cerebras.sdk.runtime.sdkruntimepybind.RoutingPosition
Represents a single routing position, which can consist of one or more route values
for input and one or more route values for output. set_input (routes: List[Route ])
Set a list of routes as the input route position. List of routes to be set as the input route position.
set_output (routes: List[Route ])
Set a list of routes as the output route position. List of routes to be set as the output route position.
Add a route to the input route position. Route to be added to the input route position.
Add a route to the output route position. Route to be added to the output route position.
get_input () → List[Route ]
For this routing position object, return a list of all input routes in the input route
position.
Returns : List of all routes in the input route position.
Return type : List[Route ]
get_output () → List[Route ]
For this routing position object, return a list of all output routes in the output route
position.
Returns : List of all routes in the output route position.
Return type : List[Route ]
get_edge_routing
Construct an edge routing info object from a given edge and routing positions. List of routing positions to be applied to edge.
Returns : Object containing edge routing info.
Return type : EdgeRouteInfo
Geometry
IntRectangle
Defines a rectangle of values. Origin of rectangle’s northwest corner.
Width and height of rectangle.
IntVector
class cerebras.geometry.geometry.IntVector (x: int, y: int)
Wraps a tuple of two integer values, often used to specify coordinates or offsets.