Repository navigation
Fit lenses on any commit-pinned Hugging Face dataset - #59
Merged
Merged
Conversation
lens fit could stream only the hard-coded FineWeb-Edu sample; any other corpus went through --corpus FILE, recorded as file:<name>, which drops the Hub pin. The default is now one instance of HfLensCorpus (repo, config, revision, text field), and --hf-corpus REPO[:CONFIG][@rev] [--text-field F] streams any other dataset the same way. - pin_lens_corpus resolves REV (default main) to its commit and an omitted CONFIG to the dataset's default at that commit. The CLI pins once per fit, so the no-op preflight and the stream read the same commit. - The recorded spec is hf:REPO/CONFIG@COMMIT;preprocess=1;doc_chars=4000, plus ;text_field=F off the default column. The default corpus keeps the exact spec its existing fits recorded, so their no-op preflight still holds. - Documents are the first N non-empty values of the train split, stripped and sliced as before. Null values are skipped like empty ones (they used to become the text "None"); a missing column or a non-text value is an error rather than an endless scan. A larger N therefore reads a superset prefix, and the existing token-id prefix resume tops a fit up; on a globally shuffled dataset such as dclm_100BT-shuffled that adds a nested random sample. - Every corpus read now runs in the spawned worker, not only the server's cancellable one, and the worker is terminated once it reports. After a stream stops early, pyarrow's I/O pool can block interpreter exit forever. An in-process read of dclm_100BT-shuffled returned in ~10 s and then hung at exit in 4 of 4 runs, as did a finished CLI fit; the FineWeb-Edu default exited in 4 of 4. - The server's lens fit preparation takes hf_corpus and text_field, parsed before the job starts. - stream_default_lens_corpus and resolved_default_lens_corpus_spec become stream_lens_corpus and pin_lens_corpus; sae train and its route call the new name with the default corpus.
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
drowse lens fitcould stream only the hard-codedHuggingFaceFW/fineweb-edusample-10BThead. Any other corpus had to go through--corpus FILE, which is recorded asfile:<name>and so drops the Hub pin. Larger, well-provenanced refits need other datasets, starting withHuggingFaceFW/dclm_100BT-shuffled. That dataset is globally shuffled, so its head is a random sample and growing a fit adds a nested one.Change
HfLensCorpus(drowse/io/lens.py) is a frozen(repo, config, revision, text_field). The default corpus is now just one instance of it, so the CLI, the server,sae trainand its route share one streaming path.--hf-corpus REPO[:CONFIG][@REV]and--text-field F(defaulttext) onlens fit.--hf-corpusand--corpusare mutually exclusive, and--text-fieldis rejected without--hf-corpus.REVmay be a branch, tag or commit; slashes are allowed, as inrefs/convert/parquet.pin_lens_corpusresolvesREV(defaultmain) to its commit and an omittedCONFIGto the dataset's default at that commit. The CLI pins once per fit, so the model-free no-op preflight and the stream read the same commit.hf:REPO/CONFIG@COMMIT;preprocess=1;doc_chars=4000, plus;text_field=Fwhen the text isn't intext. The default corpus produces exactly the spec its existing fits recorded, so their no-op preflight still holds."None". A missing column or a non-text value is an error instead of an endless scan. The read is prefix-stable, so a larger--promptstops a fit up through the existing token-id prefix resume. To grow a fit after the dataset has moved, pass the recorded commit asREV.fitpreparation takeshf_corpusandtext_field, parsed before the job starts, with a 400 when malformed. Pinning and streaming run in the cancellable worker.__cxa_finalize→arrow::internal::ThreadPool::~ThreadPool). An in-process read of dclm returned in ~10 s and then hung at exit in 4 of 4 runs, and so did a finished CLI fit. The FineWeb-Edu default onmainexited in 4 of 4, which is presumably why nobody had hit this. Without the fix, any script running fits in sequence would stall after the first.stream_default_lens_corpus→stream_lens_corpus,resolved_default_lens_corpus_spec→pin_lens_corpus.Tests
text_fieldsuffix; unpinned corpora refuse to name a spec; parsing round-trips and rejects malformed specs.LENS_DOC_CHARS; a missing field or a non-text value raises.text_fieldalone, gets a 400.Verification
default@2fa015e4…, and its first 6 documents extend its first 3 exactly, both in-process and through the worker.hf-internal-testing/tiny-random-LlamaForCausalLM, isolatedDROWSE_HOME): fit 3 dclm documents, then--prompts 6("resuming from 3 prompts (3 remaining)"), then--prompts 6again, which is a model-free no-op. Every run exits cleanly, andlens showreports the pinned dclm spec.pytest -m "not gpu": 3973 passed. The 2 failures are the browser affine-Fisher fixture and sampling-fixturecase2, the same Mac-numerics failures that Record the RelP policy in R-lens checkpoints and repair mislabelled ones #58 recorded on cleanmain. ruff and pyright are clean.Not in this PR
--hf-corpusplus weights, interleaved on a fixed schedule (smooth weighted round-robin). Document i's source would then not depend on N, the first N mixed documents would stay a prefix of the first M, and resume would still work; the spec would be something likemix:3*hf:…|1*hf:…. The harder part is the data. Most Chinese pretraining sets on the Hub are not globally shuffled; FineWeb-2cmn_Hani, for example, is ordered by dump and shard, so its head is a biased sample. A streaming shuffle buffer should be prefix-stable for a fixed seed, but I haven't verified that, and it would tie reproducibility to thedatasetsversion. The simplest route needs no code: publish one pre-shuffled bilingual mix and pin it with--hf-corpus.sae train --hf-corpus. It now shares the corpus path, so adding the flag would be small.