Skip to content

Commit cf1f7d3

Browse files
authored
Merge pull request #11 from ben1009/housekeeping
chore: housekeeping
2 parents 1159247 + 51e79eb commit cf1f7d3

20 files changed

Lines changed: 233 additions & 85 deletions

.github/codecov.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# # ref: https://docs.codecov.com/docs/codecovyml-reference
2+
# comment out coverage job for now, https://github.com/tekaratzas/RustGPT/pull/11#issuecomment-3361854174
3+
# coverage:
4+
# # Hold ourselves to a high bar
5+
# range: 55..100
6+
# round: down
7+
# precision: 1
8+
# status:
9+
# # ref: https://docs.codecov.com/docs/commit-status
10+
# project:
11+
# default:
12+
# # Avoid false negatives
13+
# threshold: 1%
14+
15+
# # Test files aren't important for coverage
16+
# ignore:
17+
# - "tests"
18+
19+
# # Make comments less noisy
20+
# comment:
21+
# layout: "files"
22+
# require_changes: yes

.github/workflows/check.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
permissions:
2+
contents: read
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
merge_group:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
env:
14+
RUST_TOOLCHAIN: stable
15+
16+
name: Check
17+
jobs:
18+
fmt:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
name: fmt
23+
permissions:
24+
# Give the default GITHUB_TOKEN write permission to commit and push the
25+
# added or changed files to the repository.
26+
contents: write
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
submodules: true
31+
- name: Install rust
32+
uses: dtolnay/rust-toolchain@master
33+
with:
34+
toolchain: nightly #${{ env.RUST_TOOLCHAIN }}
35+
components: rustfmt
36+
- run: cargo fmt --check
37+
38+
clippy:
39+
runs-on: ubuntu-latest
40+
name: clippy
41+
permissions:
42+
contents: read
43+
checks: write
44+
strategy:
45+
fail-fast: false
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
submodules: true
50+
- name: Install ${{ env.RUST_TOOLCHAIN }}
51+
uses: dtolnay/rust-toolchain@master # master
52+
with:
53+
toolchain: ${{ env.RUST_TOOLCHAIN }}
54+
components: clippy
55+
- name: Rust Cache
56+
uses: Swatinem/rust-cache@v2
57+
- run: cargo clippy --workspace --all-features --all-targets -- -D warnings
58+
59+
typos:
60+
runs-on: ubuntu-latest
61+
name: typos
62+
permissions:
63+
contents: read
64+
strategy:
65+
fail-fast: false
66+
steps:
67+
- uses: actions/checkout@v4
68+
with:
69+
submodules: true
70+
- name: Check spelling
71+
uses: crate-ci/typos@master
72+
73+

.github/workflows/rust.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
permissions:
2+
contents: read
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
merge_group:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
env:
14+
RUST_TOOLCHAIN: stable
15+
16+
name: Test
17+
jobs:
18+
required:
19+
runs-on: ubuntu-latest
20+
name: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
- name: Install ${{ env.RUST_TOOLCHAIN }}
26+
uses: dtolnay/rust-toolchain@master
27+
with:
28+
toolchain: ${{ env.RUST_TOOLCHAIN }}
29+
- name: cargo generate-lockfile
30+
if: hashFiles('Cargo.lock') == ''
31+
run: cargo generate-lockfile
32+
# https://twitter.com/jonhoo/status/1571290371124260865
33+
- name: Rust Cache
34+
uses: Swatinem/rust-cache@v2
35+
- name: Install nextest
36+
uses: taiki-e/install-action@nextest
37+
- name: cargo nextest --locked
38+
run: cargo nextest run --locked --workspace --all-features --all-targets
39+
40+
# comment out coverage job for now, https://github.com/tekaratzas/RustGPT/pull/11#issuecomment-3361854174
41+
# coverage:
42+
# runs-on: ubuntu-latest
43+
# name: coverage
44+
# steps:
45+
# - uses: actions/checkout@v4
46+
# with:
47+
# submodules: true
48+
# - name: Install rust
49+
# uses: dtolnay/rust-toolchain@master
50+
# with:
51+
# toolchain: ${{ env.RUST_TOOLCHAIN }}
52+
# components: llvm-tools-preview
53+
# - name: cargo install cargo-llvm-cov
54+
# uses: taiki-e/install-action@cargo-llvm-cov
55+
# - name: cargo generate-lockfile
56+
# if: hashFiles('Cargo.lock') == ''
57+
# run: cargo generate-lockfile
58+
# - name: Rust Cache
59+
# uses: Swatinem/rust-cache@v2
60+
# - name: Install nextest
61+
# uses: taiki-e/install-action@nextest
62+
# - name: cargo llvm-cov
63+
# run: cargo llvm-cov nextest --locked --workspace --all-features --all-targets --lcov --output-path lcov.info
64+
# - name: Upload to codecov.io
65+
# uses: codecov/codecov-action@v5
66+
# with:
67+
# fail_ci_if_error: true
68+
# token: ${{ secrets.CODECOV_TOKEN }} # required

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2024"
77
[dependencies]
88
bincode = "2.0.1"
99
ndarray = "0.16.1"
10-
rand = "0.9.0"
10+
rand = "0.9.2"
1111
rand_distr = "0.5.0"
1212
serde = { version = "1.0", features = ["derive"] }
1313
serde_json = "1.0"

rustfmt.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
edition = "2024"
2+
style_edition = "2024"
3+
comment_width = 120
4+
format_code_in_doc_comments = true
5+
format_macro_bodies = true
6+
format_macro_matchers = true
7+
normalize_comments = true
8+
normalize_doc_attributes = true
9+
imports_granularity = "Crate"
10+
group_imports = "StdExternalCrate"
11+
reorder_impl_items = true
12+
reorder_imports = true
13+
tab_spaces = 4
14+
wrap_comments = true

src/dataset_loader.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
use csv::ReaderBuilder;
2-
use serde_json;
31
use std::fs;
42

3+
use csv::ReaderBuilder;
4+
55
pub struct Dataset {
66
pub pretraining_data: Vec<String>,
77
pub chat_training_data: Vec<String>,
88
}
99

1010
#[allow(dead_code)]
11+
#[allow(clippy::upper_case_acronyms)]
1112
pub enum DatasetType {
1213
JSON,
1314
CSV,

src/embeddings.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use crate::{EMBEDDING_DIM, MAX_SEQ_LEN, adam::Adam, llm::Layer, vocab::Vocab};
21
use ndarray::{Array2, s};
32
use rand_distr::{Distribution, Normal};
43

4+
use crate::{EMBEDDING_DIM, MAX_SEQ_LEN, adam::Adam, llm::Layer, vocab::Vocab};
5+
56
pub struct Embeddings {
67
pub token_embeddings: Array2<f32>,
78
pub positional_embeddings: Array2<f32>,

src/feed_forward.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::{adam::Adam, llm::Layer};
2-
use ndarray::Array2;
3-
use ndarray::Axis;
1+
use ndarray::{Array2, Axis};
42
use rand_distr::{Distribution, Normal};
53

4+
use crate::{adam::Adam, llm::Layer};
5+
66
pub struct FeedForward {
77
w1: Array2<f32>,
88
b1: Array2<f32>,

src/layer_norm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::adam::Adam;
2-
use crate::llm::Layer;
31
use ndarray::{Array2, Axis};
42

3+
use crate::{adam::Adam, llm::Layer};
4+
55
pub struct LayerNorm {
66
epsilon: f32, // Small constant for stability
77
gamma: Array2<f32>, // Learnable scaling parameter

0 commit comments

Comments
 (0)