Skip to content

Complete TinyInfiniTrain homework (EnzoDing-rgb) - #12

Open
EnzoDing-rgb wants to merge 2 commits into
InfiniTensor:masterfrom
EnzoDing-rgb:master
Open

Complete TinyInfiniTrain homework (EnzoDing-rgb)#12
EnzoDing-rgb wants to merge 2 commits into
InfiniTensor:masterfrom
EnzoDing-rgb:master

Conversation

@EnzoDing-rgb

Copy link
Copy Markdown

Summary

  • Implement dispatcher Call/Register, Neg autograd, Matmul/Adam (CPU+CUDA), Tensor Flatten/Backward, Shakespeare dataset and tokenizer.
  • Replace std::format with JoinDot for g++11 compatibility.
  • Unit tests (dispatcher/elementwise/matmul/adam/tensor, CPU+CUDA) pass; GPT2 LogitsConsistency still under investigation.

Test plan

  • test_dispatcher / test_elementwise / test_matmul / test_matmul_cuda / test_adam / test_adam_cuda / test_tensor
  • test_gpt2 LogitsConsistency

Made with Cursor

EnzoDing-rgb and others added 2 commits August 12, 2026 23:21
Implement dispatcher Call/Register, Neg autograd, Matmul/Adam CPU+CUDA,
Tensor Flatten/Backward, Shakespeare dataset and tokenizer; replace
std::format with JoinDot for g++11 compatibility.

Co-authored-by: Cursor <cursoragent@cursor.com>
…tics)

The dataset previously used stride-1 overlapping windows (sample idx offset by
one token), so every training batch saw tokens[idx : idx+seq_len]. Tiny
Shakespeare data is produced by karpathy/llm.c's tinyshakespeare.py, which
uses non-overlapping windows: sample idx covers tokens[idx*seq_len :
(idx+1)*seq_len]. This made the GPT-2 training data differ from the reference
run that generated gpt2_logits_reference.bin, so LogitsConsistency failed by a
large margin (logits off by 10-270). With the correct windowing the test
passes on CUDA within the 1e-3 tolerance.

- num_samples = num_toks / sequence_length (was num_toks - sequence_length)
- sequence_size_in_bytes_ = sequence_length * sizeof(int64_t) (was sizeof(int64_t))

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant