Skip to content

Latest commit

 

History

History
732 lines (593 loc) · 36.6 KB

training.md

File metadata and controls

732 lines (593 loc) · 36.6 KB

Training

SpecForge has one public training entry point for every strategy and runtime topology:

specforge train --config examples/configs/online/disaggregated/external/qwen3-8b-eagle3.yaml

The YAML file is the run contract. It selects the draft strategy, target model, data source, optimizer settings, and deployment topology. Method-specific Python trainers are not part of the public interface.

This is an intentional hard cutover. The old scripts/train_*.py commands and temporary move-only Python import paths were removed rather than deprecated. Downstream launchers should migrate to a typed run config and specforge train; there is no compatibility dispatch to the previous trainers.

Choose a recipe

The config catalog separates three concepts:

Question Config source Catalog level
Are target features captured during training or prepared earlier? data.train_data_path / data.prompts_path versus data.hidden_states_path online/ versus offline/
Does the trainer read offline hidden states files directly or consume refs from a producer? deployment.mode: local_colocated versus deployment.mode: disaggregated colocated/ versus disaggregated/
Who starts Mooncake and SGLang for online disaggregation? Presence of deployment.disaggregated.managed_local external/ versus managed-local/

The supported catalog layout is:

examples/configs/
├── offline/
│   ├── colocated/
│   └── disaggregated/
└── online/
    ├── colocated/                 # reserved; currently unsupported
    └── disaggregated/
        ├── external/
        └── managed-local/

external is an ownership boundary, not a statement that the services are on another machine. It is external when the user starts the server. managed-local owns those services on one host, while producer and consumer remain separate SpecForge roles. The runtime reads the YAML fields, not filename suffixes, to determine these semantics. See the complete recipe catalog for representative configs.

Launch a run

Use the command directly for every checked-in topology:

specforge train --config examples/configs/online/disaggregated/external/qwen3-8b-eagle3.yaml

deployment.trainer.nproc_per_node records the audited local process count. When it is greater than one, the CLI starts torch distributed itself:

specforge train -c examples/configs/online/disaggregated/external/qwen3-30b-a3b-eagle3.yaml

Online target inference never runs in the trainer. A SGLang server running the capture plugin owns target parallelism and publishes captured features through Mooncake; every consumer rank is data parallel. Offline runs shard fixed feature references across trainer ranks and may additionally use EAGLE3 USP. See Parallel topologies for the exact constraints.

Paths in a config are resolved from the current working directory. The example configs assume that the command is run from the repository root.

You can override an existing value without copying the YAML. Overrides use validated section.field=value syntax:

specforge train \
  --config examples/configs/online/disaggregated/external/qwen3-8b-eagle3.yaml \
  training.learning_rate=5e-5 \
  training.max_steps=100 \
  output_dir=./outputs/eagle3-smoke

Unknown config fields and unknown override paths are errors. This keeps a misspelled or retired option from being silently ignored.

Run config

A run config has seven typed sections (model, data, training, tracking, profiling, runtime, and deployment) plus run_id and output_dir:

draft: specforge/config/draft/presets/qwen3-8b-eagle3.yaml

model:
  target_model_path: Qwen/Qwen3-8B
  target_backend: sglang
  vocab_mapping_path: cache/vocab_mapping/qwen3-8b.pt
  torch_dtype: bfloat16

data:
  train_data_path: ./cache/dataset/sharegpt_train.jsonl
  max_length: 4096
  chat_template: qwen
  cache_dir: ./cache

training:
  num_epochs: 10
  max_steps: 10000
  batch_size: 1
  learning_rate: 1.0e-4
  save_interval: 1000

run_id: qwen3-8b-eagle3-disaggregated
output_dir: outputs/qwen3-8b-eagle3-disaggregated

deployment:
  mode: disaggregated
  trainer:
    nnodes: 1
    nproc_per_node: 1
  disaggregated:
    control_dir: outputs/qwen3-8b-eagle3-disaggregated/control
    consumer_state_dir: outputs/qwen3-8b-eagle3-disaggregated/consumer-state
    backend: mooncake
    server_urls:
      - http://127.0.0.1:30000
    mooncake_metadata_server: http://127.0.0.1:35880/metadata
    mooncake_master_server_addr: 127.0.0.1:35551

Draft configuration and model initialization

Use draft to provide a complete draft mapping or a YAML/JSON file. Presets in specforge/config/draft/presets/ use the same format. The target model and filename do not choose the draft architecture. Copy a preset and edit its component nodes and layer_types to change the model.

draft: specforge/config/draft/presets/qwen3-8b-dflash.yaml
training:
  attention_backend: flex_attention
  objective_options:
    num_anchors: 128
  loss:
    fused: true
    execution:
      chunk_size: 128
      checkpoint: true

Named attention_configs define GQA, MHA or MLA, including is_causal and sliding_window on each node. layer_configs composes attention and FFN nodes; layer_types selects the named layer for each position. Architecture settings live in spec_config. A checkpoint stores the expanded canonical configuration. There are no target-derived defaults or structural overrides in the run config.

See draft training for objectives, kernel options, sequence parallelism and checkpoint initialization.

DFlash2

DFlash2 is a draft-architecture variant of DFlash, not a separate capture protocol. Select it with a draft config whose architecture is DFlash2DraftModel; its default objective is dflash2. The target server still captures the same selected hidden states with --speculative-algorithm DFLASH. Online capture also retains the target's final hidden state for teacher-alignment telemetry; for existing offline DFlash datasets without final target states, set training.objective_options.teacher_metrics: false to omit teacher-only metrics. The loss does not require that hidden state. Set training.objective_options.teacher_metrics: false to stop requesting it: the capture server no longer writes it and the trainer no longer fetches it, which removes one hidden_size row per token from every sample (a sixth of the payload with five target layers). The run then omits dflash/teacher/* and dflash2/selector/self_conditioned_teacher_argmax_agreement; every other metric and the loss are unchanged. Other strategies reject the setting.

A canonical run (one with a draft config) does not request that hidden state unless training.objective_options.teacher_metrics: true is set; the default is false, and the same metrics are then omitted.

The DFlash2 config additionally defines conv_kernel_size and conv_group_size for the local convolution, plus selector_rank and selector_top_k for candidate-path selection. The base draft head uses the configured CE/LK/TV objective. The selector always uses categorical CE over the target head's strict unary top-k, exactly as it will be used during inference. If the gold token is outside that candidate set, the token contributes no selector loss; dflash/hard_label/unary_topK_recall reports how often the gold token is present. Both objectives receive the configured fixed-decay or D-PACE position weight, and their combined numerator is normalized by the sum of valid effective token weights rather than by batch or anchor count.

Set training.loss.terms.selector.coefficient to scale the selector objective. training.objective_options.selector_warmup_ratio keeps that scale at zero for an initial fraction of optimizer steps, and training.objective_options.selector_ramp_ratio then ramps it linearly to the configured value. Both schedule ratios default to zero. A configured alpha of zero disables selector training and freezes its parameters; a positive alpha keeps the selector in the optimizer and autograd graph even while its effective warmup weight is zero. The convolution starts from an identity kernel with a zero-initialized dynamic projection, and the selector starts as a unary no-op, so both additions initially preserve the corresponding DFlash computation.

Set training.objective_options.selector_stop_gradient: true to keep the selector CE from updating the unary logits and draft hidden states. The selector parameters still train, and the primary DFlash/D-PACE/LK objective keeps its normal draft gradient path. The option defaults to false, preserving coupled training.

External tracking reports DFlash-family diagnostics on optimizer steps that reach training.log_interval. Aggregates live under train/dflash/* and train/dflash2/selector/*. Per-position metrics live under position_1/* through position_<block_size-1>/*, without the train/ or algorithm prefix. Position 0 is the verified anchor and is omitted from token rates. K is the selector's selector_top_k, or metric_top_k (default 16) for plain DFlash.

Reading the acceptance metrics

The following metrics compare predictions to recorded hard labels on fixed training blocks. The greedy selector conditions on its own preceding choices within each block; the block still starts from the recorded prefix and anchor. These are training diagnostics, not measured serving acceptance at the eval sampling temperature, top-p, or top-K.

Metric Population and meaning
dflash/hard_label/unary_top1_accuracy Unary argmax matches, over all supervised slots; a marginal rate.
dflash/hard_label/unary_topK_recall Gold token is in the strict unary top-K, over all supervised slots.
dflash/hard_label/unary_probability, unary_topK_mass Full-softmax gold probability and mass assigned to the candidate set.
dflash2/selector/teacher_forced_covered_accuracy Selector argmax accuracy given a gold predecessor and gold in top-K; uniform over covered slots.
dflash2/selector/self_conditioned_marginal_accuracy Greedy selector matches over all supervised slots, including slots after an earlier error.
dflash2/selector/greedy_prefix_acceptance Accepted / reached slots on the greedy selector prefix. A slot is reached only when all earlier slots matched and the current slot is supervised.
position_<j>/selector/greedy_prefix_survival Fraction of valid blocks whose selector prefix matches through position j.
dflash2/selector/greedy_accepted_length Mean 1 + number of leading matches, including the anchor.

Unary greedy and top-K oracle paths have their own *_prefix_acceptance, *_prefix_survival, and *_accepted_length under dflash/hard_label/, with stems unary_greedy and unary_topK_oracle. Each path uses its own reached population. The oracle assumes the recorded gold token is always selected when it is in top-K; it is a candidate-coverage bound on these blocks, not a serving performance ceiling.

For each path, position_<j>/* also logs *_reached_count, *_accepted_count, and *_first_failure_count. Counts are summed across metric chunks, gradient-accumulation microbatches, and data-parallel ranks before forming any rate. They describe the optimizer window being logged, not all steps since the last log. Aggregate prefix rates use total accepted / total reached, rather than averaging per-position percentages.

To separate candidate misses from selector ranking errors on the same selector-reached prefixes, use:

  • dflash2/selector/greedy_prefix_unary_top1_accuracy and greedy_prefix_topK_recall: unary accuracy and candidate recall on that population.
  • greedy_prefix_covered_accuracy: selector matches / covered reached slots.
  • greedy_prefix_coverage_miss_rate: uncovered reached slots / reached slots.
  • greedy_prefix_ranking_error_rate: covered but incorrect slots / reached slots.

The last two rates plus greedy_prefix_acceptance sum to one whenever there are observations. Their per-position counts are greedy_covered_count, greedy_coverage_miss_count, and greedy_ranking_error_count in the selector section. A ratio with zero denominator logs zero by the trainer's existing convention; ignore it when the corresponding reached or covered count is zero, rather than treating it as measured 0% accuracy.

Chains stop at the first unsupervised slot. Padding, masked tails, and internal mask gaps are not model failures. dflash/hard_label/block_count counts blocks with at least one supervised prediction; per-position hard_label/supervised_count and hard_label/valid_prefix_count expose the raw mask and contiguous supervised prefix populations. dflash/hard_label/supervised_prefix_length is the mean maximum observable chain length including the anchor. This distinguishes a short supervision window from a short accepted prefix.

For each path, length is exactly 1 + sum_j survival_j (when block count is positive). With fully supervised blocks, survival is also the cumulative product of the conditional prefix rates. With masked tails, inspect the counts as well. Plot length and survival over optimizer steps first, then prefix acceptance and the coverage/ranking split at early versus late positions. Marginal accuracy alone cannot identify where the acceptance chain breaks.

Probability and objective diagnostics

  • dflash/hard_label/unary_gold_probability_chain_length is the smooth D-PACE surrogate 1 + sum_j prod_{i<=j} q_i(gold_i) on recorded labels.
  • dflash/teacher/unary_distribution_overlap is 1 - TV(q_unary, p_teacher) over the full-vocabulary softmax distributions, when target final hidden states are available. unary_overlap_chain_length chains these overlaps along the recorded blocks. Neither includes the final selector distribution or eval sampling filters. Unary top-1 teacher agreement and top-K teacher mass remain in this family.
  • dflash2/selector/self_conditioned_teacher_argmax_agreement compares the greedy selector to the target argmax at recorded prefixes.
  • dflash2/selector/loss is the weighted selector CE. Its gold probability is teacher_forced_covered_gold_probability, uniform over covered slots. dflash2/objective/weighted_covered_accuracy uses the selector loss weights; use the uniform accuracy metrics above for comparisons across objectives.
  • position_<j>/objective/loss_weight_share reports the effective fixed-decay or D-PACE objective weight per position. train/objective/lk_kl_weight is the CE weight of the lambda LK objective.

Dashboard migration and checkpoint alignment

The following old DFlash metric names are no longer emitted. Update existing panels; historical W&B rows are not renamed or deleted. Per-position variants follow the same changes.

Old name Replacement
expected_acceptance, dflash/hard_label/expected_acceptance target_probability or dflash/hard_label/unary_probability (duplicate aliases removed)
dflash/hard_label/expected_accepted_length dflash/hard_label/unary_gold_probability_chain_length
dflash/teacher/expected_acceptance dflash/teacher/unary_distribution_overlap
dflash/teacher/expected_accepted_length dflash/teacher/unary_overlap_chain_length
dflash2/selector/serving_accuracy dflash2/selector/self_conditioned_marginal_accuracy
dflash2/selector/conditional_accuracy dflash2/selector/teacher_forced_covered_accuracy
dflash2/selector/serving_accepted_length dflash2/selector/greedy_accepted_length
dflash2/selector/teacher_serving_agreement dflash2/selector/self_conditioned_teacher_argmax_agreement
selector_loss dflash2/selector/loss (duplicate removed)
selector_coverage dflash/hard_label/unary_topK_recall (duplicate removed)
selector_accuracy dflash2/objective/weighted_covered_accuracy
selector_target_probability dflash2/selector/teacher_forced_covered_gold_probability

The generic acc and target_probability remain available for lightweight logging and evaluation consumers. EAGLE3 and DSpark metric names are unchanged. Every tracker row now includes train/optimizer_step, supplied by the same controller counter used for checkpoints. Join external eval results by run ID and checkpoint optimizer step, not by a tracker's internal row index. An eval comparison must also record its dataset, target/draft revisions, block size, sampling settings, and whether acceptance length is proposal-weighted or a mean of per-request lengths; the training proxies above do not replace those measurements.

The exported computation and parameter names match the public SGLang DFlash2 contract, including optional output_multiplier and final_logit_softcapping transforms from dflash_config.

The checked-in Qwen3.6-27B recipe owns a two-GPU local stack: one configured GPU runs the target capture server and another runs the trainer. Update its model/data paths and cuda_visible_devices lists for the local host.

specforge train \
  -c examples/configs/online/disaggregated/managed-local/qwen3.6-27b-dflash2.yaml \
  model.target_model_path=/path/to/Qwen3.6-27B

Export for serving with specforge export --converter sglang. Serving requires an SGLang version that includes DFlash2 support (SGLang PR #35371); the serving algorithm name remains DFLASH, and the exported DFlash2DraftModel config enables the new path automatically.

See the dedicated DFlash2 guide for the complete model-field constraints, offline feature workflow, selector schedule, and serving compatibility boundary.

Choose checkpoint loading independently of the training objective:

Intent Config field Restored state
Continue a run resume draft, optimizer/scheduler, counters, data position and RNG
Start a run with the same draft initialization.checkpoint configuration and draft weights
Initialize a different draft draft plus initialization.weights_from explicitly mapped weights
Copy native target modules draft plus initialization.from_target explicitly mapped target weights

Initialization and resume are mutually exclusive. When loading a checkpoint, any supplied draft must equal its saved structure; use weights_from to change structure. Producers read only the capture/configuration contract; consumers load the draft weights and training state.

Set exactly one data source:

  • data.train_data_path for raw conversation or preformatted online data;
  • data.prompts_path for pre-tokenized online JSONL containing input_ids and loss_mask;
  • data.hidden_states_path for precomputed offline feature checkpoints.

The checked-in examples are the canonical starting points:

Strategy Category Config
EAGLE3 Online disaggregated, external qwen3-8b-eagle3.yaml
EAGLE3 Offline colocated qwen3-8b-eagle3.yaml
EAGLE3 Offline disaggregated qwen3-8b-eagle3.yaml
P-EAGLE Online disaggregated, external qwen3-8b-peagle.yaml
DFlash Online disaggregated, external qwen3-8b-dflash.yaml
DFlash Online disaggregated, managed-local qwen3-8b-dflash-1server-dp7.yaml
DFlash Offline colocated qwen3-8b-dflash.yaml
DFlash2 Online disaggregated, managed-local qwen3.6-27b-dflash2.yaml
Domino Online disaggregated, external qwen3-8b-domino.yaml
Domino Online disaggregated, managed-local qwen3-8b-domino-2server-dp2.yaml
Domino Offline colocated qwen3-8b-domino.yaml
DSpark Online disaggregated, external qwen3-4b-dspark.yaml
DSpark Offline colocated qwen3-4b-dspark.yaml
DFlash (Ascend) Online disaggregated, external qwen3.5-4b-dflash-npu.yaml
MTP (Ascend) Online disaggregated, managed-local qwen3.5-4b-mtp-npu.yaml

Online and offline data

Online training captures target features while the run is active. It uses little disk space but keeps target inference available during training. Offline training reads feature checkpoints generated ahead of time, so only the draft model must fit on the training GPUs at the cost of substantially more storage.

Mode Target during training Disk use Data config
Online External or managed-local SGLang capture server Low train_data_path or prompts_path
Offline Not loaded by the trainer High hidden_states_path

Prepare raw datasets and offline features as described in Data Preparation, then update the matching example YAML before launching it.

Supported combinations

The unified runtime supports text training in these combinations:

Strategy Online disaggregated Offline colocated Offline disaggregated
EAGLE3 Yes, consumer DP Yes, DP + USP Yes, consumer DP
DFlash/DFlash2 Yes, consumer DP Yes, DP Yes, consumer DP
Domino Yes, consumer DP Yes, DP Yes, consumer DP
DSpark Yes, consumer DP Yes, DP Yes, consumer DP
MTP Yes, consumer DP Yes, DP Yes, consumer DP
P-EAGLE Yes, consumer DP, batch size 1 No No

Unsupported combinations fail explicitly during config validation or run assembly. In particular:

  • VLM training, including Qwen2.5-VL, is not supported. The unified runtime currently accepts text inputs only;
  • online evaluation is not supported. Evaluation requires precomputed offline features through data.eval_hidden_states_path;
  • attention backends are strategy-specific: EAGLE3 accepts sdpa, flex_attention, fa, or offline usp; P-EAGLE requires flex_attention; DFlash, DFlash2, Domino, and DSpark accept eager, sdpa, or flex_attention; MTP accepts eager or sdpa;
  • P-EAGLE requires training.batch_size=1 and reuses EAGLE3's server capture schema;
  • offline feature training supports EAGLE3, DFlash, DFlash2, Domino, DSpark, and MTP;
  • every online run is disaggregated and uses model.target_backend=sglang; finite runs may omit both step fields so the producer can publish the exact optimizer horizon derived from the prepared prompt plan;
  • EAGLE3 offline colocated runs derive and cache a deterministic vocabulary mapping from the feature corpus when model.vocab_mapping_path is empty. EAGLE3 disaggregated runs require an explicit shared mapping so producer and consumer cannot derive different artifacts.

Step limits, LR/loss horizons, logging, saving, and Domino lambda decay are expressed in completed optimizer updates. Fixed datasets are validated to contain complete accumulation windows, and finite online plans do not train an incomplete final quantum. training.max_steps is a stop cap and, when set without training.total_steps, the fallback optimizer/loss schedule horizon. training.total_steps can describe a longer schedule, but does not by itself stop an online stream. When a finite online run omits both, the producer publishes the exact schedule horizon and the consumer trains to EOF.

Parallel topologies

The launcher creates every process group from the typed run config:

  • Online target TP/EP belongs to each external SGLang capture server, not the trainer. Online consumers keep training.tp_size and both SP sizes at 1; every trainer rank receives a disjoint feature stream.
  • Offline consumers also keep training.tp_size at 1. Without USP, every trainer rank receives a disjoint reference shard and participates as data parallelism.
  • EAGLE3 offline can set training.attention_backend: usp and choose training.sp_ulysses_size and training.sp_ring_size. Their product must be greater than one, USP currently uses training.batch_size: 1, and SP peers share one sequence while draft-DP groups receive disjoint references.

The world size must be divisible by training.sp_ulysses_size * training.sp_ring_size. Use a shared output_dir for multi-rank checkpoints.

Loader and profiling controls

data.dataloader_num_workers controls ordered background feature materialization. If omitted, the former trainer defaults are retained: EAGLE3/P-EAGLE use four workers and DFlash-family strategies use eight. Set it to zero for fully synchronous loading.

Enable a bounded, per-rank PyTorch trace without a separate profiler entry:

profiling:
  enabled: true
  start_step: 30
  num_steps: 4
  record_shapes: false

The window is expressed in completed optimizer steps, works across gradient accumulation and resume, and writes one trace per rank beneath output_dir. An active partial window is finalized when training stops or fails.

Evaluation and best checkpoints

Offline evaluation is configured through the same YAML:

data:
  hidden_states_path: ./cache/hidden_states/train
  eval_hidden_states_path: ./cache/hidden_states/eval

training:
  eval_interval: 100

The evaluation source and training.eval_interval must be set together. Online evaluation is not supported; setting data.eval_data_path fails config validation. Offline evaluation uses the same feature reader and collator as training and retains the final partial batch. Metrics are emitted under eval/*.

The default selection metric is eval/simulated_acc_len. An improvement writes a complete checkpoint and points <run_id>-best at it, even when training.save_interval is zero. <run_id>-latest continues to identify the newest complete checkpoint.

Compact offline teacher

Offline text EAGLE3 can project teacher targets in exact vocabulary chunks instead of materializing full-vocabulary fp32 logits:

training:
  loss:
    execution:
      teacher_chunk_size: 4096

This lowers peak memory without changing the teacher distribution, at the cost of additional projection passes. The option is intentionally rejected for online and non-EAGLE3 runs.

Experiment tracking

Console metrics remain available for every run. Select one optional external backend with the top-level tracking section:

tracking:
  report_to: tensorboard

Accepted values are none, wandb, tensorboard, swanlab, and mlflow. W&B, SwanLab, and MLflow have matching project/run fields in the typed schema; TensorBoard writes beneath output_dir/runs, and SwanLab writes beneath output_dir/swanlog. Optimization and evaluator metrics use train/* and eval/*; throughput and timing counters use the top-level perf/* namespace. Historical ploss*, acceptance_rate*, and target_probability names remain available alongside explicit kl_loss* or lk_loss*, ce_loss, and expected_acceptance* names.

CUDA, ROCm, and Ascend NPU

CUDA and ROCm runs use the same YAML and entry point. For ROCm, install the checked-in environment before installing SpecForge:

python -m pip install -r requirements-rocm.txt
python -m pip install -e . --no-deps
python -m pip install --no-deps "liger-kernel>=0.8.3,<0.9"

Use a model/backend combination supported by that PyTorch ROCm environment; HF + SDPA recipes are the portable baseline. PyTorch exposes ROCm devices through its torch.cuda API and distributed runs use NCCL. DFlash drafts use Liger RMSNorm/SwiGLU by default on CUDA and ROCm, which is why Liger is installed without dependencies above; set model.use_liger_kernel: false to use the native Qwen3 modules.

For Ascend, install the vendor-matched PyTorch and torch_npu packages first. The checked-in NPU recipes use an external NPU-compatible SGLang capture server and SDPA consumers. A four-device launch is:

export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3
export HCCL_CONNECT_TIMEOUT=7200
export HCCL_EXEC_TIMEOUT=7200
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True

specforge train -c examples/configs/online/disaggregated/external/qwen3.5-4b-dflash-npu.yaml

The unified launcher supplies rank, world-size, and rendezvous variables. The runtime selects the active device dynamically and uses HCCL when torch_npu is active.

Disaggregated roles

A single-node disaggregated config supervises the SpecForge producer and consumer with one command. This does not make the run colocated: the roles and their data-plane contract remain separate. For an external recipe, the command also does not start Mooncake or SGLang. Split deployments use the same config with --role producer or --role consumer; multi-node consumers add only --node-rank on each host. The optional examples/disagg/run_online.sh and run_offline.sh files are thin delegates, not topology wrappers. See the disaggregated training guide for external-service prerequisites, managed-local ownership, freshness rules, and both launch forms.

Checkpoints and resume

training.save_interval controls checkpoint frequency and training.max_checkpoints controls rotation. Checkpoints are written beneath output_dir. A completed trainer run always saves its final runtime checkpoint, even when save_interval is zero or the final step is not an interval boundary. The <run_id>-latest symlink resolves to the newest complete checkpoint.

Offline colocated runs restore draft weights, optimizer/scheduler, epoch/step/data position, and per-rank RNG. Offline disaggregated consumers have the same checkpoint contract. For an offline colocated run, override training.resume_from:

specforge train \
  --config examples/configs/offline/colocated/qwen3-8b-eagle3.yaml \
  training.resume_from=./outputs/qwen3-8b-eagle3-offline/qwen3-8b-eagle3-offline-latest

For a disaggregated offline resume, reuse the same manifest, feature store, and run id, then invoke specforge train -c run.yaml --role consumer with the checkpoint override; the producer never accepts a resume checkpoint.

Online disaggregated resume is intentionally consumer-only. Reuse the retained SQLite metadata DB, original channel/inboxes, Mooncake objects, and matching checkpoint; rank 0 verifies that the durable optimizer marker equals the checkpoint step, skips acknowledged refs, and requeues the unacknowledged tail. The producer itself is not restarted or resumed. Optimizer/FSDP checkpoints currently require the same trainer world size; control-plane ref redistribution does not imply optimizer-state resharding.

Training metrics are printed every training.log_interval steps and forwarded to the configured tracking backend.

Export a trained draft

Runtime checkpoints contain training state and are not serving model directories. Export the final checkpoint before loading it with SGLang or Transformers.

Canonical checkpoints carry their model configuration. Export them without a training YAML:

specforge export --converter sglang --checkpoint /path/to/checkpoint --output-dir ./serving
specforge export --checkpoint /path/to/checkpoint --output-dir ./hf-model

Only canonical checkpoints containing config.json are supported. HF exports now contain canonical configuration and bundled code for Transformers, and cannot be served directly by SGLang. Except for native merge-back, both formats omit bound target embeddings and LM heads; HF callers must bind target weights before running the model. Restore vocabulary mappings before export; export does not replace checkpoint tensors.

SGLang conversion supports DFlash, DFlash2, Domino, DSpark, EAGLE3 and native dense Qwen3.5 MTP within the pinned serving format's representable structures. DSpine, DMTP and P-EAGLE require SGLang implementations before they can be exported. Mixed causality supports causal sliding layers with bidirectional full layers. See draft export for restrictions and validation.

Export preserves tensor values and dtypes. HF uses dtype="auto" to load the saved precision when tensors share one floating-point dtype; SGLang casts to its serving dtype. Mixed-dtype HF artifacts retain the original tensors, but public loading requires an explicit dtype; SGLang export rejects mixed dtypes.

MTP checkpoints trained before the #1014 fix (2026-11-09) used different RoPE and attention computations. Do not resume those runs; retrain from native MTP weights under the corrected model. A historical draft checkpoint is imported only after conversion with scripts/convert_legacy_checkpoint.py.

For native MTP, use the ordinary YAML preset and explicit target mapping in the preset guide. A complete text-only offline recipe is available at examples/configs/offline/colocated/qwen3.5-4b-native-mtp.yaml.

specforge export --export-mode native \
  --checkpoint ./outputs/native-mtp/native-mtp-latest \
  --target-model Qwen/Qwen3.5-4B \
  --output-dir ./exports/Qwen3.5-4B-MTP

Native export rewrites shards containing old MTP tensors and links unchanged shards; add --copy-target for a self-contained directory. A historical checkpoint must be converted to the canonical format first. Target computation mismatches fail instead of rewriting the target's settings to fit a draft.

The MTP trainer uses the composed model and canonical objective. Set training.objective_options.objective_chunk_size (default 4096; 0 disables chunking) to bound the token positions passed through the LM head and loss at once. Chunked training recomputes these intermediates during backward. The online NPU MTP recipe uses this path and the native preset.

All training now uses canonical draft configuration. EAGLE3 supports cached FlashAttention and Ulysses/Ring sequence parallelism; trainer tensor parallelism remains unsupported. See objective and backend options. The old model implementations and training wrappers have been removed.

Historical draft checkpoints and configuration formats are no longer accepted. Convert an old checkpoint's weights with scripts/convert_legacy_checkpoint.py (see checkpoint boundary) and import them through initialization.checkpoint. Use canonical presets or inline canonical configurations for new training.

Troubleshooting

Late OOM or non-finite hidden states on online runs

Symptoms. An online job starts cleanly, then fails well into training with a CUDA OOM that reports a large "reserved but unallocated" pool and only a few MiB free (for example, unable to serve a 388 MiB request with 58.3 GiB reserved and 34 MiB free). The same fragmentation can also surface first as non-finite target hidden states or as an anchor-sampling error that names the data rather than the allocator.

Cause. Online training feeds the draft one micro-batch per step whose rows vary in length, so the caching allocator is asked for a differently sized block almost every step. Without expandable segments, reserved-but-unallocated memory accumulates until a modest allocation fails.

Fix. Enable expandable segments before launch:

export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True

Set this before chasing data or numeric bugs that match the symptoms above. The Ascend equivalent (PYTORCH_NPU_ALLOC_CONF) is already set in the NPU recipes earlier in this page.