Skip to content

Add native Inkling 2 Mini attention LoRA training on a single DGX Spark - #6424

Draft
drisspg wants to merge 27 commits into
mainfrom
drisspg/inkling-native-spark
Draft

drisspg wants to merge 27 commits into
mainfrom
drisspg/inkling-native-spark

Conversation

@drisspg

@drisspg drisspg commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary (human-written)

Putting this up in draft for now; i was doing some lora tweak over the weekend and thought might be intersting for folks

Agent Notes

Why

Main has no native training path for the published Inkling 2 Mini checkpoint. This experiment fine-tunes its recurrent text backbone on one DGX Spark without expanding all experts to BF16 or introducing Inkling-specific logic into the core Trainer.

Before After
No Inkling recipe Use the recipe example with torchrun --standalone --nproc-per-node=1 --module torchtitan.train --module inkling_run --config spark --output-dir "$run".
Inference expects an HF checkpoint Export $run/merged-step-N with the trained query weights, original packed experts, tokenizer and drafter.

What changed

  • Share 24 layers across 48 visits and train rank-8 LoRA on their query projections, not the language head. Use FlexAttention with grouped-query heads, relative bias and learned sinks on CUDA.
  • Group routed tokens on device and decode NVFP4/MXFP8 tiles inside the expert forward and input-gradient kernels. Native grouped MM on the tested nightly does not return FP32 from BF16 inputs for the required scale epilogue.
  • Save native adapter and training state. Verify checkpoint and corpus contents on resume; keep the source snapshot separate from the run's native checkpoint directory.

Numerics / performance

One GB10, batch 1, 64 tokens, PyTorch 2.16.0.dev20261126+cu134. Across two runs per arm, median warm optimizer steps took 7.22–7.25 s for the eager prototype and 0.584–0.587 s for grouped experts + FlexAttention (12.35×). Peak reserved memory was 20.28 vs 19.99 GiB. FlexAttention changes BF16 rounding; first-step adapter gradient cosine versus eager was 0.672, not numerical parity.

On the same stratified UCI Car Evaluation split (1,382 train, 346 held out), seed 42, and learning rate 0.0002:

Checkpoint Held-out accuracy Macro F1 Four-choice log loss ↓
Published 69.94% 0.206 1.225
Eager LoRA 84.39% 0.420 0.444
Grouped + Flex LoRA 86.99% 0.659 0.282

Testing

  • python -m pytest -q torchtitan/experiments/inkling/tests: 45 passed on CPU/GB10, including gradients after inference, packed expert gradients, shared adapters, HF load, native checkpoint round-trip, and rejection of overlapping checkpoint paths.
  • The optimized training run completed 1,382 steps; the independent scorer evaluated the merged HF export on every held-out row. These are single-seed results, not evidence of improvement on other domains.
  • The earlier eager revision (e1169c116) matched the six-token reference exactly, resumed step 9 to 10 bit-for-bit on 192 adapter/optimizer tensors, and passed a 16-step WarpDrive decode on its merged export. Those are not exact-parity or final-SHA WarpDrive claims for the optimized CUDA path.

Self-review

Branch-mode review of f432f8c57..ae55c0580: approve for the documented single-Spark workflow. Manually symlinking native step-* directories from other runs is outside the tested workflow. Hosted CI has not run.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant