Skip to content

Commit

Permalink
Merge pull request #72 from certik/namelist2
Browse files Browse the repository at this point in the history
CI: test fastGPT with LFortran
  • Loading branch information
certik authored Mar 17, 2024
2 parents bc528f8 + 249e1af commit 7d96ec2
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 2 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:

jobs:

basic:
name: Linux/macOS (${{ matrix.os }})
gfortran:
name: GFortran (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -49,3 +49,33 @@ jobs:
shell: bash -l {0}
run: |
ci/build.sh
lfortran:
name: LFortran (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest"]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: mamba-org/provision-with-micromamba@main
with:
environment-file: environment.yml
extra-specs: |
lfortran=0.20.3
sel(linux): llvm-openmp=11.1.0
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}

- name: Build and run
shell: bash -l {0}
run: |
ci/build_lfortran.sh
27 changes: 27 additions & 0 deletions ci/build_lfortran.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -ex

patch -p1 < ci/lfortran_namelist.patch

curl -o model.gguf -L https://huggingface.co/certik/fastGPT/resolve/main/model_fastgpt_124M_v2.gguf

mkdir lf
cd lf
FC=lfortran CMAKE_PREFIX_PATH=$CONDA_PREFIX cmake -DFASTGPT_BLAS=OpenBLAS -DCMAKE_BUILD_TYPE=Debug ..
make VERBOSE=1
ln -s ../model.gguf .
time OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 ./gpt2
time OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 ./test_basic_input
time OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 ./test_more_inputs
cd ..

mkdir lf-fast
cd lf-fast
FC="lfortran --fast" CMAKE_PREFIX_PATH=$CONDA_PREFIX cmake -DFASTGPT_BLAS=OpenBLAS -DCMAKE_BUILD_TYPE=Release ..
make VERBOSE=1
ln -s ../model.gguf .
time OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 ./gpt2
time OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 ./test_basic_input
time OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 ./test_more_inputs
cd ..
31 changes: 31 additions & 0 deletions ci/lfortran_namelist.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
commit 8bc6115d9d2a60dc6af986f0da3b6ca21177d83b
Author: Ondřej Čertík <[email protected]>
Date: Tue Sep 5 13:54:47 2023 -0600

Workaround a namelist, which is not supported yet

diff --git a/driver.f90 b/driver.f90
index a5fe28a..ff4ae2b 100644
--- a/driver.f90
+++ b/driver.f90
@@ -17,18 +17,9 @@ character(:), allocatable, intent(out) :: input_txt
integer, intent(out) :: n_tokens_to_generate
character(1024) :: input_txt2
integer :: u, ios
-namelist / input_fastGPT / n_tokens_to_generate
allocate(character(0) :: input_txt)
-input_txt = ""
-open(newunit=u, file=filename, status="old")
-read(u, input_fastGPT)
-do
- read(u, "(a)", iostat=ios) input_txt2
- if (ios /= 0) exit
- if (len(input_txt) > 0) input_txt = input_txt // char(10)
- input_txt = input_txt // trim(input_txt2)
-end do
-close(u)
+n_tokens_to_generate = 20
+input_txt = "Alan Turing theorized that computers would one day become very powerful, but even he could not imagine"
end subroutine

! Skips `amount` bytes from the current position

0 comments on commit 7d96ec2

Please sign in to comment.