Repository navigation
Conversation
The base forward ran under an unconditional torch.no_grad(), so dflash_freeze_base_model=False was silently inert. convert() honours the flag on the parameters -- requires_grad stays True -- but with no autograd graph built, nothing ever reaches them. The base sits at its initial weights for the entire run while every surface reports it as trainable. It is a quiet failure. There is no error and no warning; the only symptom is a base-model loss that does not move, which is easy to read as a bad learning rate or a hard dataset. It surfaced here as a co-training experiment whose "unfrozen" arm held a perfectly flat cross-entropy while its control arm descended normally -- which looked like a result about co-training rather than a bug. The context is now chosen from the flag. The other no_grad blocks in this file are deliberate and untouched: the D-PACE weighting is detached by design (paper Eq.9) and the accuracy computation is a metric. Training with the base unfrozen now also costs the activation memory that implies, which is the expected consequence of the flag doing what it says. Testing: two tests in tests/unit/torch/speculative/plugins/test_hf_dflash.py -- the frozen default builds no graph, and the unfrozen case builds one and receives a non-zero gradient on the base parameters after backward. Verified the pair catches the bug: with the fix 2 passed; with the base forward reverted to the unconditional no_grad, the unfrozen test fails on the grad_fn assertion and the frozen one still passes. Run on aarch64 with torch 2.13 and transformers 5.12.1. pre-commit clean on all three files. Signed-off-by: Ye Yu <[email protected]>
With dflash_freeze_base_model=False the only gradient reaching the base comes from the draft objective. Nothing holds it to language modelling, so the base drifts toward whatever is easiest to draft rather than toward predicting text -- which makes "co-training" a misnomer: it is really optimising a base for draftability and watching it degrade. dflash_base_lm_loss_alpha adds a cross-entropy on the base's own next-token prediction, weighted and added to the draft loss. Default 0.0, so the existing objective is unchanged for everyone not asking for it. Both preconditions are checked rather than silently ignored, because a term that quietly contributes nothing is the failure mode this area already had: a non-zero weight on a frozen base raises at convert time (no graph, no gradient), and a missing labels tensor raises at forward rather than skipping the anchor. The causal shift is done here rather than assumed: DFlash's data module builds labels unshifted (shift_labels=not is_dflash). Testing: 6 tests in tests/unit/torch/speculative/plugins/test_hf_dflash.py -- the default leaves the loss untouched, a non-zero weight both changes the loss and delivers non-zero gradient to base parameters, a frozen base is refused at convert, and missing labels are refused at forward. pre-commit clean. Signed-off-by: Ye Yu <[email protected]>
The online data path renders conversations through a chat template, so a pretraining corpus cannot be expressed at all: raw documents have no conversation structure, and wrapping them in pseudo-turns would insert chat tokens into the text and, with answer_only_loss, mask most of it away. That left co-training a base alongside a drafter reachable only on chat data. data.packed_data_path takes a datasets.save_to_disk directory of fixed-length pre-tokenized blocks and derives the new "packed" mode the same way the existing modes are derived -- from which data-source field is set, never from an incoming mode value. Packing deliberately stays outside this library: it is expensive, it has to be byte-identical across runs being compared, and tokenizer policy is not this library's to own. The collator is a stack, since the blocks are already fixed-length and tokenized. labels defaults to input_ids because for causal LM the shift belongs to the loss, and the DFlash path shifts there (shift_labels=not is_dflash). main.py previously derived use_offline_training as "mode != online", which would have classified packed as offline and loaded the fake base meant for pre-dumped hidden states -- training against a model that is not there, with nothing saying so. packed is an online path with a different data source and is now treated as one. Testing: 11 tests in tests/unit/torch/speculative/plugins/test_hf_dflash.py -- mode derivation and its ambiguity check, the collator stacking blocks, defaulting labels, honouring explicit labels, truncating to train_len, rejecting rows without input_ids, and a guard that packed is not classified as offline. pre-commit clean on all six files. Signed-off-by: Ye Yu <[email protected]>
Extend the packed data path from PR NVIDIA#2826 to read Falconer safetensors and preserve binary supervision masks in online and streaming training. Signed-off-by: Andrii Skliar <[email protected]>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
This branch has not been deployed
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.
What does this PR do?
Type of change: New feature.
Fourth PR in the stack. Merge #2692, then #2824, then #2826, then this PR.
This draft targets
mainbecause the parent branch exists only in another fork.The first three commits belong to the parent PRs.
Review the additional changes in this comparison.
The branch needs a rebase after #2826 merges.
Falconer stores pre-tokenized conversations in safetensors shards with token IDs, binary loss masks, and sample offsets.
The packed-data path in #2826 reads Hugging Face datasets and does not preserve a separate loss-mask column.
This PR extends
data.packed_data_pathto read Falconer shards and preserve supplied loss masks.The same source can supply online training or streaming hidden-state capture.
Existing Hugging Face packed datasets remain supported.
Summary
Usage
For streaming training, also set the serving endpoint and model name:
Each shard contains flat
input_idsandloss_masktensors.The
offsetstensor contains one more entry than the sample count.Each adjacent offset pair selects one sample.
A Falconer manifest controls shard order when present.
Mask value
1enables supervision; value0excludes the token from supervision.Testing
The tests replace the streaming fetch operation.
They do not verify vLLM, NIXL, RDMA, distributed training, full-model quality, or representative dataset performance.
Evidence
loss_maskcolumn.Merge Danger
Door: two-way. Reverting the commit restores the parent data paths without modifying datasets.
Blast Radius: training-data loading and batch creation for packed inputs.
Before your PR is "Ready for review"
CONTRIBUTING.md?: No new dependencies.CHANGELOG.rst?: Yes.Additional Information
Parent: #2826
Prepared against parent head
6f692296abc82c2f1d646f164f61d2491422ff45.Relative to #2826, this follow-up adds 238 production source lines across 11 changed files, including tests and documentation.