Skip to content

Methods resource estimation

A resource estimation value model declares an estimate of resources needed by your method: "at least 5 Gb of memory", "32 CPUs", "estimated time of 20 minutes". Only methods need resource estimation. Resource estimations are built from value models, so they're re-evaluated by the platform against actual user data — not interpreted at build time, evaluated at run time. The same value models are used for validation rules.

For the exhaustive operator surface that resource estimation are built from, see reference: value-model catalogue; for a quick reference on how to add resource estimation, see how-to: add resource estimation.

Where to write method resource estimation

Method resource estimation is specified in *.method.kts file's resourceEstimation block. The block returns a MethodResourceEstimationValueModel. Inside, the body sees the value-model view of the method's configuration schema and all the input data. I.e. rules can be built based on input data (e.g. mesh size) and user settings (e.g. boundary conditions).

Anatomy

MethodResourceEstimationValueModel
  └─ oneProcessorEstimation
     ├─ memoryInMebibytes: IntegerValue
     ├─ storageInMebibytes: IntegerValue
     ├─ timeInSeconds: IntegerValue
     ├─ timeInSecondsByArch: Value<TimeByArchValueModel>
     ├─ timeInSecondsByGpuArch: Value<TimeByGpuArchValueModel>
     ├─ timeInSecondsByGpuArchAndModel: Value<TimeByGpuArchAndModelValueModel>
     └─ gpuEstimation
        ├─ gpuMemoryInMebibytes: IntegerValue
        └─ cpus: IntegerValue
  └─ scalingEstimation
      ├─ speedUp: ValueList<ScalingPointValueModel>
      ├─ memory: ValueList<ScalingPointValueModel>
      ├─ storage: ValueList<ScalingPointValueModel>
      └─ gpuScaling
         ├─ gpuMemory: ValueList<ScalingPointValueModel>
         └─ cpus: ValueList<ScalingPointValueModel>

ScalingPointValueModel
  ├─ processors: IntegerValue
  └─ scaling: RealValue

TimeByArchValueModel
  ├─ cpuArch: StringValue  // available ones are: "AMD64", "ARM"
  └─ timeInSeconds: IntegerValue

TimeByGpuArchValueModel
  ├─ gpuArch: StringValue  // available ones are: "NVIDIA" 
  └─ timeInSeconds: IntegerValue

TimeByGpuArchAndModelValueModel
  ├─ gpuArch: StringValue  // available ones are: "NVIDIA"
  ├─ gpuModel: StringValue  // available ones are: "A100", "H100", "H200"
  └─ timeInSeconds: IntegerValue

The developer provides resource estimation for a single processor and the scaling for multiprocessor runs. All inputs are optional. If nothing is provided, 1 CPU with 1Gb of memory and storage is provided.

Scaling estimation contains models for scaling curves: Speed up, memory scaling, storage scaling, and GPU scaling. All are modeled with a list of ScalingPointValueModel. A scaling point is defined by a scaling value corresponding to the number of processors.

You can use: * scalingPoint function to define a single scaling point based on constant values, * scaling function to define a list of scaling points based on constant values, * linearScaling function to declare that your method scales linearly.

This information is used to effectively provision an optimal machine for your method run.

A resource estimation end-to-end

Specifies one processor estimates and scaling based on mesh data size:

resourceEstimation {
    val meshDataSize = dataSizeValueModel("mesh")

    // Based on some heuristics
    val oneProcMemory = ceil(meshDataSize * 1.2)
    val oneProcTimeInSecs = meshDataSize / 60

    // Based on a representative test
    val memoryAndStorageScaling =
        scaling(
            1 to 1.0,
            2 to 1.28,
            4 to 1.44,
            8 to 1.87,
            12 to 2.32,
            16 to 2.67,
            24 to 3.52,
        )
    val speedUp =
        scaling(
            1 to 1.0,
            2 to 1.68,
            4 to 3.19,
            8 to 4.47,
            12 to 4.79,
            16 to 4.79,
            24 to 3.94,
        )

    return MethodResourceEstimationValueModel(
        oneProcessorEstimation =
            OneProcessorEstimationValueModel(
                memoryInMebibytes = oneProcMemory,
                storageInMebibytes = oneProcMemory * 10,
                timeInSeconds = oneProcTimeInSecs,
                timeInSecondsByArch =
                    ConstantValueList(
                        TimeByArchValueModel(cpuArch = "AMD64".asValueModel(), timeInSeconds = oneProcTimeInSecs),
                        TimeByArchValueModel(cpuArch = "ARM".asValueModel(), timeInSeconds = oneProcTimeInSecs / 2),
                    ),
            ),
        scalingEstimation =
            ScalingEstimationValueModel(
                speedUp = speedUp,
                memory = memoryAndStorageScaling,
                storage = memoryAndStorageScaling,
            ),
    )
}

Output JSON

Resource estimation is bundled into the component's JSON envelope (under the package field) and stored alongside the description in the registry. The platform acts on resource estimation and provisions a pod (virtual machine) on which the method will run.

Cross-references