Repository navigation
gpt-oss-20b trains in-process (MoE backward in the llama.cpp patch); tuned qwen3-14b and gpt-oss-20b profiles - #20
Merged
Conversation
… SWIGLU_OAI); qwen3-14b and gpt-oss-20b profiles GGML_OP_OUT_PROD_ID is the input gradient of MUL_MAT_ID with the experts frozen: a CPU kernel (one dequantized expert row at a time) and a CUDA kernel (routing read once, then per expert: gather its columns, dequantize slices, GEMM, scatter-add). ADD_ID passes its gradient to the activations; SWIGLU_OAI's backward is built from clamp, sigmoid, step and mul, split and fused. packaging/llama-patches/tests/gradtest.cpp checks all of them on the CPU against finite differences (and quantized experts against f32): all pass. The CUDA kernel is not built or run yet. models.json: qwen3-14b (Q4_K_M) and gpt-oss-20b (MXFP4), in-process trainer, training settings still the 1.5B's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…om the weights, gate recall 1.00, drift 1.14); bench_llama follows [gpu] layout On bench/facts.json (30 facts, 60 questions), training through the Q4_K_M weights on the card: 2 epochs (the 1.5B's setting) 0.90 from the weights, recall 0.93, drift 1.22, 42 s; 3 epochs 0.967, recall 1.00, drift 1.14, interference 0.017, 59 s. A 10-fact sweep of lr and epochs (0.80 to 1.00) picked 3 epochs at lr 3e-4. bench_llama resolved no layout and forced the CPU, so on a card it tried to make a 60 GB f32 copy of the 14B; it now uses Mem.Layout (BENCH_CPU=1 for the old behaviour). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…ft 1.40); batched GET_ROWS_BACK; tuned profiles The last missing backward for gpt-oss was get_rows over a batch (each token's expert weights): GET_ROWS_BACK is now batched on the CPU and CUDA, checked against finite differences in gradtest.cpp. On an RTX 4090 the CUDA OUT_PROD_ID matches the CPU for f32, Q4_K, MXFP4 and Q8_0 experts, and gpt-oss-20b trains end to end: 4 epochs, lr 6e-4, 32 anchors gives 0.75 answered from the weights, gate recall 1.00, drift 1.40, 31 s (10 facts). gpt-oss-20b profile set to that. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
memagent's own llama.cpp trainer can now train gpt-oss-20b, and two tuned profiles target a single 16 GB+ GPU. Write-up:
bench/README.md, section "Qwen3-14B and gpt-oss-20b training on an RTX 4090".llama.cpp patch: backward passes for gpt-oss's mixture of experts
The experts stay frozen, so these are gradients into the activations only.
GGML_OP_OUT_PROD_ID: the input gradient ofMUL_MAT_ID.ADD_ID: the gradient passes through to the activations.SWIGLU_OAI: built from clamp, sigmoid, step and mul, in both the split and fused forms.GET_ROWS_BACK: now batched, on CPU and CUDA. gpt-oss uses it to pick each token's expert weights.packaging/llama-patches/tests/:gradtest.cppchecks each pass against central finite differences, and checks quantized experts against the same experts as f32.cudacmp.cppcompares GPU against CPU.Profiles (
models.json)qwen3-14bgpt-oss-20bbench/results/memory-qwen3-14b-4090-*.jsonandmemory-gpt-oss-20b-4090-*.json.Also
bench_llamanow resolves[gpu] layoutinstead of forcing the CPU.BENCH_CPU=1keeps the old behaviour. Before this, on a GPU it tried to build a 60 GB f32 copy of the 14B.Not in this PR
SSM_CONV,SOLVE_TRI,CUMSUMand more, plus training support for the recurrent cache.Test plan
make test-pascalgradtest.cppon the CPU: all checks passcudacmp.cppon an RTX 4090: f32, Q4_K, MXFP4 and Q8_0 experts match the CPUscripts-style chat,/sleep,/waitandbench_memory.py --trainer llamaGenerated by Claude Code