# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
apiVersion: nvidia.com/v1alpha1
kind: DynamoGraphDeployment
metadata:
  name: gpt-oss-agg
spec:
  backendFramework: trtllm
  pvcs:
    - name: model-cache-oss-gpt120b
      create: false
  services:
    Frontend:
      componentType: frontend
      dynamoNamespace: gpt-oss-agg
      extraPodSpec:
        affinity:
          podAntiAffinity:
            requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                - key: nvidia.com/dynamo-graph-deployment-name
                  operator: In
                  values:
                  - gpt-oss-agg-frontend
              topologyKey: kubernetes.io/hostname
        mainContainer:
          args:
          - python3 -m dynamo.frontend --router-mode round-robin --http-port 8000
          command:
          - /bin/sh
          - -c
          image: my-registry/trtllm-runtime:my-tag
      pvc:
        create: false
        mountPoint: /model-store
        name: model-cache
      replicas: 1
    TrtllmWorker:
      componentType: main
      dynamoNamespace: gpt-oss-agg
      envFromSecret: hf-token-secret
      volumeMounts:
        - name: model-cache-oss-gpt120b
          mountPoint: /root/.cache/huggingface
      sharedMemory:
        size: 80Gi
      extraPodSpec:
        affinity:
          nodeAffinity:
            requiredDuringSchedulingIgnoredDuringExecution:
              nodeSelectorTerms:
              - matchExpressions:
                - key: nvidia.com/gpu.present
                  operator: In
                  values:
                  - "true"
        mainContainer:
          args:
          - |
            python3 -m dynamo.trtllm \
              --model-path "${MODEL_PATH}" \
              --served-model-name "openai/gpt-oss-120b" \
              --extra-engine-args "${ENGINE_ARGS}" \
              --tensor-parallel-size 4 \
              --expert-parallel-size 4 \
              --max-batch-size 800 \
              --free-gpu-memory-fraction 0.9
          command:
          - /bin/sh
          - -c
          image: my-registry/trtllm-runtime:my-tag
          env:
          - name: TRTLLM_ENABLE_PDL
            value: "1"
          - name: TRT_LLM_DISABLE_LOAD_WEIGHTS_IN_PARALLEL
            value: "True"
          - name: SERVED_MODEL_NAME
            value: "openai/gpt-oss-120b"
          - name: ENGINE_ARGS
            value: "/opt/dynamo/configs/config.yaml"
          - name: MODEL_PATH
            value: "/model-store/hub/models--openai--gpt-oss-120b/snapshots/b5c939de8f754692c1647ca79fbf85e8c1e70f8a"
          volumeMounts:
          - mountPath: /opt/dynamo/configs
            name: llm-config
            readOnly: true
          workingDir: /workspace/components/backends/trtllm
        volumes:
        - configMap:
            name: llm-config
          name: llm-config
      pvc:
        create: false
        mountPoint: /model-store
        name: model-cache
      replicas: 1
      resources:
        limits:
          gpu: "4"
        requests:
          gpu: "4"