Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix openssf #273

Closed
wants to merge 59 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
2f8d21b
add part of DPO code
minmingzhu May 23, 2024
5169639
integrate DPO trainer
minmingzhu May 24, 2024
9a7b63d
update
minmingzhu May 27, 2024
9476a0b
update
minmingzhu May 29, 2024
0971b18
update
minmingzhu May 29, 2024
e5da4e0
1. code format
minmingzhu May 29, 2024
51d60fc
update
minmingzhu May 29, 2024
5aee2b6
add DPO example
minmingzhu May 29, 2024
f7d17f2
update
minmingzhu May 31, 2024
ec77c05
fix comments
minmingzhu Jun 5, 2024
7efbe7e
update
minmingzhu Jun 5, 2024
1650fda
Update huggingface_dataset.py
minmingzhu Jun 5, 2024
a022320
Update finetune_config.py
minmingzhu Jun 5, 2024
698cbb9
update
minmingzhu Jun 15, 2024
bd3477b
Update test_openai_protocol.py
minmingzhu Jun 14, 2024
9e88652
1. fix comments
minmingzhu Jun 16, 2024
2bbb6fd
format
minmingzhu Jun 16, 2024
19b574a
update
minmingzhu Jun 16, 2024
3c0b332
update
minmingzhu Jun 16, 2024
1d07d1e
update
minmingzhu Jun 16, 2024
d3ee663
update
minmingzhu Jun 17, 2024
09097f7
debug CI
minmingzhu Jun 17, 2024
7400086
update CI
minmingzhu Jun 17, 2024
c9d6912
update CI
minmingzhu Jun 17, 2024
ea06dd7
update CI
minmingzhu Jun 17, 2024
f4fc1c2
update CI
minmingzhu Jun 19, 2024
f37a30b
1. update CI
minmingzhu Jun 19, 2024
9105a44
update CI
minmingzhu Jun 19, 2024
5a87496
update doc
minmingzhu Jun 20, 2024
32d70c1
refactor
minmingzhu Jun 20, 2024
2dafa94
update
minmingzhu Jul 2, 2024
e649649
add part of DPO code
minmingzhu May 23, 2024
66f1f35
integrate DPO trainer
minmingzhu May 24, 2024
0ffc7b4
update
minmingzhu May 27, 2024
ee279ad
update
minmingzhu May 29, 2024
6cfe399
update
minmingzhu May 29, 2024
809f8bc
1. code format
minmingzhu May 29, 2024
fccd18e
update
minmingzhu May 29, 2024
5b3aec5
add DPO example
minmingzhu May 29, 2024
9009509
update
minmingzhu May 31, 2024
ee87b3b
fix comments
minmingzhu Jun 5, 2024
d866aaa
update
minmingzhu Jun 5, 2024
139604b
Update huggingface_dataset.py
minmingzhu Jun 5, 2024
d62462f
Update finetune_config.py
minmingzhu Jun 5, 2024
3fcf77d
update
minmingzhu Jun 15, 2024
9a61837
1. fix comments
minmingzhu Jun 16, 2024
188e6d5
update
minmingzhu Jun 16, 2024
a0374a6
update
minmingzhu Jun 16, 2024
62d5026
update
minmingzhu Jun 17, 2024
c4cc4ef
update CI
minmingzhu Jun 17, 2024
4f3bda0
update CI
minmingzhu Jun 17, 2024
2395a9d
update CI
minmingzhu Jun 17, 2024
9209e4d
update CI
minmingzhu Jun 19, 2024
ba8b4e7
1. update CI
minmingzhu Jun 19, 2024
be492d4
update doc
minmingzhu Jun 20, 2024
cac58df
refactor
minmingzhu Jun 20, 2024
306902a
update
minmingzhu Jul 2, 2024
eb393f6
update
minmingzhu Jul 2, 2024
6155031
fix openssf
minmingzhu Aug 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/workflow_finetune.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-ft
cancel-in-progress: true

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
finetune:
name: finetune
Expand Down Expand Up @@ -63,7 +66,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Build Docker Image
run: |
Expand All @@ -88,6 +91,12 @@ jobs:
source dev/scripts/ci-functions.sh
finetune_test ${{ matrix.model }}

- name: Run Finetune DPO Test
run: |
TARGET="finetune"
source dev/scripts/ci-functions.sh
finetune_dpo_test ${{ matrix.model }}

- name: Run PEFT-LoRA Test
run: |
source dev/scripts/ci-functions.sh
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/workflow_finetune_gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
type: string
default: 'http://proxy-prc.intel.com:912'

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
finetune-gpu:
name: finetune-gpu
Expand All @@ -35,7 +38,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Running task on Intel GPU
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/workflow_inference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-inf
cancel-in-progress: true

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
inference:
name: inference
Expand Down Expand Up @@ -65,7 +68,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Determine Target
id: "target"
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/workflow_inference_gaudi2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-inf-gaudi2
cancel-in-progress: true

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
inference:
name: inference
Expand Down Expand Up @@ -81,7 +84,7 @@ jobs:
echo "target=$target" >> $GITHUB_OUTPUT

- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Build Docker Image
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/workflow_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-lt
cancel-in-progress: true

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
lint:
name: lint
Expand All @@ -22,7 +25,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Run Lint
run: ./format.sh -a
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/workflow_orders_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on: []
# schedule:
# - cron: "0 16 * * *"

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:

call-inference:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/workflow_orders_on_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- '**'
- '!*.md'

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
Lint:
uses: ./.github/workflows/workflow_lint.yml
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/workflow_orders_on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
paths:
- '**'
- '!*.md'

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:

Lint:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/workflow_test_benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-bench
cancel-in-progress: true

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
setup-test:

Expand All @@ -51,7 +54,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Load environment variables
run: cat /root/actions-runner-config/.env >> $GITHUB_ENV
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/workflow_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
type: string
default: 'pr'

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
setup-test:

Expand All @@ -26,10 +29,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{matrix.python-version}}
architecture: 'x64'
Expand Down Expand Up @@ -60,10 +63,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{matrix.python-version}}
architecture: 'x64'
Expand Down Expand Up @@ -94,10 +97,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{matrix.python-version}}
architecture: 'x64'
Expand Down Expand Up @@ -141,7 +144,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Determine Target
id: "target"
Expand All @@ -165,7 +168,7 @@ jobs:
code_checkout_path=${{ github.workspace }}
source dev/scripts/ci-functions.sh
start_docker ${TARGET} ${code_checkout_path}

- name: Install Dependencies for Tests
run: |
TARGET=${{steps.target.outputs.target}}
Expand All @@ -189,4 +192,4 @@ jobs:
run: |
TARGET=${{steps.target.outputs.target}}
source dev/scripts/ci-functions.sh
stop_container ${TARGET}
stop_container ${TARGET}
15 changes: 15 additions & 0 deletions dev/scripts/ci-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,21 @@ finetune_test(){
docker exec "finetune" bash -c "llm_on_ray-finetune --config_file llm_on_ray/finetune/finetune.yaml"
}

finetune_dpo_test(){
local model=$1
# Check if the model is 'EleutherAI/gpt-j-6b' or 'gpt2'
if [ "$model" == "EleutherAI/gpt-j-6b" ] || [ "$model" == "gpt2" ]; then
echo "Model '$model' is not supported for this operation."
return
fi
echo Set finetune source config :
docker exec "finetune" bash -c "source \$(python -c 'import oneccl_bindings_for_pytorch as torch_ccl;print(torch_ccl.cwd)')/env/setvars.sh; RAY_SERVE_ENABLE_EXPERIMENTAL_STREAMING=1 ray start --head --node-ip-address 127.0.0.1 --ray-debugger-external; RAY_SERVE_ENABLE_EXPERIMENTAL_STREAMING=1 ray start --address='127.0.0.1:6379' --ray-debugger-external"
echo Set "${model}" patch_yaml_config :
docker exec "finetune" bash -c "python dev/scripts/patch_yaml_config.py --conf_path "llm_on_ray/finetune/finetune.yaml" --models ${model} --dpo"
echo Stert "${model}" dpo finetune :
docker exec "finetune" bash -c "llm_on_ray-finetune --config_file llm_on_ray/finetune/finetune.yaml"
}

peft_lora_test(){
local model=$1
docker exec "finetune" bash -c "rm -rf /tmp/llm-ray/*"
Expand Down
8 changes: 8 additions & 0 deletions dev/scripts/patch_yaml_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def patch_yaml_config():
parser.add_argument("--conf_path", type=str)
parser.add_argument("--models", type=str)
parser.add_argument("--peft_lora", action="store_true", default=False)
parser.add_argument("--dpo", action="store_true", default=False)

args = parser.parse_args()

conf_path = args.conf_path
Expand Down Expand Up @@ -69,6 +71,12 @@ def patch_yaml_config():
result["General"]["lora_config"]["target_modules"] = None
else:
result["General"]["lora_config"] = None
if args.dpo:
if "finetuning_model" not in result["Training"]:
result["Training"]["finetuning_model"] = {}
result["Dataset"]["train_file"] = "examples/data/sample_dpo_data.jsonl"
result["Training"]["beta"] = 0.1
result["Training"]["finetuning_model"]["dpo"] = True

with open(conf_path, "w") as output:
yaml.dump(result, output, sort_keys=False)
Expand Down
3 changes: 3 additions & 0 deletions docs/finetune_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ The following are the parameters supported in the finetuning workflow.
| mask_input |True| mask the input part in lables |
| mask_response |True| mask the response part in lables |
| data_preprocess_type |neural_chat| The type of the encode input |
|pad_max|False|Whether to pad the data to the max length of the batch|
|max_source_length|512|Maximum source sequence length. Sequences will be right padded|
|torch_dtype|bfloat16|Override the default `torch.dtype` and load the model under this dtype|


## Training Parameters
Expand Down
Loading
Loading