Skip to content

Commit

Permalink
feat: Add Envar for Setting Pytorch Expandable Segments (#584)
Browse files Browse the repository at this point in the history
**Reason for Change**:
Setting `PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True` allows
PyTorch Memory Allocator to mark memory blocks as expandable for reduced
peak GPU memory usage.

---------

Signed-off-by: Ishaan Sehgal <ishaanforthewin@gmail.com>
  • Loading branch information
ishaansehgal99 authored Sep 3, 2024
1 parent cb7b83f commit fd83b2a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/tuning/preset-tuning.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ func CreatePresetTuning(ctx context.Context, workspaceObj *kaitov1alpha1.Workspa
Value: "k_proj,q_proj,v_proj,o_proj,gate_proj,down_proj,up_proj",
})
}
// Add Expandable Memory Feature to reduce Peak GPU Mem Usage
envVars = append(envVars, corev1.EnvVar{
Name: "PYTORCH_CUDA_ALLOC_CONF",
Value: "expandable_segments:True",
})
jobObj := resources.GenerateTuningJobManifest(ctx, workspaceObj, revisionNum, tuningImage, imagePullSecrets, *workspaceObj.Resource.Count, commands,
containerPorts, nil, nil, resourceReq, tolerations, initContainers, sidecarContainers, volumes, volumeMounts, envVars)

Expand Down

0 comments on commit fd83b2a

Please sign in to comment.