Documentation
¶
Overview ¶
Code generated by gen-nccl-extensions. DO NOT EDIT.
Package ncclep provides Go bindings for the NCCL expert-parallel communication library, libnccl_ep.
Communicators, streams, windows, data types, and result codes use the types in github.com/tmc/lib/nvidia/nccl. This package loads and probes libnccl_ep independently of NCCL.
Initialize public descriptors with their New functions before setting workload fields. Their zero values do not contain the required ABI size and magic fields. Configuration defaults alone do not define a valid workload: set the group dimensions and choose an explicit handle layout before creating handles.
Device storage, tensor descriptors, callbacks, and asynchronous input arrays are caller-owned. Keep them valid until the operation completes. Pin any Go memory retained by C, including nested pointers, for the full retention interval. A uintptr does not keep an allocation alive. MaskQuery writes a device array; MaskUpdate reads a host array asynchronously.
See the NCCL EP reference for collective ordering and supported algorithms.
Operations ¶
- Handle.Combine: combines expert outputs in the original token order.
- Handle.Complete: completes a staged EP operation on the given stream.
- Handle.Dispatch: dispatches tokens to experts using the handle's routing metadata.
- GetVersion: returns the EP library version code.
Groups and handles ¶
- NewGroup: collectively creates an EP group from an NCCL communicator.
- Group.CreateHandle: creates a handle and updates its routing metadata.
- Group.Close: destroys an EP group.
- Handle.Close: destroys a handle without freeing caller-owned storage.
- Group.MemSize: returns the required caller-owned handle storage size in bytes.
- Group.InitHandle: initializes a handle for an explicit layout.
- Handle.Update: updates a handle's routing metadata on the given stream.
Failure handling ¶
- Group.ErrorClear: clears the group's asynchronous error flag.
- Group.AsyncError: reads the asynchronous error flag without synchronizing the GPU.
- Group.MaskClean: collectively cleans masked-rank communication state.
- Group.MaskQuery: copies the rank mask to a device array asynchronously.
- Group.MaskUpdate: copies a host rank mask to the device asynchronously.
Tensor descriptors ¶
- TensorAlloc: allocates a tensor descriptor and copies its dimensions.
- TensorDestroy: releases a descriptor returned by TensorAlloc.
Code generated by gen-nccl-extensions. DO NOT EDIT.
Code generated by gen-nccl-extensions. DO NOT EDIT.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/nccl"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
dims := [2]uint{32, 128}
tensor := ncclep.NewTensor()
tensor.Ndim = 2
tensor.Datatype = nccl.Float32
tensor.Sizes = &dims[0]
// Set Data or WinHdl to device storage before submitting tensor operations.
fmt.Println(tensor.Ndim, tensor.Datatype, *tensor.Sizes)
}
Output: 2 Float32 32
Index ¶
- Constants
- func Close() error
- func Combine(handle Handle, inputs *CombineInputs, outputs *CombineOutputs, ...) error
- func Complete(handle Handle, config *CompleteConfig, stream driver.Stream) error
- func Dispatch(handle Handle, inputs *DispatchInputs, outputs *DispatchOutputs, ...) error
- func ErrorClear(epGroup Group) error
- func GetAsyncError(epGroup Group) (int32, error)
- func GetVersion() (int32, error)
- func GroupDestroy(epGroup Group) error
- func HandleDestroy(handle Handle) error
- func HandleMemSize(epGroup Group, layout Layout, config *HandleConfig, numTopk int32) (uint, error)
- func Has(symbol string) bool
- func HasCombine() bool
- func HasComplete() bool
- func HasCreateGroup() bool
- func HasCreateHandle() bool
- func HasDispatch() bool
- func HasErrorClear() bool
- func HasGetAsyncError() bool
- func HasGetVersion() bool
- func HasGroupDestroy() bool
- func HasHandleDestroy() bool
- func HasHandleMemSize() bool
- func HasInitHandle() bool
- func HasMaskClean() bool
- func HasMaskQuery() bool
- func HasMaskUpdate() bool
- func HasTensorAlloc() bool
- func HasTensorDestroy() bool
- func HasUpdateHandle() bool
- func Load(path string) error
- func Loaded() bool
- func MaskClean(epGroup Group, stream driver.Stream) error
- func MaskQuery(epGroup Group, maskStatus nccl.Buffer, stream driver.Stream) error
- func MaskUpdate(epGroup Group, mask *int32, stream driver.Stream) error
- func Path() string
- func TensorDestroy(tensor *Tensor) error
- func UpdateHandle(handle Handle, topkIdx *Tensor, layoutInfo *LayoutInfo, stream driver.Stream) error
- type Algorithm
- type AllocConfig
- type BindFailure
- type CallError
- type CombQuant
- type CombineConfig
- type CombineInputs
- type CombineOutputs
- type CompleteConfig
- type DispQuant
- type DispatchConfig
- type DispatchInputs
- type DispatchOutputs
- type ExpertIdKind
- type Group
- func (g Group) AsyncError() (int32, error)
- func (g *Group) Close() error
- func (g Group) CreateHandle(layout Layout, topkIdx *Tensor, layoutInfo *LayoutInfo, config *HandleConfig, ...) (Handle, error)
- func (g Group) ErrorClear() error
- func (g Group) InitHandle(layout Layout, config *HandleConfig, numTopk int32, handleMem *Tensor) (Handle, error)
- func (g Group) MaskClean(stream driver.Stream) error
- func (g Group) MaskQuery(maskStatus nccl.Buffer, stream driver.Stream) error
- func (g Group) MaskUpdate(mask *int32, stream driver.Stream) error
- func (g Group) MemSize(layout Layout, config *HandleConfig, numTopk int32) (uint, error)
- type GroupConfig
- type Handle
- func (h *Handle) Close() error
- func (h Handle) Combine(inputs *CombineInputs, outputs *CombineOutputs, config *CombineConfig, ...) error
- func (h Handle) Complete(config *CompleteConfig, stream driver.Stream) error
- func (h Handle) Dispatch(inputs *DispatchInputs, outputs *DispatchOutputs, layoutInfo *LayoutInfo, ...) error
- func (h Handle) Update(topkIdx *Tensor, layoutInfo *LayoutInfo, stream driver.Stream) error
- type HandleConfig
- type Layout
- type LayoutInfo
- type LibraryAttempt
- type LibraryConflictError
- type LibraryError
- type OverflowPolicy
- type PassDir
- type Result
- type SymbolError
- type Tensor
- type TensorAllocConfig
- type ZeroCopyMode
Examples ¶
Constants ¶
const ( // CombineConfigCurrentVersion is NCCL_EP_COMBINE_CONFIG_CURRENT_VERSION. CombineConfigCurrentVersion = 2 // CombineConfigSize is NCCL_EP_COMBINE_CONFIG_SIZE. CombineConfigSize = 20 // CombineConfigV1Size is NCCL_EP_COMBINE_CONFIG_V1_SIZE. CombineConfigV1Size = 16 // CombineConfigV2Size is NCCL_EP_COMBINE_CONFIG_V2_SIZE. CombineConfigV2Size = 20 // CombineInputsCurrentVersion is NCCL_EP_COMBINE_INPUTS_CURRENT_VERSION. CombineInputsCurrentVersion = 2 // CombineInputsSize is NCCL_EP_COMBINE_INPUTS_SIZE. CombineInputsSize = 32 // CombineInputsV1Size is NCCL_EP_COMBINE_INPUTS_V1_SIZE. CombineInputsV1Size = 24 // CombineInputsV2Size is NCCL_EP_COMBINE_INPUTS_V2_SIZE. CombineInputsV2Size = 32 // CombineOutputsCurrentVersion is NCCL_EP_COMBINE_OUTPUTS_CURRENT_VERSION. CombineOutputsCurrentVersion = 1 // CombineOutputsSize is NCCL_EP_COMBINE_OUTPUTS_SIZE. CombineOutputsSize = 24 // CombineOutputsV1Size is NCCL_EP_COMBINE_OUTPUTS_V1_SIZE. CombineOutputsV1Size = 24 // CompleteConfigCurrentVersion is NCCL_EP_COMPLETE_CONFIG_CURRENT_VERSION. CompleteConfigCurrentVersion = 1 // CompleteConfigSize is NCCL_EP_COMPLETE_CONFIG_SIZE. CompleteConfigSize = 8 // CompleteConfigV1Size is NCCL_EP_COMPLETE_CONFIG_V1_SIZE. CompleteConfigV1Size = 8 // DispatchConfigCurrentVersion is NCCL_EP_DISPATCH_CONFIG_CURRENT_VERSION. DispatchConfigCurrentVersion = 2 // DispatchConfigSize is NCCL_EP_DISPATCH_CONFIG_SIZE. DispatchConfigSize = 24 // DispatchConfigV1Size is NCCL_EP_DISPATCH_CONFIG_V1_SIZE. DispatchConfigV1Size = 20 // DispatchConfigV2Size is NCCL_EP_DISPATCH_CONFIG_V2_SIZE. DispatchConfigV2Size = 24 // DispatchInputsCurrentVersion is NCCL_EP_DISPATCH_INPUTS_CURRENT_VERSION. DispatchInputsCurrentVersion = 1 // DispatchInputsSize is NCCL_EP_DISPATCH_INPUTS_SIZE. DispatchInputsSize = 32 // DispatchInputsV1Size is NCCL_EP_DISPATCH_INPUTS_V1_SIZE. DispatchInputsV1Size = 32 // DispatchOutputsCurrentVersion is NCCL_EP_DISPATCH_OUTPUTS_CURRENT_VERSION. DispatchOutputsCurrentVersion = 1 // DispatchOutputsSize is NCCL_EP_DISPATCH_OUTPUTS_SIZE. DispatchOutputsSize = 40 // DispatchOutputsV1Size is NCCL_EP_DISPATCH_OUTPUTS_V1_SIZE. DispatchOutputsV1Size = 40 // GroupConfigCurrentVersion is NCCL_EP_GROUP_CONFIG_CURRENT_VERSION. GroupConfigCurrentVersion = 2 // GroupConfigSize is NCCL_EP_GROUP_CONFIG_SIZE. GroupConfigSize = 112 // GroupConfigV1Size is NCCL_EP_GROUP_CONFIG_V1_SIZE. GroupConfigV1Size = 96 // GroupConfigV2Size is NCCL_EP_GROUP_CONFIG_V2_SIZE. GroupConfigV2Size = 112 // HandleConfigCurrentVersion is NCCL_EP_HANDLE_CONFIG_CURRENT_VERSION. HandleConfigCurrentVersion = 1 // HandleConfigSize is NCCL_EP_HANDLE_CONFIG_SIZE. HandleConfigSize = 16 // HandleConfigV1Size is NCCL_EP_HANDLE_CONFIG_V1_SIZE. HandleConfigV1Size = 16 // LayoutInfoCurrentVersion is NCCL_EP_LAYOUT_INFO_CURRENT_VERSION. LayoutInfoCurrentVersion = 2 // LayoutInfoSize is NCCL_EP_LAYOUT_INFO_SIZE. LayoutInfoSize = 48 // LayoutInfoV1Size is NCCL_EP_LAYOUT_INFO_V1_SIZE. LayoutInfoV1Size = 40 // LayoutInfoV2Size is NCCL_EP_LAYOUT_INFO_V2_SIZE. LayoutInfoV2Size = 48 // Magic is NCCL_EP_MAGIC. Magic = 3222274030 // Major is NCCL_EP_MAJOR. Major = 0 // Minor is NCCL_EP_MINOR. Minor = 2 // Patch is NCCL_EP_PATCH. Patch = 0 // TensorAllocConfigCurrentVersion is NCCL_EP_TENSOR_ALLOC_CONFIG_CURRENT_VERSION. TensorAllocConfigCurrentVersion = 1 // TensorAllocConfigSize is NCCL_EP_TENSOR_ALLOC_CONFIG_SIZE. TensorAllocConfigSize = 8 // TensorAllocConfigV1Size is NCCL_EP_TENSOR_ALLOC_CONFIG_V1_SIZE. TensorAllocConfigV1Size = 8 // TensorCurrentVersion is NCCL_EP_TENSOR_CURRENT_VERSION. TensorCurrentVersion = 1 // TensorMagic is NCCL_EP_TENSOR_MAGIC. TensorMagic = 3405695742 // TensorSize is NCCL_EP_TENSOR_SIZE. TensorSize = 48 // TensorV1Size is NCCL_EP_TENSOR_V1_SIZE. TensorV1Size = 48 // VersionCode is NCCL_EP_VERSION_CODE. Packed version code: MAJOR*10000 + MINOR*100 + PATCH. Mirrors NCCL_VERSION_CODE. VersionCode = 200 )
const APIVersion = 2
APIVersion is the public descriptor ABI version.
const Auto = 0
Auto selects automatic configuration for supported EP fields.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close() error
Close unloads the library and clears all bound function pointers.
The function pointers are package-level state, so Close must not be called concurrently with any other call into this package: doing so is a use-after-free. It is intended for test teardown, not for reclaiming a live library.
func Combine ¶
func Combine(handle Handle, inputs *CombineInputs, outputs *CombineOutputs, config *CombineConfig, stream driver.Stream) error
Combine combines expert outputs in the original token order.
Perform EP combine * Gathers outputs from experts and returns them to their source in original token order. * This call is collective and must be invoked by all ranks in the group.
- handle: in,out EP handle that was used for `[Handle.Dispatch]` operation
- inputs: in Named input tensors (see CombineInputs). The shapes of the tensors are identical to the shapes of the respective output tensors of the corresponding `[Handle.Dispatch]` call. The inputs->tokens tensor is required. For the backward pass in HT mode, the inputs->topk_weights must also be provided
- outputs: in,out Named preallocated output tensors (see CombineOutputs). outputs->tokens [num_tokens, hidden] is required; returns tokens in the original order. outputs->topk_weights: LL expert-major: per-token routing weights applied on the combine receive side. HT backward: must also be provided; receives combined routing weights
- config: in Combine configuration (see CombineConfig). NULL = defaults
- stream: in CUDA stream. If `[Handle.Combine]` is called on a different stream than the stream used in `[Group.CreateHandle]`, it is the responsibility of the user to synchronize between streams to ensure correctness
Wraps ncclEpCombine.
func Complete ¶
func Complete(handle Handle, config *CompleteConfig, stream driver.Stream) error
Complete completes a staged EP operation on the given stream.
Continues a staged EP operation to completion. * This should be called after a prior `[Handle.Dispatch]` or `[Handle.Combine]` call with `send_only` flag set.
- handle: in,out EP handle used in the preceding staged operation
- config: in Completion configuration (see CompleteConfig). NULL = defaults
- stream: in CUDA stream Notes: - If `[Handle.Complete]` is called on a different stream than the operation initiation call (i.e., `[Handle.Dispatch]` or `[Handle.Combine]`), it is the responsibility of the user to synchronize between streams to ensure correctness. - Only LL mode is supported
Wraps ncclEpComplete.
func Dispatch ¶
func Dispatch(handle Handle, inputs *DispatchInputs, outputs *DispatchOutputs, layoutInfo *LayoutInfo, config *DispatchConfig, stream driver.Stream) error
Dispatch dispatches tokens to experts using the handle's routing metadata.
Perform EP dispatch * Sends tokens and metadata to the experts according to routing decisions. * This call is collective and must be invoked by all ranks in the group.
- handle: in,out EP handle
- inputs: in Named input tensors (see DispatchInputs). inputs->tokens is required for all modes and layouts. For LL mode (rank-major layout) and HT mode (all layouts, forward pass), inputs->topk_weights must be provided
- outputs: in,out Named preallocated output tensors (see DispatchOutputs). outputs->tokens is required; other fields depend on the layout and pass direction. HT mode: The sizing of the output tensors relies on `num_recv_slots`. Static allocation: `num_recv_slots` is `max_recv_tokens_per_rank` (see GroupConfig.max_recv_tokens_per_rank). Required for CUDA Graph capturing. Query-then-allocate: `num_recv_slots` is the actual number of tokens this rank will receive (padded for Expert-major layout). Obtain the count from the LayoutInfo.recv_total_counter scalar tensor supplied to `[Group.CreateHandle]` / `[Handle.Update]`; the caller copies it device-to-host and synchronizes before allocating. The counter serves both layouts: for expert-major it reports the padded total. The count is readable in any mode; to size the outputs to it rather than to the worst case, the group must also be created with max_recv_tokens_per_rank = Auto. The outputs->tokens tensor shape is [num_recv_slots, hidden]. For the forward pass, in addition the following tensor[s] are required: * Expert-major layout: outputs->topk_weights tensor [num_recv_slots] (1D, one weight per slot) * Flat layout: outputs->topk_weights tensor [num_recv_slots, num_topk] outputs->topk_idx tensor [num_recv_slots, num_topk] LL mode: The set and shapes of the output tokens vary depending on the layout. * Expert-major layout: requires only outputs->tokens [local_experts, num_ranks * max_dispatch_tokens_per_rank, hidden] The actual number of tokens received by expert `e` is obtained via layoutInfo->expert_counters[`e`] (see below). * Rank-major layout: * outputs->tokens [num_ranks, max_dispatch_tokens_per_rank, hidden] * outputs->topk_weights [num_ranks, max_dispatch_tokens_per_rank, num_topk] * outputs->topk_idx [num_ranks, max_dispatch_tokens_per_rank, num_topk] The actual number of tokens received by rank `r` is obtained via layoutInfo->src_rank_counters[`r`] (see below)
- layoutInfo: in,out Named local tensors for layout-specific counters (see LayoutInfo). * For HT mode should be NULL, the counter information is available through Handle.Update. * For LL mode, layout-specific counter tensors must be provided (see LayoutInfo doc). * Expert-major layout: expert_counters tensor is required. * Rank-major layout: src_rank_counters is optional; when provided, it receives one token count per source rank
- config: in Dispatch configuration (see DispatchConfig). NULL = defaults
- stream: in CUDA stream. If `[Handle.Dispatch]` is called on a different stream than the stream used in `[Group.CreateHandle]`, it is the responsibility of the user to synchronize between streams to ensure correctness
Wraps ncclEpDispatch.
func ErrorClear ¶
ErrorClear clears the group's asynchronous error flag.
Clear the async error flag. Lightweight host-side reset — writes zero to the pinned CPU flag. Use after detecting an error (via Group.AsyncError) to re-arm the flag for detecting new failures. Should be called after Group.MaskClean (full recovery) or standalone when surviving ranks continue in degraded mode. Requires enable_mask=true in the group config.
- epGroup: in EP group with masking enabled
Wraps ncclEpErrorClear.
func GetAsyncError ¶
GetAsyncError reads the asynchronous error flag without synchronizing the GPU.
Poll for asynchronous errors (e.g., rank timeout). Lightweight host-side check — reads a pinned CPU flag, no GPU sync required. The flag is set by the kernel when a timeout masks a rank; clear it explicitly via Group.ErrorClear. Requires enable_mask=true in the group config.
- epGroup: in EP group with masking enabled
Wraps ncclEpGetAsyncError.
func GetVersion ¶
GetVersion returns the EP library version code.
Return the VersionCode of the NCCL EP library in the supplied integer. This integer is coded with the MAJOR, MINOR and PATCH level of the library.
Wraps ncclEpGetVersion.
func GroupDestroy ¶
GroupDestroy destroys an EP group.
Destroy an EP group and release associated resources.
- epGroup: in EP group to destroy
Wraps ncclEpGroupDestroy.
func HandleDestroy ¶
HandleDestroy destroys a handle without freeing caller-owned storage.
Destroy an EP handle and release all associated resources.
- handle: in EP handle to destroy
Wraps ncclEpHandleDestroy.
func HandleMemSize ¶
HandleMemSize returns the required caller-owned handle storage size in bytes.
Query the device bytes required for a handle's routing buffers.
- epGroup: in A valid EP group
- layout: in Receive buffer layout. Required; must not be LayoutUnset
- config: in Handle configuration (see HandleConfig). NULL = defaults
- numTopk: in Required for LL (> 0); optional for HT
Wraps ncclEpHandleMemSize.
func Has ¶
Has reports whether the named C symbol resolved in the loaded library, loading it first if necessary. It returns false if the library failed to load. Use it to gate on capabilities before calling into them.
func HasCombine ¶
func HasCombine() bool
HasCombine reports whether ncclEpCombine resolved in the loaded library.
func HasComplete ¶
func HasComplete() bool
HasComplete reports whether ncclEpComplete resolved in the loaded library.
func HasCreateGroup ¶
func HasCreateGroup() bool
HasCreateGroup reports whether ncclEpCreateGroup resolved in the loaded library.
func HasCreateHandle ¶
func HasCreateHandle() bool
HasCreateHandle reports whether ncclEpCreateHandle resolved in the loaded library.
func HasDispatch ¶
func HasDispatch() bool
HasDispatch reports whether ncclEpDispatch resolved in the loaded library.
func HasErrorClear ¶
func HasErrorClear() bool
HasErrorClear reports whether ncclEpErrorClear resolved in the loaded library.
func HasGetAsyncError ¶
func HasGetAsyncError() bool
HasGetAsyncError reports whether ncclEpGetAsyncError resolved in the loaded library.
func HasGetVersion ¶
func HasGetVersion() bool
HasGetVersion reports whether ncclEpGetVersion resolved in the loaded library.
func HasGroupDestroy ¶
func HasGroupDestroy() bool
HasGroupDestroy reports whether ncclEpGroupDestroy resolved in the loaded library.
func HasHandleDestroy ¶
func HasHandleDestroy() bool
HasHandleDestroy reports whether ncclEpHandleDestroy resolved in the loaded library.
func HasHandleMemSize ¶
func HasHandleMemSize() bool
HasHandleMemSize reports whether ncclEpHandleMemSize resolved in the loaded library.
func HasInitHandle ¶
func HasInitHandle() bool
HasInitHandle reports whether ncclEpInitHandle resolved in the loaded library.
func HasMaskClean ¶
func HasMaskClean() bool
HasMaskClean reports whether ncclEpMaskClean resolved in the loaded library.
func HasMaskQuery ¶
func HasMaskQuery() bool
HasMaskQuery reports whether ncclEpMaskQuery resolved in the loaded library.
func HasMaskUpdate ¶
func HasMaskUpdate() bool
HasMaskUpdate reports whether ncclEpMaskUpdate resolved in the loaded library.
func HasTensorAlloc ¶
func HasTensorAlloc() bool
HasTensorAlloc reports whether ncclEpTensorAlloc resolved in the loaded library.
func HasTensorDestroy ¶
func HasTensorDestroy() bool
HasTensorDestroy reports whether ncclEpTensorDestroy resolved in the loaded library.
func HasUpdateHandle ¶
func HasUpdateHandle() bool
HasUpdateHandle reports whether ncclEpUpdateHandle resolved in the loaded library.
func Load ¶
Load opens the shared library from path, or from the default search list when path is empty, and binds all symbols. Callers that need to direct loading should call Load before any other function; otherwise the first call loads from the default search list.
Load is idempotent: calling it again with the same path, or with an empty path, returns nil. Calling it with a different path after a successful load returns *LibraryConflictError rather than replacing the library. After a failed load, Load retries.
func Loaded ¶
func Loaded() bool
Loaded reports whether the library is currently loaded. It does not trigger a load.
func MaskClean ¶
MaskClean collectively cleans masked-rank communication state.
Reset masks and RDMA buffers so previously masked ranks can re-join. Collective: all surviving ranks must call simultaneously. Resets RDMA buffers via a cross-rank barrier and sets all masks to active. Does NOT reset the async error flag — call Group.ErrorClear separately. Note: this API is for re-admitting a delayed rank within the same communicator. Rank replacement requires a new communicator (e.g., ncclCommGrow) and a new EP group. Requires enable_mask=true in the group config.
- epGroup: in EP group with masking enabled
- stream: in CUDA stream
Wraps ncclEpMaskClean.
func MaskQuery ¶
MaskQuery copies the rank mask to a device array asynchronously.
Query the active-mask status of all ranks. Copies the mask buffer to a user-provided device tensor. Requires enable_mask=true in the group config.
- epGroup: in EP group with masking enabled
- maskStatus: out Device pointer to int[nRanks]. 1 = active, 0 = masked (failed)
- stream: in CUDA stream
Wraps ncclEpMaskQuery.
func MaskUpdate ¶
MaskUpdate copies a host rank mask to the device asynchronously.
Set the mask for all ranks at once. Requires enable_mask=true in the group config.
- epGroup: in EP group with masking enabled
- mask: in Host pointer to int[nRanks]. 1 = active, 0 = masked (failed)
- stream: in CUDA stream
Wraps ncclEpMaskUpdate.
func Path ¶
func Path() string
Path returns the path or name the loaded library was opened from, or the empty string if no library is loaded.
func TensorDestroy ¶
TensorDestroy releases a descriptor returned by TensorAlloc.
Release a descriptor previously returned by TensorAlloc.
- tensor: in Pointer returned by TensorAlloc. NULL is accepted
Wraps ncclEpTensorDestroy.
func UpdateHandle ¶
func UpdateHandle(handle Handle, topkIdx *Tensor, layoutInfo *LayoutInfo, stream driver.Stream) error
UpdateHandle updates a handle's routing metadata on the given stream.
Per-step collective: prepare the handle for the given top-k routing decisions. Must be called after Group.InitHandle and before Handle.Dispatch.
- handle: in Handle from Group.InitHandle
- topkIdx: in [num_tokens, top_k]; ncclInt32 or ncclInt64
- layoutInfo: in/out, optional Named local tensors (NULL = none provided). See LayoutInfo for the fields populated at handle time and the layouts each applies to. LL mode: must be NULL
- stream: in CUDA stream
Wraps ncclEpUpdateHandle.
Types ¶
type AllocConfig ¶
type AllocConfig struct {
// Optional C function pointer: cudaError_t alloc(void **ptr, size_t size, void *context). Zero selects the native default allocator.
AllocFn uintptr
// Optional C function pointer: cudaError_t free(void *ptr, void *context). Zero selects the native default deallocator.
FreeFn uintptr
// Caller-owned callback context; must remain valid for the group lifetime.
Context unsafe.Pointer
}
AllocConfig represents allocator callbacks returning CUDA runtime status codes, with a caller-owned context.
type BindFailure ¶
BindFailure names a symbol the loaded library exports but that could not be bound, and why.
func BindFailures ¶
func BindFailures() []BindFailure
BindFailures returns the symbols the loaded library exports that could not be bound, sorted by symbol name, or nil if every exported symbol bound. Calling one of these reports *SymbolError with the same Err.
A load that reports no error can still leave symbols unbound: the library is fine and the signatures are not representable here. Call this after Load to find that out at once rather than one call site at a time. It does not trigger a load, and returns nil if none has happened.
type CallError ¶
CallError is the error a failed call returns. It is NCCL's, so errors.As matches it whichever package made the call.
type CombineConfig ¶
type CombineConfig struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
SendOnly uint32
PassDirection PassDir
QuantRecipe CombQuant
}
CombineConfig represents combine options.
func NewCombineConfig ¶
func NewCombineConfig() CombineConfig
NewCombineConfig returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewCombineConfig()
fmt.Println(v.Size)
}
Output: 20
type CombineInputs ¶
type CombineInputs struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
Tokens *Tensor
TopkWeights *Tensor
Scales *Tensor
}
CombineInputs represents expert output tensors to combine.
func NewCombineInputs ¶
func NewCombineInputs() CombineInputs
NewCombineInputs returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewCombineInputs()
fmt.Println(v.Size)
}
Output: 32
type CombineOutputs ¶
type CombineOutputs struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
Tokens *Tensor
TopkWeights *Tensor
}
CombineOutputs represents preallocated output tensors for combine.
func NewCombineOutputs ¶
func NewCombineOutputs() CombineOutputs
NewCombineOutputs returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewCombineOutputs()
fmt.Println(v.Size)
}
Output: 24
type CompleteConfig ¶
type CompleteConfig struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
}
CompleteConfig represents staged-operation completion options.
func NewCompleteConfig ¶
func NewCompleteConfig() CompleteConfig
NewCompleteConfig returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewCompleteConfig()
fmt.Println(v.Size)
}
Output: 8
type DispatchConfig ¶
type DispatchConfig struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
SendOnly uint32
RoundScales uint32
PassDirection PassDir
QuantRecipe DispQuant
}
DispatchConfig represents dispatch options.
func NewDispatchConfig ¶
func NewDispatchConfig() DispatchConfig
NewDispatchConfig returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewDispatchConfig()
fmt.Println(v.Size)
}
Output: 24
type DispatchInputs ¶
type DispatchInputs struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
Tokens *Tensor
TopkWeights *Tensor
Scales *Tensor
}
DispatchInputs represents input tensors for dispatch.
func NewDispatchInputs ¶
func NewDispatchInputs() DispatchInputs
NewDispatchInputs returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewDispatchInputs()
fmt.Println(v.Size)
}
Output: 32
type DispatchOutputs ¶
type DispatchOutputs struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
Tokens *Tensor
TopkWeights *Tensor
Scales *Tensor
TopkIdx *Tensor
}
DispatchOutputs represents preallocated output tensors for dispatch.
func NewDispatchOutputs ¶
func NewDispatchOutputs() DispatchOutputs
NewDispatchOutputs returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewDispatchOutputs()
fmt.Println(v.Size)
}
Output: 40
type ExpertIdKind ¶
type ExpertIdKind int32
ExpertIdKind represents numbering convention for the recv_topk_idx output of dispatch.
Applies to layouts that populate recv_topk_idx (LL rank-major, HT flat). Selects whether per-slot expert ids are written in this rank's local numbering or in the global numbering used on the wire. AUTO (zero-init default): library picks the historical default, which today resolves to LOCAL. Existing callers that leave the field zero-initialized stay on whatever the library currently considers the default; the resolved value may change in a future release without an ABI break. Callers that need a stable contract should pin LOCAL or GLOBAL explicitly. LOCAL: expert id in [0, num_local_experts), i.e. global_id - rank * num_local_experts. Slots not routed to this rank are -1. GLOBAL: unmodified wire-format global expert id in [rank*num_local_experts, (rank+1)*num_local_experts) for the local experts on this rank. Slots not routed to this rank are -1. The zero-init AUTO default keeps source/binary backward compatibility for callers built against the pre-flag headers (the field reads as 0 and the library treats it as today's behavior). Downstream consumers that prefer the global id (e.g. fused MoE routers that want to skip the per-element +rank*num_local_experts fold-back) opt in by setting GLOBAL on the layout info struct.
const ( ExpertIdAuto ExpertIdKind = 0 ExpertIdLocal ExpertIdKind = 1 ExpertIdGlobal ExpertIdKind = 2 )
func (ExpertIdKind) String ¶
func (e ExpertIdKind) String() string
String returns the constant name, or a numeric representation for unknown values.
type Group ¶
type Group uintptr
Group is an opaque handle for ncclEpGroup_t.
func CreateGroup ¶
func CreateGroup(comm nccl.Comm, config *GroupConfig) (Group, error)
CreateGroup collectively creates an EP group from an NCCL communicator.
Create an EP group from an NCCL communicator This call is collective and must be invoked by all ranks in the group.
- comm: in Existing NCCL communicator
- config: in Pointer to EP configuration structure
Wraps ncclEpCreateGroup.
func NewGroup ¶
func NewGroup(comm nccl.Comm, config *GroupConfig) (Group, error)
NewGroup collectively creates an EP group from an NCCL communicator.
Create an EP group from an NCCL communicator This call is collective and must be invoked by all ranks in the group.
- comm: in Existing NCCL communicator
- config: in Pointer to EP configuration structure
Wraps ncclEpCreateGroup.
func (Group) AsyncError ¶
AsyncError reads the asynchronous error flag without synchronizing the GPU.
Poll for asynchronous errors (e.g., rank timeout). Lightweight host-side check — reads a pinned CPU flag, no GPU sync required. The flag is set by the kernel when a timeout masks a rank; clear it explicitly via Group.ErrorClear. Requires enable_mask=true in the group config.
Wraps ncclEpGetAsyncError.
func (*Group) Close ¶
Close destroys an EP group.
Destroy an EP group and release associated resources.
If g is zero, Close returns nil. Otherwise Close sets g to zero when the call succeeds and leaves it unchanged when it fails. Only g is zeroed: a copy of it still refers to the released object.
Wraps ncclEpGroupDestroy.
func (Group) CreateHandle ¶
func (g Group) CreateHandle(layout Layout, topkIdx *Tensor, layoutInfo *LayoutInfo, config *HandleConfig, stream driver.Stream) (Handle, error)
CreateHandle creates a handle and updates its routing metadata.
Create, initialize and bind an EP handle to a given layout and routing decisions. Must be called before the first Handle.Dispatch/Handle.Combine. Combines the functionality of Group.InitHandle and Handle.Update (see above)
- layout: in Receive buffer layout. Required; must not be LayoutUnset. HT supports FLAT / EXPERT_MAJOR; LL supports EXPERT_MAJOR / RANK_MAJOR
- topkIdx: in Tensor holding top-K expert indices (routing information)
- layoutInfo: in/out, optional Layout info (see LayoutInfo). NULL = none. See LayoutInfo for the fields populated at handle time and the layouts each applies to. LL mode: must be NULL
- config: in Handle configuration (see HandleConfig). NULL = defaults
- stream: in CUDA stream
Wraps ncclEpCreateHandle.
func (Group) ErrorClear ¶
ErrorClear clears the group's asynchronous error flag.
Clear the async error flag. Lightweight host-side reset — writes zero to the pinned CPU flag. Use after detecting an error (via Group.AsyncError) to re-arm the flag for detecting new failures. Should be called after Group.MaskClean (full recovery) or standalone when surviving ranks continue in degraded mode. Requires enable_mask=true in the group config.
Wraps ncclEpErrorClear.
func (Group) InitHandle ¶
func (g Group) InitHandle(layout Layout, config *HandleConfig, numTopk int32, handleMem *Tensor) (Handle, error)
InitHandle initializes a handle for an explicit layout.
Create and initialize EP handle. Must be called before the first Handle.Dispatch/Handle.Combine.
NOTE: the impact of auto-sizing of internal buffers (GroupConfig.rdma_buffer_size == Auto): * collective behaviour: This function MAY be collective and must be called by all ranks in the group in the same order. * memory allocation/re-allocation: This function may perform allocation/re-allocation if the new layout/topK requires more memory than the current allocation. All ranks must call this function in lockstep with the same (layout, numTopk). No active communication is allowed between the ranks during this operation. * CUDA graph invalidation: This function must not be included in CUDA graph captures.
Use an explicit, sufficiently large rdma_buffer_size if you need to avoid collective allocation/re-allocation, mid-stream reallocation, or graph invalidation. Alternatively, to avoid CUDA graph invalidation, all Handles must be created before the beginning of the CUDA graph capture.
handleMem == NULL: NCCL EP allocates via alloc_fn; handle owns the memory. handleMem != NULL: wraps caller-owned 1D ncclUint8 tensor (>= Group.MemSize); handle owns no memory; Handle.Close frees only the struct.
- layout: in Receive buffer layout. Required; must not be LayoutUnset
- config: in Handle configuration (see HandleConfig). NULL = defaults
- numTopk: in Required for LL (> 0); pass -1 for HT
- handleMem: in NULL = internal alloc; non-NULL = caller-owned device buffer
Wraps ncclEpInitHandle.
func (Group) MaskClean ¶
MaskClean collectively cleans masked-rank communication state.
Reset masks and RDMA buffers so previously masked ranks can re-join. Collective: all surviving ranks must call simultaneously. Resets RDMA buffers via a cross-rank barrier and sets all masks to active. Does NOT reset the async error flag — call Group.ErrorClear separately. Note: this API is for re-admitting a delayed rank within the same communicator. Rank replacement requires a new communicator (e.g., ncclCommGrow) and a new EP group. Requires enable_mask=true in the group config.
- stream: in CUDA stream
Wraps ncclEpMaskClean.
func (Group) MaskQuery ¶
MaskQuery copies the rank mask to a device array asynchronously.
Query the active-mask status of all ranks. Copies the mask buffer to a user-provided device tensor. Requires enable_mask=true in the group config.
- maskStatus: out Device pointer to int[nRanks]. 1 = active, 0 = masked (failed)
- stream: in CUDA stream
Wraps ncclEpMaskQuery.
func (Group) MaskUpdate ¶
MaskUpdate copies a host rank mask to the device asynchronously.
Set the mask for all ranks at once. Requires enable_mask=true in the group config.
- mask: in Host pointer to int[nRanks]. 1 = active, 0 = masked (failed)
- stream: in CUDA stream
Wraps ncclEpMaskUpdate.
func (Group) MemSize ¶
MemSize returns the required caller-owned handle storage size in bytes.
Query the device bytes required for a handle's routing buffers.
- layout: in Receive buffer layout. Required; must not be LayoutUnset
- config: in Handle configuration (see HandleConfig). NULL = defaults
- numTopk: in Required for LL (> 0); optional for HT
Wraps ncclEpHandleMemSize.
type GroupConfig ¶
type GroupConfig struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
Version uint32
Algorithm Algorithm
NumExperts uint32
MaxDispatchTokensPerRank uint32
MaxRecvTokensPerRank uint32
MaxTokenBytes uint32
RdmaBufferSize uint
NumQpPerRank uint32
NumChannels uint32
MaxNumSms uint32
Alloc AllocConfig
EnableMask uint32
TimeoutNs uint64
ZeroCopy ZeroCopyMode
OverflowPolicy OverflowPolicy
NumTopk uint32
PaddingV2 [4]uint8
}
GroupConfig represents EP group dimensions, algorithm selection, and allocator options.
func NewGroupConfig ¶
func NewGroupConfig() GroupConfig
NewGroupConfig returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewGroupConfig()
fmt.Println(v.Size)
}
Output: 112
type Handle ¶
type Handle uintptr
Handle is an opaque handle for ncclEpHandle_t.
func CreateHandle ¶
func CreateHandle(epGroup Group, layout Layout, topkIdx *Tensor, layoutInfo *LayoutInfo, config *HandleConfig, stream driver.Stream) (Handle, error)
CreateHandle creates a handle and updates its routing metadata.
Create, initialize and bind an EP handle to a given layout and routing decisions. Must be called before the first Handle.Dispatch/Handle.Combine. Combines the functionality of Group.InitHandle and Handle.Update (see above)
- epGroup: in A valid EP group
- layout: in Receive buffer layout. Required; must not be LayoutUnset. HT supports FLAT / EXPERT_MAJOR; LL supports EXPERT_MAJOR / RANK_MAJOR
- topkIdx: in Tensor holding top-K expert indices (routing information)
- layoutInfo: in/out, optional Layout info (see LayoutInfo). NULL = none. See LayoutInfo for the fields populated at handle time and the layouts each applies to. LL mode: must be NULL
- config: in Handle configuration (see HandleConfig). NULL = defaults
- stream: in CUDA stream
Wraps ncclEpCreateHandle.
func InitHandle ¶
func InitHandle(epGroup Group, layout Layout, config *HandleConfig, numTopk int32, handleMem *Tensor) (Handle, error)
InitHandle initializes a handle for an explicit layout.
Create and initialize EP handle. Must be called before the first Handle.Dispatch/Handle.Combine.
NOTE: the impact of auto-sizing of internal buffers (GroupConfig.rdma_buffer_size == Auto): * collective behaviour: This function MAY be collective and must be called by all ranks in the group in the same order. * memory allocation/re-allocation: This function may perform allocation/re-allocation if the new layout/topK requires more memory than the current allocation. All ranks must call this function in lockstep with the same (layout, numTopk). No active communication is allowed between the ranks during this operation. * CUDA graph invalidation: This function must not be included in CUDA graph captures.
Use an explicit, sufficiently large rdma_buffer_size if you need to avoid collective allocation/re-allocation, mid-stream reallocation, or graph invalidation. Alternatively, to avoid CUDA graph invalidation, all Handles must be created before the beginning of the CUDA graph capture.
handleMem == NULL: NCCL EP allocates via alloc_fn; handle owns the memory. handleMem != NULL: wraps caller-owned 1D ncclUint8 tensor (>= Group.MemSize); handle owns no memory; Handle.Close frees only the struct.
- epGroup: in A valid EP group
- layout: in Receive buffer layout. Required; must not be LayoutUnset
- config: in Handle configuration (see HandleConfig). NULL = defaults
- numTopk: in Required for LL (> 0); pass -1 for HT
- handleMem: in NULL = internal alloc; non-NULL = caller-owned device buffer
Wraps ncclEpInitHandle.
func (*Handle) Close ¶
Close destroys a handle without freeing caller-owned storage.
Destroy an EP handle and release all associated resources.
If h is zero, Close returns nil. Otherwise Close sets h to zero when the call succeeds and leaves it unchanged when it fails. Only h is zeroed: a copy of it still refers to the released object.
Wraps ncclEpHandleDestroy.
func (Handle) Combine ¶
func (h Handle) Combine(inputs *CombineInputs, outputs *CombineOutputs, config *CombineConfig, stream driver.Stream) error
Combine combines expert outputs in the original token order.
Perform EP combine * Gathers outputs from experts and returns them to their source in original token order. * This call is collective and must be invoked by all ranks in the group.
- inputs: in Named input tensors (see CombineInputs). The shapes of the tensors are identical to the shapes of the respective output tensors of the corresponding `[Handle.Dispatch]` call. The inputs->tokens tensor is required. For the backward pass in HT mode, the inputs->topk_weights must also be provided
- outputs: in,out Named preallocated output tensors (see CombineOutputs). outputs->tokens [num_tokens, hidden] is required; returns tokens in the original order. outputs->topk_weights: LL expert-major: per-token routing weights applied on the combine receive side. HT backward: must also be provided; receives combined routing weights
- config: in Combine configuration (see CombineConfig). NULL = defaults
- stream: in CUDA stream. If `[Handle.Combine]` is called on a different stream than the stream used in `[Group.CreateHandle]`, it is the responsibility of the user to synchronize between streams to ensure correctness
Wraps ncclEpCombine.
func (Handle) Complete ¶
func (h Handle) Complete(config *CompleteConfig, stream driver.Stream) error
Complete completes a staged EP operation on the given stream.
Continues a staged EP operation to completion. * This should be called after a prior `[Handle.Dispatch]` or `[Handle.Combine]` call with `send_only` flag set.
- config: in Completion configuration (see CompleteConfig). NULL = defaults
- stream: in CUDA stream Notes: - If `[Handle.Complete]` is called on a different stream than the operation initiation call (i.e., `[Handle.Dispatch]` or `[Handle.Combine]`), it is the responsibility of the user to synchronize between streams to ensure correctness. - Only LL mode is supported
Wraps ncclEpComplete.
func (Handle) Dispatch ¶
func (h Handle) Dispatch(inputs *DispatchInputs, outputs *DispatchOutputs, layoutInfo *LayoutInfo, config *DispatchConfig, stream driver.Stream) error
Dispatch dispatches tokens to experts using the handle's routing metadata.
Perform EP dispatch * Sends tokens and metadata to the experts according to routing decisions. * This call is collective and must be invoked by all ranks in the group.
- inputs: in Named input tensors (see DispatchInputs). inputs->tokens is required for all modes and layouts. For LL mode (rank-major layout) and HT mode (all layouts, forward pass), inputs->topk_weights must be provided
- outputs: in,out Named preallocated output tensors (see DispatchOutputs). outputs->tokens is required; other fields depend on the layout and pass direction. HT mode: The sizing of the output tensors relies on `num_recv_slots`. Static allocation: `num_recv_slots` is `max_recv_tokens_per_rank` (see GroupConfig.max_recv_tokens_per_rank). Required for CUDA Graph capturing. Query-then-allocate: `num_recv_slots` is the actual number of tokens this rank will receive (padded for Expert-major layout). Obtain the count from the LayoutInfo.recv_total_counter scalar tensor supplied to `[Group.CreateHandle]` / `[Handle.Update]`; the caller copies it device-to-host and synchronizes before allocating. The counter serves both layouts: for expert-major it reports the padded total. The count is readable in any mode; to size the outputs to it rather than to the worst case, the group must also be created with max_recv_tokens_per_rank = Auto. The outputs->tokens tensor shape is [num_recv_slots, hidden]. For the forward pass, in addition the following tensor[s] are required: * Expert-major layout: outputs->topk_weights tensor [num_recv_slots] (1D, one weight per slot) * Flat layout: outputs->topk_weights tensor [num_recv_slots, num_topk] outputs->topk_idx tensor [num_recv_slots, num_topk] LL mode: The set and shapes of the output tokens vary depending on the layout. * Expert-major layout: requires only outputs->tokens [local_experts, num_ranks * max_dispatch_tokens_per_rank, hidden] The actual number of tokens received by expert `e` is obtained via layoutInfo->expert_counters[`e`] (see below). * Rank-major layout: * outputs->tokens [num_ranks, max_dispatch_tokens_per_rank, hidden] * outputs->topk_weights [num_ranks, max_dispatch_tokens_per_rank, num_topk] * outputs->topk_idx [num_ranks, max_dispatch_tokens_per_rank, num_topk] The actual number of tokens received by rank `r` is obtained via layoutInfo->src_rank_counters[`r`] (see below)
- layoutInfo: in,out Named local tensors for layout-specific counters (see LayoutInfo). * For HT mode should be NULL, the counter information is available through Handle.Update. * For LL mode, layout-specific counter tensors must be provided (see LayoutInfo doc). * Expert-major layout: expert_counters tensor is required. * Rank-major layout: src_rank_counters is optional; when provided, it receives one token count per source rank
- config: in Dispatch configuration (see DispatchConfig). NULL = defaults
- stream: in CUDA stream. If `[Handle.Dispatch]` is called on a different stream than the stream used in `[Group.CreateHandle]`, it is the responsibility of the user to synchronize between streams to ensure correctness
Wraps ncclEpDispatch.
func (Handle) Update ¶
Update updates a handle's routing metadata on the given stream.
Per-step collective: prepare the handle for the given top-k routing decisions. Must be called after Group.InitHandle and before Handle.Dispatch.
- topkIdx: in [num_tokens, top_k]; ncclInt32 or ncclInt64
- layoutInfo: in/out, optional Named local tensors (NULL = none provided). See LayoutInfo for the fields populated at handle time and the layouts each applies to. LL mode: must be NULL
- stream: in CUDA stream
Wraps ncclEpUpdateHandle.
type HandleConfig ¶
type HandleConfig struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
DispatchOutputPerExpertAlignment uint
}
HandleConfig represents handle layout options.
func NewHandleConfig ¶
func NewHandleConfig() HandleConfig
NewHandleConfig returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewHandleConfig()
fmt.Println(v.Size)
}
Output: 16
type Layout ¶
type Layout int32
Layout represents dispatch output layout.
Controls the shape and contents of the user-visible dispatch output tensors (tokens, topk_weights, topk_idx) and their expected shape in Combine. Each layout is supported by a subset of algorithms: HT: LayoutFlat, LayoutExpertMajor. LL: LayoutExpertMajor, LayoutRankMajor.
const ( LayoutUnset Layout = 0 // Sentinel for "layout not set" (zero-init default). Callers must override this with one of the layout values below before passing the config to [Group.InitHandle] / [Group.MemSize]; the library does not auto-resolve based on algorithm. Leaving the field at [LayoutUnset] is a programmer error and trips an assertion at handle-init time. LayoutExpertMajor Layout = 1 LayoutRankMajor Layout = 2 LayoutFlat Layout = 3 )
type LayoutInfo ¶
type LayoutInfo struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
ExpertCounters *Tensor
SrcRankCounters *Tensor
ExpertOffsets *Tensor
RecvTotalCounter *Tensor
RecvTopkIdxKind ExpertIdKind
PaddingV2 [4]uint8
}
LayoutInfo represents preallocated routing metadata tensor descriptors.
func NewLayoutInfo ¶
func NewLayoutInfo() LayoutInfo
NewLayoutInfo returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewLayoutInfo()
fmt.Println(v.Size)
}
Output: 48
type LibraryAttempt ¶
LibraryAttempt records one failed attempt to open the shared library.
type LibraryConflictError ¶
type LibraryConflictError struct {
Loaded string
Requested string
// Implicit reports that the loaded library was opened lazily and no
// successful Load has since acknowledged it. A
// caller that sees this called some
// other function first, and that call took the default search list.
Implicit bool
}
LibraryConflictError reports a Load call naming a different library than the one already loaded. Only one library is loaded per process.
func (*LibraryConflictError) Error ¶
func (e *LibraryConflictError) Error() string
Error reports the conflicting library paths, and whether the library that is already loaded got there without a Load call.
type LibraryError ¶
type LibraryError struct {
Library string
Env string
Path string
Attempts []LibraryAttempt
Hint string
}
LibraryError reports that libnccl_ep could not be opened. Attempts lists every name tried in order. Path is set when an explicit path, from Load or NCCL_EP_LIB_PATH, was requested and failed. Hint reports pkg-config discovery results and query failures, when discovery ran.
func (*LibraryError) Error ¶
func (e *LibraryError) Error() string
Error describes the library load attempts and their errors.
func (*LibraryError) Unwrap ¶
func (e *LibraryError) Unwrap() []error
Unwrap returns the error from each attempt.
type OverflowPolicy ¶
type OverflowPolicy int32
OverflowPolicy represents ncclEpOverflowPolicy_t.
const ( OverflowAuto OverflowPolicy = 0 OverflowTrap OverflowPolicy = 1 OverflowDrop OverflowPolicy = 2 )
func (OverflowPolicy) String ¶
func (e OverflowPolicy) String() string
String returns the constant name, or a numeric representation for unknown values.
type PassDir ¶
type PassDir int32
PassDir represents training pass direction for Handle.Dispatch / Handle.Combine.
Selects which side of the routing the call is participating in. FWD is the zero-init default so callers that don't set the field get forward-pass semantics. FWD dispatch (HT): caller provides input topk_weights; routing is live. BWD dispatch (HT): no input topk_weights; reuses cached routing state. FWD combine (HT): no input topk_weights; tokens only. BWD combine (HT): caller provides input topk_weights and receives combined topk_weights gradients alongside tokens. LL mode does not currently distinguish FWD/BWD and ignores this field.
type SymbolError ¶
SymbolError reports that a symbol is not callable.
Err distinguishes the two ways that happens. A nil Err means the loaded library does not export the symbol, which is what an installation older than the symbol looks like. A non-nil Err means the library does export it and the binding itself failed; the library is not at fault.
func (*SymbolError) Error ¶
func (e *SymbolError) Error() string
Error reports the uncallable library symbol and, when the symbol was present but could not be bound, why.
func (*SymbolError) Unwrap ¶
func (e *SymbolError) Unwrap() error
Unwrap returns the reason the symbol could not be bound, or nil when the loaded library does not export it.
type Tensor ¶
type Tensor struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
Ndim uint32
Datatype nccl.DataType
Data nccl.Buffer
WinHdl nccl.Window
WinOffset uint64
Sizes *uint
}
Tensor represents an EP tensor descriptor with caller-owned device storage.
func NewTensor ¶
func NewTensor() Tensor
NewTensor returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewTensor()
fmt.Println(v.Size)
}
Output: 48
func TensorAlloc ¶
func TensorAlloc(ndim uint32, datatype nccl.DataType, sizes *uint, config *TensorAllocConfig) (*Tensor, error)
TensorAlloc allocates a tensor descriptor and copies its dimensions.
Allocate a tensor descriptor sufficient to represent the requested shape.
- ndim: in Number of dimensions (> 0)
- datatype: in Element type
- sizes: in Array of `ndim` dimension sizes
- config: in Optional allocation configuration. NULL = defaults
Wraps ncclEpTensorAlloc.
type TensorAllocConfig ¶
type TensorAllocConfig struct {
// ABI byte size; set by the descriptor's New function.
Size uint32
// ABI guard; set by the descriptor's New function.
Magic uint32
}
TensorAllocConfig represents tensor allocation options.
func NewTensorAllocConfig ¶
func NewTensorAllocConfig() TensorAllocConfig
NewTensorAllocConfig returns a descriptor initialized with the public C initializer. Set workload fields before passing it to the library.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/ncclep"
)
func main() {
v := ncclep.NewTensorAllocConfig()
fmt.Println(v.Size)
}
Output: 8
type ZeroCopyMode ¶
type ZeroCopyMode int32
ZeroCopyMode represents ncclEpZeroCopyMode_t.
const ( ZeroCopyAuto ZeroCopyMode = 0 ZeroCopyOff ZeroCopyMode = 1 ZeroCopyOn ZeroCopyMode = 2 )
func (ZeroCopyMode) String ¶
func (e ZeroCopyMode) String() string
String returns the constant name, or a numeric representation for unknown values.