Record Class ParallelConfig

java.lang.Object
java.lang.Record
smile.llm.parallel.ParallelConfig
Record Components:
tpSize - tensor-parallel size (must divide attention / FFN widths).
ppSize - pipeline-parallel size (must be 1 until phase 2).
dpSize - data-parallel size (must be 1 in phase 1).
devices - CUDA device indices for local TP ranks (length == tpSize).

public record ParallelConfig(int tpSize, int ppSize, int dpSize, byte[] devices) extends Record
Process-mesh configuration for tensor / pipeline / data parallelism.

worldSize == tpSize * ppSize * dpSize. Phase 1 uses ppSize=1 and dpSize=1; pipeline axes are reserved for multi-node PP.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ParallelConfig(int tpSize, int ppSize, int dpSize, byte[] devices)
    Validates mesh sizes and defensively copies devices.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the value of the devices record component.
    int
    Returns the value of the dpSize record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns whether tensor parallelism is enabled.
    int
    Returns the value of the ppSize record component.
    single(byte device)
    Single-device (no parallelism).
    tensorParallel(byte... devices)
    Tensor-parallel group on the given CUDA devices.
    final String
    Returns a string representation of this record class.
    int
    Returns the value of the tpSize record component.
    int
    Returns tpSize * ppSize * dpSize.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ParallelConfig

      public ParallelConfig(int tpSize, int ppSize, int dpSize, byte[] devices)
      Validates mesh sizes and defensively copies devices.
  • Method Details

    • single

      public static ParallelConfig single(byte device)
      Single-device (no parallelism).
      Parameters:
      device - CUDA device index.
      Returns:
      config with tpSize=1.
    • tensorParallel

      public static ParallelConfig tensorParallel(byte... devices)
      Tensor-parallel group on the given CUDA devices.
      Parameters:
      devices - CUDA device indices (length becomes tpSize).
      Returns:
      tensor-parallel config.
    • worldSize

      public int worldSize()
      Returns tpSize * ppSize * dpSize.
      Returns:
      world size.
    • isTensorParallel

      public boolean isTensorParallel()
      Returns whether tensor parallelism is enabled.
      Returns:
      true if tpSize > 1.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • tpSize

      public int tpSize()
      Returns the value of the tpSize record component.
      Returns:
      the value of the tpSize record component
    • ppSize

      public int ppSize()
      Returns the value of the ppSize record component.
      Returns:
      the value of the ppSize record component
    • dpSize

      public int dpSize()
      Returns the value of the dpSize record component.
      Returns:
      the value of the dpSize record component
    • devices

      public byte[] devices()
      Returns the value of the devices record component.
      Returns:
      the value of the devices record component