Add token-id LM training, CUDA defaults, and kernel launch hygiene#11
Open
wadkisson wants to merge 2 commits into
Open
Add token-id LM training, CUDA defaults, and kernel launch hygiene#11wadkisson wants to merge 2 commits into
wadkisson wants to merge 2 commits into
Conversation
Token-id causal LM API for persistent-module training; --cuda enables fast-kernels by default; noGrad for eval1NoGrad; clear stale CUDA errors before kernel launches.
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.
Summary
Three library changes
Part A — Token-id causal LM API
causalTransformerTokenLmScalarModuleDeffor float-encoded token-id inputscausalLmTokenRows,causalLmTokenFloatVec,causalLmTokenSampleRowsFromTokenArrayfloatVecToNatTensorop (Functional → Ops → TorchLean Functional → Trainer instances)Compile.leanandSpecEval.leanEnables persistent-module LM training: token windows can change each step without rebuilding the module or one-hot tensors (Adam state stays on one session). Matches PyTorch
nn.Embedding+cross_entropystructurally.Part B — CUDA CLI + inference
--cudaauto-enables--fast-kernels(fastKernels := fastKernels || useGpu)Options.noGrad;eval1NoGradsetsnoGrad := true--fast-kernelsMakes --cuda turn on fast kernels by default and fixes inference so eval1NoGrad runs without recording autograd state.
Part C — Native CUDA robustness
torchlean_cuda_clear_pending_errorandtorchlean_cuda_check_launchreduceMeanClears stale CUDA driver errors before kernel launches so unrelated failures don’t break TorchLean’s native kernels.