Harden token-data ingestion across training pipelines (validation + FD hygiene)#30
Open
nabbilkhan wants to merge 2 commits intomaderix:mainfrom
Open
Conversation
dev-erik
added a commit
to dev-erik/ANE
that referenced
this pull request
Mar 4, 2026
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.
Why
I’m using this project for local Apple-device training workflows in healthcare IT, where keeping PHI on-device is a hard requirement. While running repeated training/restart cycles, I hit two practical reliability risks:
exec()-based restart loops could keep token-data file descriptors open longer than necessaryIn long-running jobs, these are the kinds of issues that can turn into hard-to-diagnose failures.
What this PR changes
1) Fail-fast token file layout validation in all training pipelines
Applied in:
training/train_large.mtraining/train_large_ane.mtraining/training_dynamic/train.mNew checks before training starts:
SEQ + 1[0, VOCAB)2) Prevent restart-time FD accumulation
After successful
mmap, each pipeline now immediately closesdata_fd.The mapping remains valid, and this avoids descriptor accumulation across repeated
exec()restarts.3) Shared helper + expanded unit tests
training/data_validation.h:token_data_bytes_to_token_count(...)training/test_data_validation.cfrom 8 to 18 tests, including:4) Documentation update
training/README.mdnow documents byte-alignment validation in the startup checks section.Validation performed
On Apple Silicon (macOS):
make test_data_validation && ./test_data_validation→ 18 passed, 0 failedmake train_large train_large_ane(cd training/training_dynamic && make train)Runtime negative-path checks across all three binaries:
Compatibility / scope
I’m an active contributor to OpenClaw and I’m excited to contribute back here as well. Thanks for building and open-sourcing this project.