# This is the default configuration of TransferQueue. Users may modify the default value
# and use transfer_queue.init(conf) to overwrite the config entries.

# Prometheus metrics exporter.
metrics:
  enabled: true
  # HTTP port for /metrics endpoint (0 = auto-assign free port)
  port: 0

controller:
  # User-defined sampler. User can pass sampler instance to overwrite this string config.
  sampler: SequentialSampler
  # Whether return an empty BatchMeta to prevent request blocking when no enough data is available
  polling_mode: False
  # ZMQ Server IP & Ports (automatically generated during init)
  zmq_info: null


backend:
  # Pluggable storage/transport backend of TransferQueue. Choose from:
  # SimpleStorage, Yuanrong, MooncakeStore, ...
  storage_backend: SimpleStorage

  # SimpleStorage: ZMQ-based in-memory storage for out-of-the-box usage
  SimpleStorage:
    # Maximum number of experience samples to hold across all storage units
    total_storage_size: 100000
    # Number of distributed storage units.
    # Recommended: >= 2 x number of nodes for load balancing.
    num_data_storage_units: 16
    # ZMQ Server IP & Ports (automatically generated during init)
    zmq_info: null

  # MooncakeStore: high-performance KV-based hierarchical storage
  # that supports RDMA transport between GPU and DRAM.
  MooncakeStore:
    # Whether TransferQueue should automatically start the Mooncake metadata server.
    # WARNING: When set to `true`, TQ will attempt to terminate any existing mooncake_master process.
    auto_init: true
    # Address of the metadata coordination server.
    # Set to "P2PHANDSHAKE" to use peer-to-peer handshake mode (recommended for multi-NIC environments).
    metadata_server: localhost:50050
    # Address of the Mooncake master server.
    master_server_address: localhost:50051
    # Local host address visible to the Mooncake cluster.
    # Set to "" to auto-detect using Ray's node IP.
    local_hostname: ""
    # Transport protocol. Choose from: tcp, rdma.
    protocol: rdma
    # Global memory segment size in bytes **per client** for mounting (default: 4GB)
    global_segment_size: 86294967296
    # Local buffer size in bytes **per client** (default: 1GB)
    local_buffer_size: 86294967296
    # Network device name.
    # Set to "" to let Mooncake auto-select available devices.
    device_name: ""
    # Whether to hard-pin objects in memory. Hard-pinned objects are never evicted.
    # Set to null (default) for auto-management: hard_pin is disabled when offload is enabled,
    # and enabled otherwise. Set to true/false to explicitly override.
    hard_pin: null

    # SSD Offload configuration.
    # When enabled, TQ will start a standalone mooncake_client process that offloads
    # data from DRAM to NVMe SSD when memory usage exceeds the high watermark.
    # This is essential for environments where total CPU DRAM < GPU HBM.
    #
    # Architecture note:
    #   The offload client is a **single-node centralized SSD storage pool** that runs
    #   on the first node where tq.init() is called. It registers itself with mooncake_master
    #   and serves the entire cluster — when eviction is triggered, the master moves data
    #   from ANY node's memory to this offload client via TCP/RDMA.
    #   Ensure that `local_hostname` (above) is set to a cluster-reachable address so that
    #   all nodes can transfer data to the offload client.
    #
    # TODO: Support multi-node distributed offload (one client per node) for better
    #       scalability in large clusters.
    offload:
      # Master switch for SSD offload.
      enabled: false
      # Path to the SSD directory for offloaded data.
      file_storage_path: /tmp/mooncake_offload
      # Local buffer size in bytes for the offload client (default: 2GB).
      local_buffer_size_bytes: 2147483648
      # Whether to use io_uring for async I/O (requires kernel >= 5.1 and liburing).
      use_uring: false
      # Heartbeat interval in seconds for the offload client.
      # Note: This is paired with mooncake_master's -client_ttl (default: 30s).
      # The client sends heartbeats at this interval; the master considers the client
      # dead if no heartbeat is received within client_ttl. Ensure:
      #   heartbeat_interval_seconds << client_ttl (currently 2s << 30s = tolerates ~15 missed beats)
      heartbeat_interval_seconds: 2
      # Port for the standalone mooncake_client process.
      client_port: 42052
      # Eviction high watermark ratio (0.0-1.0). Eviction starts when memory usage exceeds this ratio.
      eviction_high_watermark_ratio: 0.9
      # Fraction of memory to free during each eviction cycle.
      eviction_ratio: 0.1

  # For Yuanrong:
  Yuanrong:
    # Whether to let TQ automatically init yuanrong
    auto_init: True
    # Datasystem worker port
    worker_port: 31501
    # Metastore service port
    metastore_port: 2379
    # If enable npu transport
    enable_yr_npu_transport: true
    # Additional config for yuanrong worker.
    # Recommended options for NPU environments:
    #   --remote_h2d_device_ids       Enable RH2D for efficient cross-node data transfer. Specify NPU device IDs (comma-separated).
    #   --enable_huge_tlb             Enable huge page memory to improve performance. Required for >21GB shared memory on 910B.
    # Example: "--shared_memory_size_mb 16384 --remote_h2d_device_ids 0,1,2,3 --enable_huge_tlb true"
    worker_args: "--shared_memory_size_mb 65536 --remote_h2d_device_ids 0 --enable_huge_tlb true"

  # For RayStore:
  RayStore: