# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

apiVersion: nvidia.com/v1alpha1
kind: DynamoGraphDeployment
metadata:
  name: agg-round-robin-dsv32-nvfp4
spec:
  services:
    Frontend:
      componentType: frontend
      extraPodSpec:
        containers: null
        mainContainer:
          command:
            - python3
          args:
            - -m
            - dynamo.frontend
            - --router-mode
            - round-robin
            - --router-reset-states
            - --request-plane
            - nats
          env:
            - name: POD_UID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.uid
          image: nvcr.io/nvidia/ai-dynamo/tensorrtllm-runtime:1.0.0
          name: ""
          resources: {}
        # tolerations:     # uncomment to populate any tolerations for the gpu nodes
      replicas: 1
    agg:
      componentType: worker
      envFromSecret: hf-token-secret
      extraPodSpec:
        containers: null
        mainContainer:
          args:
            - --model-path
            - nvidia/DeepSeek-V3.2-NVFP4
            - --served-model-name
            - nvidia/DeepSeek-V3.2-NVFP4
            - --extra-engine-args
            - /config/aggregated.yaml
            - --publish-events-and-metrics
            - --request-plane
            - nats
            - --kv-block-size
            - "64"
          command:
            - python3
            - -m
            - dynamo.trtllm
          env:
            - name: POD_UID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.uid
            - name: HF_HOME
              value: /model-cache
            - name: TRITON_CACHE_DIR
              value: /model-cache/.triton-cache
            - name: NCCL_DEBUG
              value: INFO
            - name: NCCL_MNNVL_ENABLE
              value: "1"
            - name: NCCL_CUMEM_ENABLE
              value: "1"
            - name: NCCL_NVLS_ENABLE
              value: "1"
            - name: NVIDIA_GDRCOPY
              value: "1"
            - name: UCX_CUDA_IPC_ENABLE_MNNVL
              value: "1"
            - name: NCCL_SOCKET_IFNAME
              value: eth0
            - name: GLOO_SOCKET_IFNAME
              value: eth0
            - name: NCCL_STORE_TIMEOUT
              value: "7200"
            - name: TRTLLM_MOE_ENABLE_ALLTOALL_WITHOUT_ALLGATHER
              value: "1"
            - name: TRTLLM_ENABLE_PDL
              value: "1"
            - name: TRTLLM_SERVER_DISABLE_GC
              value: "1"
            - name: TRTLLM_WORKER_DISABLE_GC
              value: "1"
            - name: NCCL_GRAPH_MIXING_SUPPORT
              value: "0"
            - name: TRTLLM_FORCE_COMM_METHOD
              value: NVLINK_TWO_SIDED
            - name: ENABLE_CONFIGURABLE_MOE
              value: "1"
            - name: TLLM_LOG_LEVEL
              value: "INFO"
          image: nvcr.io/nvidia/ai-dynamo/tensorrtllm-runtime:1.0.0
          name: ""
          resources: {}
          securityContext:
            runAsUser: 0
          startupProbe:
            failureThreshold: 60
            httpGet:
              path: /live
              port: 9090
            periodSeconds: 60
            timeoutSeconds: 5
          volumeMounts:
            - mountPath: /model-cache
              name: model-cache
            - mountPath: /config
              name: trtllm-config
              readOnly: true
          workingDir: /workspace/
        nodeSelector:
          kubernetes.io/arch: arm64
        #tolerations: :     # uncomment to populate any tolerations for the gpu nodes
        resourceClaims:
          - name: compute-domain-channel
            resourceClaimTemplateName: your-compute-domain-channel
        volumes:
          - name: model-cache
            persistentVolumeClaim:
              claimName: model-cache
          - name: trtllm-config
            configMap:
              name: dsv32-trtllm-config
      multinode:
        nodeCount: 2
      replicas: 4
      resources:
        limits:
          gpu: "4"
        claims:
          - name: compute-domain-channel
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: dsv32-trtllm-config
data:
  aggregated.yaml: |
    allreduce_strategy: MNNVL
    cache_transceiver_config:
      backend: UCX
      max_tokens_in_buffer: 120000
    max_num_tokens: 8192
    enable_chunked_prefill: true
    disable_overlap_scheduler: true
    cuda_graph_config:
      max_batch_size: 8
      enable_padding: true
    enable_attention_dp: true
    kv_cache_config:
      dtype: fp8
      enable_block_reuse: false
      free_gpu_memory_fraction: 0.9
      tokens_per_block: 64
    max_batch_size: 8
    max_seq_len: 121000
    moe_config:
      backend: TRTLLM
      use_low_precision_moe_combine: true
    moe_expert_parallel_size: 8
    num_postprocess_workers: 8
    print_iter_log: true
    stream_interval: 10
    tensor_parallel_size: 8