|
| 1 | +.. tabs:: |
| 2 | + |
| 3 | + .. code-tab:: python |
| 4 | + :caption: Python |
| 5 | + |
| 6 | + from ads.jobs import Job, DataScienceJob, PyTorchDistributedRuntime |
| 7 | + |
| 8 | + job = ( |
| 9 | + Job(name="LLAMA2-Fine-Tuning") |
| 10 | + .with_infrastructure( |
| 11 | + DataScienceJob() |
| 12 | + .with_log_group_id("<log_group_ocid>") |
| 13 | + .with_log_id("<log_ocid>") |
| 14 | + .with_compartment_id("<compartment_ocid>") |
| 15 | + .with_project_id("<project_ocid>") |
| 16 | + .with_subnet_id("<subnet_ocid>") |
| 17 | + .with_shape_name("VM.GPU.A10.1") |
| 18 | + .with_block_storage_size(256) |
| 19 | + ) |
| 20 | + .with_runtime( |
| 21 | + PyTorchDistributedRuntime() |
| 22 | + # Specify the service conda environment by slug name. |
| 23 | + .with_service_conda("pytorch20_p39_gpu_v1") |
| 24 | + .with_git( |
| 25 | + url="https://github.com/facebookresearch/llama-recipes.git", |
| 26 | + commit="03faba661f079ee1ecaeb66deaa6bdec920a7bab" |
| 27 | + ) |
| 28 | + .with_dependency( |
| 29 | + pip_pkg=" ".join([ |
| 30 | + "'accelerate>=0.21.0'", |
| 31 | + "appdirs", |
| 32 | + "loralib", |
| 33 | + "bitsandbytes==0.39.1", |
| 34 | + "black", |
| 35 | + "'black[jupyter]'", |
| 36 | + "datasets", |
| 37 | + "fire", |
| 38 | + "'git+https://github.com/huggingface/peft.git'", |
| 39 | + "'transformers>=4.31.0'", |
| 40 | + "sentencepiece", |
| 41 | + "py7zr", |
| 42 | + "scipy", |
| 43 | + "optimum" |
| 44 | + ]) |
| 45 | + ) |
| 46 | + .with_output("/home/datascience/outputs", "oci://bucket@namespace/outputs/$JOB_RUN_OCID") |
| 47 | + .with_command(" ".join([ |
| 48 | + "torchrun llama_finetuning.py", |
| 49 | + "--enable_fsdp", |
| 50 | + "--pure_bf16", |
| 51 | + "--batch_size_training 1", |
| 52 | + "--micro_batch_size 1", |
| 53 | + "--model_name $MODEL_NAME", |
| 54 | + "--dist_checkpoint_root_folder /home/datascience/outputs", |
| 55 | + "--dist_checkpoint_folder fine-tuned" |
| 56 | + ])) |
| 57 | + .with_replica(2) |
| 58 | + .with_environment_variable( |
| 59 | + MODEL_NAME="meta-llama/Llama-2-7b-hf", |
| 60 | + HUGGING_FACE_HUB_TOKEN="<access_token>", |
| 61 | + LD_LIBRARY_PATH="/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/opt/conda/lib", |
| 62 | + ) |
| 63 | + ) |
| 64 | + ) |
| 65 | + |
| 66 | + .. code-tab:: yaml |
| 67 | + :caption: YAML |
| 68 | + |
| 69 | + kind: job |
| 70 | + apiVersion: v1.0 |
| 71 | + spec: |
| 72 | + name: LLAMA2-Fine-Tuning |
| 73 | + infrastructure: |
| 74 | + kind: infrastructure |
| 75 | + spec: |
| 76 | + blockStorageSize: 256 |
| 77 | + compartmentId: "<compartment_ocid>" |
| 78 | + logGroupId: "<log_group_id>" |
| 79 | + logId: "<log_id>" |
| 80 | + projectId: "<project_id>" |
| 81 | + subnetId: "<subnet_id>" |
| 82 | + shapeName: VM.GPU.A10.2 |
| 83 | + type: dataScienceJob |
| 84 | + runtime: |
| 85 | + kind: runtime |
| 86 | + type: pyTorchDistributed |
| 87 | + spec: |
| 88 | + git: |
| 89 | + url: https://github.com/facebookresearch/llama-recipes.git |
| 90 | + commit: 03faba661f079ee1ecaeb66deaa6bdec920a7bab |
| 91 | + command: >- |
| 92 | + torchrun llama_finetuning.py |
| 93 | + --enable_fsdp |
| 94 | + --pure_bf16 |
| 95 | + --batch_size_training 1 |
| 96 | + --micro_batch_size 1 |
| 97 | + --model_name $MODEL_NAME |
| 98 | + --dist_checkpoint_root_folder /home/datascience/outputs |
| 99 | + --dist_checkpoint_folder fine-tuned |
| 100 | + replicas: 2 |
| 101 | + conda: |
| 102 | + type: service |
| 103 | + slug: pytorch20_p39_gpu_v1 |
| 104 | + dependencies: |
| 105 | + pipPackages: >- |
| 106 | + 'accelerate>=0.21.0' |
| 107 | + appdirs |
| 108 | + loralib |
| 109 | + bitsandbytes==0.39.1 |
| 110 | + black |
| 111 | + 'black[jupyter]' |
| 112 | + datasets |
| 113 | + fire |
| 114 | + 'git+https://github.com/huggingface/peft.git' |
| 115 | + 'transformers>=4.31.0' |
| 116 | + sentencepiece |
| 117 | + py7zr |
| 118 | + scipy |
| 119 | + optimum |
| 120 | + outputDir: /home/datascience/outputs |
| 121 | + outputUri: oci://bucket@namespace/outputs/$JOB_RUN_OCID |
| 122 | + env: |
| 123 | + - name: MODEL_NAME |
| 124 | + value: meta-llama/Llama-2-7b-hf |
| 125 | + - name: HUGGING_FACE_HUB_TOKEN |
| 126 | + value: "<access_token>" |
| 127 | + - name: LD_LIBRARY_PATH |
| 128 | + value: /usr/local/nvidia/lib:/usr/local/nvidia/lib64:/opt/conda/lib |
0 commit comments