Skip to content

v1.3.10

Choose a tag to compare

@github-actions github-actions released this 19 Jul 08:49
· 579 commits to main since this release

Storage / Dataset (major refactor)

  • Store composition: Store base + Streamable/Recordable mixins replace diamond inheritance. Removed RecordDataset, get_index, and all window/stride logic from Dataset layer
  • Store owns indexing: __getitem__/__len__/sample_window/token_count/num_samples live on Store. Dataset is a pure delegator binding Store to train-type key mapping
  • DatasetFactory._store_window_for**: record datasets (DPO/GRPO) force window_size=0 to prevent stream semantics
  • JsonlStore lazy mode: processor=fn keeps raw JSON records, defers tokenization to fetch_record — DPO/GRPO trains directly from .jsonl without pre-tokenization
  • TokenizeTransform: bridges raw JSON→tensors with shared preprocessing core (tokenizer + mask-builder + position-ids)
  • Preprocessing core.py: ~60% of Pipeline logic shared with TokenizeTransform via build_preprocessing_components, iter_raw_records, primary_ids, to_per_record_tensors
  • MmapStore: multi-shard support with per-record _offsets; docstring conforms to read-only memmap (mode="r")
  • segments_are_records class attribute differentiates H5/JSONL (per-record) from bin (opaque shards)

Training

  • MuonMix optimizer: Muon for 2D weight matrices, AdamW for 1D (bias/norm/embed/head). Inherits from torch.optim.Optimizer for proper scheduler interop. param_groups merged from both sub-optimizers
  • DPO: reduction="sum" (was mean); ref_model injected externally instead of created from model_fn; applies chat template during tokenization
  • GRPO: separates old policy (behaviour, synced externally) from ref model (frozen SFT checkpoint, KL term only). Token-level logprobs with prompt masking. Group-normalized advantages with unbiased std. No more sync_interval
  • --resume flag: decouples weight loading from checkpoint restoration (epoch, consumed_samples, optimizer & scheduler state). Trainer.train(param_path=, resume=)
  • Optional max_grad_norm: None disables clipping, logs raw grad norm instead
  • Distributed checkpoint: Executor.checkpoint_context() for coordinated multi-GPU save/load with rank0_only full state dict

Preprocessing

  • MultiOutputMaskBuilder: process_list_field returns per-element boundaries (list of lists) critical for GRPO [G, R] tensor construction. Adds "value" action section type for scalar rewards
  • bfd_split packing: plan_bfd exported as pure function; Best-Fit Decreasing on truncated sequence lengths with index-based bin plan so callbacks can apply same plan to aligned keys
  • Raw .json file support (not just JSONL) in Pipeline
  • StageBuilder: factored from Pipeline for reusable preprocessing stages

Inference

  • Frequency penalty: linear per-occurrence penalty scaled by penalty × count(token). rep_window limits history to sliding window. Wired through Task, Executor, sample() pipeline
  • write_positions: per-row positional write for ContiguousCacheView — fixes mixed-position decode in continuous batching (each task writes K/V at its own position)
  • StreamDecoder: buffers incomplete multi-byte tokens, emits text only after character is complete. Eliminates U+FFFD replacement characters in streaming output. decode_new_token() / flush_remaining() on Task
  • Merged decode batch: removed per-position group batching (pos_groups). All decode tasks run in a single execute_decode call — simpler, higher throughput
  • Greedy decode: temperature=0 short-circuits to logits.argmax(dim=-1) in SamplingPipeline.sample() and module-level sample(). GenerationRequest validates temperature >= 0
  • Simplified scheduler loop: StreamDecoder-based callbacks, removed per-iteration tokenizer decode call
  • InferenceEngine.generate() exposes frequency_penalty and rep_window parameters

CUDA kernels (csrc/)

  • HEAD_DIM=32 support added to all attention kernels
  • Paged decode CUDA kernel wired to Python extension via ops.py
  • Double-buffered KV pipeline + Q direct-to-register in decode MMA kernel (~1.27× on L20)
  • cp.async K/V loads + XOR swizzle + pre-scaled Q in both prefill and decode MMA kernels
  • Fused decode combine kernel: single-pass online-rescale reduction (halves expf calls)
  • Split-K (FlashDecoding) for decode MMA — fills idle SMs, 2.1–2.5× vs torch SDPA on low-parallelism workloads
  • Enlarged prefill KV tile to BC=32 for D≤128 (~6-8% faster)
  • Post-multiply attention scale in float (reduces causal max error 2⁻⁶ → 2⁻⁸)
  • Fast-math + vectorization nvcc/host build flags
  • Increased decode split-K parallelism for short sequences
  • Unified gqa_* → attn_* naming with _split_q / _split_kv / _mma strategy suffixes
  • Template AttentionParams, extracted shared MMA utils
  • Split extension into loader.py (.so discovery) + ops.py (wrapper + fallback with layout/mask/scale helpers)
  • Removed ineffective __launch_bounds__ from prefill kernel

Fixes

  • np.memmap opened mode="r" — prevents accidental data corruption from writes to disk-backed memory
  • Tool parser: _parse_tool_call_json uses json.loads instead of greedy regex with broken brace-stripping. Correctly handles nested object arguments, field-order-independent (no longer requires {"name": as first field)
  • Tokenizer __getattr__: guard for private attrs prevents infinite recursion during unpickle (spawn multiprocessing fix)
  • Resume: optimizer LR curve restores correctly; step display and consumed_samples alignment across checkpoint boundaries
  • DPO: chat template applied in tokenization; sequence logprob uses sum (not mean) reduction
  • GRPO: token-level ratio instead of sequence-level; prompt masking for correct response-only loss; unbiased std for group advantage normalization
  • Auto-assign free port in spawn_parallel_fn to avoid EADDRINUSE
  • System prompt handling made optional across scripts
  • Prefill mask index order corrected (batch×q_len×kv_len → batch×kv_len)
  • Support single .h5 file in load_h5
  • tqdm postfix set before first update so step 1 shows live metrics
  • MMLU: option permutation to handle answer position bias
  • IFEval: switched from raw URL download to HuggingFace datasets library

Tests

  • tests/data/test_dataset.py: +696 lines — JSONL lazy/eager, MmapStore edge cases, dual-mode H5Store, DPO/GRPO tokenization, Store composition tests
  • tests/inference/test_sample.py: +106 lines — frequency penalty scalar/tensor/batch/masked, temperature strategy
  • tests/trainer/test_grpo_strategy.py: +224 lines — shapes, reduction modes, 3D batch, no-reduction-param path
  • tests/data/test_preprocess_pipeline.py: +67 lines — pipeline end-to-end, edge cases
  • tests/data/test_preprocess_builder.py: MultiOutputMaskBuilder parity tests
  • tests/data/test_sampler.py: RDSampler tests
  • Standalone CUDA tests: attn_prefill_test.cu, attn_decode_test.cu, attn_paged_decode_test.cu
  • Benchmark for production MMA attention paths (FLOP/s + bandwidth)

Docs

  • Full sync of architecture.md, inference.md, dataflow.md, training.md, params.md, preprocessing.md to actual code
  • README / README-zh-CN install instructions updated
  • HuggingFace org from ViperEk to ViperEkura