Views
No views yet
/data/sjm/... checkout.Qwen/Qwen3-4B and
z-lab/Qwen3-4B-DFlash-b16.1git clone https://huggingface.co/jiamingshan/qwen3-4b-dflash-official100k-recipe
2cd qwen3-4b-dflash-official100k-recipe
3
4python3 -m venv .venv
5source .venv/bin/activate
6pip install -U pip
7pip install -r requirements-train.txt
8
9# Only needed if your machine is not already logged in.
10huggingface-cli login
11
12./00_check_env.sh
13./01_download_data.sh
14
15# Train Qwen E2E+DFlash.
16./10_train_e2e.sh
17
18# Train Qwen frozen+DFlash.
19./20_train_frozen.shoutputs/<run_id>/checkpoints/step_0020001python3 -m venv .venv-vllm
2source .venv-vllm/bin/activate
3pip install -U pip
4pip install -r requirements-eval.txt
5
6./30_eval_gsm8k_table.sh \
7 outputs/<frozen_run_id>/checkpoints/step_002000 \
8 outputs/<e2e_run_id>/checkpoints/step_002000requested_gsm8k_table.md1TARGET_NAME_OR_PATH=Qwen/Qwen3-4B
2DRAFT_NAME_OR_PATH=z-lab/Qwen3-4B-DFlash-b16
3DATA_PATH=data/qwen3_dflash_official100k_prepared
4STEPS=2000
5WORLD_SIZE=8
6GRADIENT_ACCUMULATION_STEPS=3
7EFFECTIVE_GLOBAL_BATCH=24
8SAMPLES_SEEN=48000
9MAX_SEQ_LEN=3072
10MAX_ANCHORS=512
11ANCHOR_BATCH_SIZE=512
12GAMMA=7
13LOSS_NORMALIZATION=weighted1FREEZE_TARGET_ALL=0
2FREEZE_TARGET_UNUSED_TAIL=0
3LR_DRAFT=1e-4
4LR_TARGET=2e-6
5DFLASH_LOSS_WEIGHT=1.0
6LM_LOSS_WEIGHT=1.0
7KL_LOSS_WEIGHT=0.0
8FEATURE_ANCHOR_LOSS_WEIGHT=0.0
9EOS_LOSS_WEIGHT=0.0dflash_loss + lm_loss1FREEZE_TARGET_ALL=1
2LR_DRAFT=1e-4
3LR_TARGET=0
4DFLASH_LOSS_WEIGHT=1.0
5LM_LOSS_WEIGHT=0.0
6KL_LOSS_WEIGHT=0.0
7FEATURE_ANCHOR_LOSS_WEIGHT=0.0
8EOS_LOSS_WEIGHT=0.0dflash_lossdflash_loss is the DFlash weighted cross-entropy objective over static draft
targets from the prepared data. It uses gamma=7 and
loss_normalization=weighted.lm_loss is next-token cross entropy from the trainable target's own
lm_head, computed over loss_mask[:, 1:] from the same target forward pass
that supplies DFlash hidden features.| Metric | Qwen target | Qwen target + zlab-official DFlash | Qwen frozen+DFlash | Qwen E2E+DFlash |
|---|---|---|---|---|
| Accuracy | 1220/1319 = 0.9249 | 1209/1319 = 0.9166 | 1211/1319 = 0.9181 | 1207/1319 = 0.9151 |
| Mean tok/s | 141.82 | 672.98 | 687.82 | 687.48 |
| Mean accept | n/a | 6.222 | 6.324 | 6.345 |
Mean tok/s is mean single-shard throughput across 8 one-GPU shards. The
aggregate 8-shard throughput is also stored in each eval run's
aggregate_summary.json, but it is not the value in this table.src/train/train_joint_target_dflash.py: self-contained training script.third_party/dflash-official: DFlash draft model code needed by training.third_party/speculators: attention helpers used by the DFlash objective.src/eval: GSM8K prompt, scoring, vLLM benchmark, acceptance parsing, and
sharded aggregation scripts.recipe.json: machine-readable recipe summary.