Operator

CUDAExperiment is the user-facing custom resource. Users describe the workload container, command, GPU request, runtime class, and whether KRATOS should profile the workload before normal execution.

Reconciliation Flow

When spec.profilingEnabled is false:

  1. Ensure execution Job <experiment>-execution exists.
  2. Record ExecutionJobCreated condition in CUDAExperiment.status.

When spec.profilingEnabled is true:

  1. Check for existing WorkloadProfile named <experiment>-profile.
  2. If missing, ensure profiling Job <experiment>-profiling exists and set condition ProfilingPending / ProfilingRunning.
  3. When the profiling Job completes, read <experiment>-profile-summary ConfigMap generated by the runner.
  4. Create/update <experiment>-profile WorkloadProfile and write parsed metrics into status.
  5. Set ProfilingCompleted condition.
  6. The controller then creates execution Job <experiment>-execution and records ExecutionJobCreated condition.

Because the controller watches owned Job objects (.Owns(&batchv1.Job{})), completion of the profiling Job automatically triggers reconciliation to publish the WorkloadProfile and launch the execution Job.

Profiling Job Structure

The profiling Job isolates the workload image from Nsight Compute:

  • stage-workload: An initContainer that uses spec.image, verifies spec.command[0], copies the CUDA executable into a shared emptyDir volume, and exits.
  • profiling-runner: Uses kratos-nsight-compute-poc:latest by default (or image defined by KRATOS_NSIGHT_COMPUTE_IMAGE), requests nvidia.com/gpu, runs the staged executable under ncu, parses hardware metrics, and publishes summary ConfigMap <experiment>-profile-summary.

For example:

spec:
  image: nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0
  command:
    - /cuda-samples/vectorAdd
  runtimeClassName: nvidia
  gpuRequired: 1
  replicas: 1
  profilingEnabled: true

Outputs

Profiling generates:

  • Job: <experiment>-profiling
  • ConfigMap: <experiment>-profile-summary
  • WorkloadProfile: <experiment>-profile
  • Job: <experiment>-execution

Example WorkloadProfile.status from an Nsight Compute run:

status:
  boundType: unknown
  metrics:
    achievedOccupancy: "80.62"
    l2Throughput: "31.23"
    smThroughput: "12.58"

Inspect resources:

kubectl logs job/<experiment>-profiling
kubectl get configmap <experiment>-profile-summary -o yaml
kubectl get workloadprofile <experiment>-profile -o yaml
kubectl get cudaexperiment <experiment> -o yaml
kubectl logs job/<experiment>-execution

Longer-Term Direction

The current controller validates profiling and profile creation. Future scheduling iterations will use stored workload profiles, GPU telemetry, node constraints, and Volcano integration to generate placement hints before execution.