Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
e10b8dc
Add ratchet-web-train
vinhowe Feb 17, 2025
87eb40c
Add ratchet-train-toy demo
vinhowe Feb 17, 2025
06b6640
Target bundler with wasm builds
vinhowe Feb 17, 2025
d75b38b
Update pnpm lock (:
vinhowe Feb 17, 2025
b56154e
I think this is important?
vinhowe Feb 17, 2025
e0d2fac
Yeah we're just gonna switch this for now
vinhowe Feb 17, 2025
d802af9
Remove tokenizers import for now?
vinhowe Feb 17, 2025
de2e068
Revert "Remove tokenizers import for now?"
vinhowe Feb 17, 2025
57ba9ce
Add sort of hacky cached inference
vinhowe Feb 18, 2025
8c8e253
Generate batches/toy tasks on frontend
vinhowe Feb 18, 2025
1caa0ab
Not clear that this is needed
vinhowe Feb 18, 2025
0fc5191
Update pnpm-lock.yaml
vinhowe Feb 18, 2025
d783088
Remove more rust batch code
vinhowe Feb 18, 2025
0cb319c
Add web-visible generation api
vinhowe Feb 18, 2025
0295c2b
Cache non mark_step forward passes
vinhowe Feb 18, 2025
033b065
Provisionally mark 256 as the end of sequence token
vinhowe Feb 18, 2025
e3140dd
Return per-token losses for visualization
vinhowe Feb 18, 2025
6e2104f
Allow running generate without streaming
vinhowe Feb 18, 2025
114d27f
Rework task generation to be configurable
vinhowe Feb 18, 2025
b58aba9
Visualize train batches
vinhowe Feb 18, 2025
106d692
Make tick slider look less busy
vinhowe Feb 18, 2025
604e874
Add eval + eval eample visualization
vinhowe Feb 18, 2025
746bfa9
Add eslint rule to ignore _ vars
vinhowe Feb 18, 2025
89cbed6
Update pnpm-lock.yaml
vinhowe Feb 18, 2025
2160384
Formatting, I can only assume
vinhowe Feb 18, 2025
5bc060f
Turn val loss ticker into val accuracy
vinhowe Feb 18, 2025
c85cf0c
Fix alignment of links on mobile
vinhowe Feb 18, 2025
185f57c
Move sidebar to the left in a responsive way
vinhowe Feb 18, 2025
d9aa494
Pad tasks to digits of max num
vinhowe Feb 18, 2025
d2aca94
Make mod add default modulo 113
vinhowe Feb 18, 2025
857871b
don't show modulo in mod add task
vinhowe Feb 18, 2025
b25d661
Work out per-task tokenization
vinhowe Feb 19, 2025
a51b404
Implement masking out prompt
vinhowe Feb 19, 2025
afe82d2
Remove now-unused generateTask
vinhowe Feb 19, 2025
a935084
Fix mutability problem for wasm generate
vinhowe Feb 19, 2025
36a48ef
Rename a bunch of tokenMap -> tokenizer
vinhowe Feb 19, 2025
6ba52fb
Reorganize eval for config-dependent tokenizers
vinhowe Feb 19, 2025
d5cac40
Force embedding size to be multiple of 8
vinhowe Feb 19, 2025
6f17652
Make tick sliders reactive
vinhowe Feb 19, 2025
4b2e671
Use dumber tokenizers
vinhowe Feb 19, 2025
ab17ca4
Update README.md
vinhowe Feb 19, 2025
1b66325
Update README.md
vinhowe Feb 19, 2025
2ed2095
Add label smoothing
vinhowe Feb 19, 2025
e51dfba
Clean up slider al a little bit
vinhowe Feb 19, 2025
a9ed602
Formatting, I assume
vinhowe Feb 19, 2025
b4772ee
Use new name for repo
vinhowe Feb 19, 2025
c9fc1c5
Enforce two sum items <= sum/2
vinhowe Feb 19, 2025
4c21bcf
Allow boolean types in task config + expression types
vinhowe Feb 19, 2025
3df8926
Allow effectively turning off label smoothing
vinhowe Feb 19, 2025
9eb4304
Add option to have no positional encoding
vinhowe Feb 19, 2025
a6f3ba2
Add some defaults
vinhowe Feb 19, 2025
e47607f
TrainBatchConfig actually shouldn't control prefix masking
vinhowe Feb 19, 2025
32083cd
Make the default datset two sum
vinhowe Feb 19, 2025
d3fffea
Don't mask out prefix by default
vinhowe Feb 19, 2025
0cece87
Don't set vocab size in page.svelte
vinhowe Feb 19, 2025
d1715f0
Set some defaults more conservativelY
vinhowe Feb 19, 2025
b57c8b8
Add attn values to streaming generate output
vinhowe Feb 21, 2025
67deb9e
Make commas and colon optional
vinhowe Feb 22, 2025
f234509
Make sort tokenizer alphabetic
vinhowe Feb 22, 2025
7628f6a
Make two sum also alphabetic
vinhowe Feb 22, 2025
0dba985
Make sorting commas and colon optional
vinhowe Feb 22, 2025
2668a92
Fix inequality bug
vinhowe Feb 22, 2025
a38ef05
Make max num on alphabetic sequences 26
vinhowe Feb 22, 2025
3d71532
Make sorting commas false by default
vinhowe Feb 22, 2025
12e7fc2
Fix dumb prompt and target mistake (no colon needed)
vinhowe Feb 22, 2025
64d362e
Don't do an unused end token
vinhowe Feb 22, 2025
acf9fce
Make tokenizers oh so configurable
vinhowe Feb 23, 2025
c5a1a4f
Fix up types for maskOutPrefix
vinhowe Feb 23, 2025
f337173
Some fixes for sort tokenizer
vinhowe Feb 23, 2025
4c024f8
Temporarily remove caching
vinhowe Feb 23, 2025
402ef92
Allow huge batch sizes
vinhowe Feb 23, 2025
9cf7fec
Make sort description clearer
vinhowe Feb 23, 2025
0e9e103
Include colon in sort target
vinhowe Feb 23, 2025
f039013
Add repeat task
vinhowe Feb 23, 2025
7d34524
Fix casting in backprop
vinhowe Feb 27, 2025
a59ad36
Turn caching back on + kill shared alloc for now
vinhowe Feb 27, 2025
eb455a3
Add f16 support for affine
vinhowe Feb 27, 2025
6a8a740
Some wishful f16 casting
vinhowe Feb 27, 2025
c60486d
Add back non masking variant of loss to compare
vinhowe Feb 27, 2025
5d67b0e
Turn "off" label smoothing for now
vinhowe Feb 27, 2025
6af5cae
Kill manual f16 casting for now until we investigate nans
vinhowe Mar 1, 2025
1a41439
Remove CLI
vinhowe Mar 2, 2025
77ae87d
Remove some low-effort comments
vinhowe Mar 2, 2025
a244752
Fixes for profiling executor
vinhowe Mar 2, 2025
b6cc081
Deduplicate postorder (:
vinhowe Mar 5, 2025
d08446a
Flip attention mask (for fun)
vinhowe Mar 6, 2025
e713e71
Add scope pushing
vinhowe Mar 7, 2025
9aaeee1
Clean up layernorm configuration
vinhowe Mar 7, 2025
5bedc4d
Add hack to exfiltrate js GPUDevice
vinhowe Mar 7, 2025
5ec5d3f
Start asyncifying execution
vinhowe Mar 7, 2025
41fc4db
Go back to using nll masked
vinhowe Mar 7, 2025
a0f4dad
Update wasm-bindgen for fix
vinhowe Mar 7, 2025
c2b0e17
Runtime tensor inspection/profiling overhaul
vinhowe Mar 8, 2025
67eec0f
tril nit
vinhowe Mar 8, 2025
db030fa
Remove imports for now-JS toy tasks
vinhowe Mar 8, 2025
02ab202
Add non-AR forward method
vinhowe Mar 8, 2025
43ff252
Add dropout
vinhowe Mar 8, 2025
5b7894a
Switches: caching, inplace
vinhowe Mar 8, 2025
85232c5
Add no layernorm option
vinhowe Mar 9, 2025
b15652e
Add training/eval mode thread local
vinhowe Mar 9, 2025
a9aea65
Stop fudging attention visualization :facepalm:
vinhowe Mar 9, 2025
7c9eb4f
Remove dataset field on trainer
vinhowe Mar 9, 2025
d7c14bf
Remove dataset imports for now
vinhowe Mar 9, 2025
2ac4651
Remove doc comment I don't want to update
vinhowe Mar 9, 2025
d29cf7f
Rename model internals to match minGPT
vinhowe Mar 9, 2025
cbf90eb
Update method to download weights as safetensors
vinhowe Mar 9, 2025
818fb77
Pull ratchet loader wasm bindgen from workspace
vinhowe Mar 9, 2025
6b0fd2a
Add wasm-land tensorlogstep cpu conversion
vinhowe Mar 9, 2025
11564cf
Remove debug log I don't care for
vinhowe Mar 9, 2025
543578c
Remove what I think are overeager comments
vinhowe Mar 9, 2025
9218a99
Make gelu default consistent
vinhowe Mar 9, 2025
10148b1
Add missing dropout probs to test
vinhowe Mar 9, 2025
c9e29e1
Make generating in tests optional (I'm abusing tests)
vinhowe Mar 9, 2025
fe9917e
Make 2 sum test run for longer
vinhowe Mar 9, 2025
a65685b
Start slimming: remove whisper implementation
vinhowe Mar 9, 2025
3612130
Update pnpm-lock.yaml
vinhowe Mar 9, 2025
c762ca3
config.toml formatting
vinhowe Mar 9, 2025
9c4204f
Remove debug I don't like
vinhowe Mar 9, 2025
e141eb7
Add simple caching sanity check
vinhowe Mar 9, 2025
6ddc9c5
Comment this assertion for now; might be important
vinhowe Mar 9, 2025
7ede0c0
Ignore samply profiles
vinhowe Mar 9, 2025
a6cd232
Ignore webdriver configs
vinhowe Mar 9, 2025
8da3a84
Check in impl of async/future buffer syncing
vinhowe Mar 9, 2025
d2cda0e
Revert "Check in impl of async/future buffer syncing"
vinhowe Mar 9, 2025
dc93a42
Remove moondream impl
vinhowe Mar 9, 2025
1f70c6c
Update pnpm-lock.yaml
vinhowe Mar 9, 2025
9b448e4
Update vite version on ratchet-train-toy
vinhowe Mar 9, 2025
8d93d9a
Add using cache graph
vinhowe Mar 9, 2025
24b4657
Move trainWorker and tasks to $lib
vinhowe Mar 9, 2025
9059dfa
Add test log utils for web train tests
vinhowe Mar 9, 2025
eadb680
Remove unused TensorId import
vinhowe Mar 9, 2025
9d169d1
Remove unused CPUBuffer import
vinhowe Mar 9, 2025
ca635bc
Slim: remove ratchet-phi
vinhowe Mar 9, 2025
fdfb57c
Slim: remove ratchet-web
vinhowe Mar 9, 2025
4941658
Remove workflows for now
vinhowe Mar 9, 2025
8febf15
Move tasks to lib with trainWorker
vinhowe Mar 9, 2025
8bd0cb9
Update pnpm-lock.yaml
vinhowe Mar 9, 2025
5ab8b1a
Remove ratchet-phi from workspace
vinhowe Mar 9, 2025
9d039f0
Update pnpm lock
vinhowe Mar 9, 2025
c902009
Remove unused import
vinhowe Mar 9, 2025
9c02bef
Make shared objects usage configurable
vinhowe Mar 10, 2025
59ff03e
Remove all workflows for now
vinhowe Mar 10, 2025
45b2689
Merge branch 'backward' into web-demo
vinhowe Mar 10, 2025
84925c6
Check in adamw browser test to remove
vinhowe Mar 10, 2025
eaeb0cd
Revert "Check in adamw browser test to remove"
vinhowe Mar 11, 2025
d2ffe01
Cull empty browser tests for now
vinhowe Mar 11, 2025
e9bf0f0
Add test ops tool from awhile ago
vinhowe Mar 9, 2025
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
6 changes: 3 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Needed for WASM unstable features
[build]
rustflags = [ "--cfg=web_sys_unstable_apis" ]
rustdocflags = [ "--cfg=web_sys_unstable_apis" ]
#target = "wasm32-unknown-unknown"
rustflags = ["--cfg=web_sys_unstable_apis"]
rustdocflags = ["--cfg=web_sys_unstable_apis"]
target = "wasm32-unknown-unknown"
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ venv/

# proptest regression tests
proptest-regressions/

# samply profile
profile.json

# webdriver configs
webdriver.json
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
members = [
"crates/ratchet-hub",
"crates/ratchet-core",
"crates/ratchet-web",
"crates/ratchet-web-train",
"crates/ratchet-loader",
"crates/ratchet-models",
"crates/ratchet-nn",
"crates/ratchet-hub",
"crates/ratchet-cli",
"crates/ratchet-macros",
"crates/ratchet-datasets",
]
Expand All @@ -28,7 +27,7 @@ inherits = "release"
debug = 2

[workspace.dependencies]
wgpu = { git = "https://github.com/vinhowe/wgpu", branch = "feature/multi-dim-compute-subgroups", features = [
wgpu = { git = "https://github.com/vinhowe/wgpu", branch = "feature/extract-webgpu-gpubuffer", features = [
"fragile-send-sync-non-atomic-wasm",
] }
bytemuck = { version = "1.14.0", features = [
Expand All @@ -49,7 +48,7 @@ anyhow = "1.0.79"
tokenizers = "0.19.1"

js-sys = "0.3.64"
wasm-bindgen = "0.2.91"
wasm-bindgen = "0.2.100"
wasm-bindgen-test = "0.3.34"
cfg-if = "1.0.0"
chrono = "0.4.35"
Expand Down
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<p align="center">
<b>For the time being, I don't have instructions on how to run this. You're on your own for a tiny bit :)</b>
</p>
# toy transformer

<div align="center">
<img width="200px" src="https://github.com/vinhowe/ratchet-backward/raw/master/.github/ratchet.png">
<p align="center">
<code>(backward)</code>
</p>
<br>
</div>
Watch a toy model train, in your browser, with WebGPU.

## Attribution

This is a fork of [Ratchet](https://github.com/huggingface/ratchet), hacked and butchered to add backpropogation, to show that it is technically possible to train language models in a (WebGPU-enabled) browser.

Expand Down
26 changes: 0 additions & 26 deletions crates/ratchet-cli/Cargo.toml

This file was deleted.

253 changes: 0 additions & 253 deletions crates/ratchet-cli/src/bin/cli.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/ratchet-cli/src/lib.rs

This file was deleted.

4 changes: 4 additions & 0 deletions crates/ratchet-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ maybe-async = { workspace = true }
async-trait = "0.1.77"
smallvec = { workspace = true, features = ["serde"] }

[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
features = ["GpuBuffer", "GpuDevice"]
workspace = true

[dev-dependencies]
env_logger = { workspace = true }
rand = { workspace = true }
Expand Down
Loading