Repository navigation
πΊοΈ Roadmap: Hugging Face Ecosystem Full Compatibility (transformers / accelerate / peft / trl)Β #204
Copy link
Copy link
Open
Description
Goal
Make candle a drop-in PyTorch replacement for the entire HuggingFace ecosystem. Target:
USE_CANDLE=1 python -c "
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('gpt2')
model = AutoModelForCausalLM.from_pretrained('gpt2')
print(tokenizer.decode(model.generate(tokenizer('Hello', return_tensors='pt').input_ids, max_new_tokens=20)[0]))
"Priority follows the HF dependency chain: transformers (core) β accelerate β peft β trl.
Current State
| Capability | Status | Notes |
|---|---|---|
| nn.Module (state_dict, load_state_dict, hooks) | β Ready | Full implementation |
| nn modules (Linear, Conv, Norm, RNN, Attention, etc.) | β Ready | Comprehensive coverage |
| Optimizers & LR Schedulers | β Ready | Adam, AdamW, SGD, etc. with state_dict |
| AMP (autocast + GradScaler) | β Ready | Device-type dispatch |
| Serialization (save/load) | β Ready | PyTorch zip checkpoint format |
| scaled_dot_product_attention | No Flash/fused attention | |
| DataLoader + Samplers | β Ready | Multi-worker, pin_memory |
| Distributed (DDP, FSDP, collectives) | β Ready | Gloo + HCCL backends |
| torch.utils.checkpoint | β Exists | Needs HF integration validation |
| torch.library / custom_op | β Ready | 2-arg Library ctor only |
| compat/transformers test framework | β Ready | Tier 1-3 model test runner |
| Meta device / to_empty() | β Missing | Blocks low_cpu_mem_usage loading |
| Native safetensors loading | β In compat layer only | Not in src/candle/ |
| Text generation (GenerationMixin) | β Missing | No generate(), KV-cache, sampling |
| torch.compile / _dynamo | Blocks compiled model paths | |
| Quantization (GPTQ/AWQ/bitsandbytes) | β Stub only | quantize_per_tensor raises RuntimeError |
| PEFT (LoRA adapter injection) | β Untested | Module internals may work |
| Accelerate integration | β Untested | Low-level pieces exist |
Sub-Issues
Phase 1: Foundation (Target: v0.1.1 β June 2026)
- [Task][HF] 1.1: Meta device and Module.to_empty() implementationΒ #223 β 1.1 Meta device and
Module.to_empty()β€΄οΈ also vLLM [Task][vLLM] 1.3: Add meta/fake tensor supportΒ #237 - [Task][HF] 1.2: Native safetensors loading in candle sourceΒ #224 β 1.2 Native safetensors loading in candle source
- [Task][HF] 1.3: Promote torch submodule stubs from conftest to candle sourceΒ #225 β 1.3 Torch submodule stubs promoted to candle source
β€΄οΈ partial overlap with vLLM [Task][vLLM] 1.5: Make torch.compile(..., backend="eager") a valid no-opΒ #239 - [Task][HF] 1.4: Fix Library() 3-arg constructorΒ #226 β 1.4 Fix
Library()3-arg constructorβ€΄οΈ also vLLM [Task][vLLM] 1.1: Fix Library() 3-arg constructorΒ #235
Phase 2: HF-Compatible Inference (Target: v0.2.0 β September 2026)
- [Task][HF] 2.1: Text generation / GenerationMixin supportΒ #227 β 2.1 Text generation / GenerationMixin support
- [Task][HF] 2.2: SDPA optimization paths and attention mask handlingΒ #228 β 2.2 SDPA optimization paths and attention mask handling
- [Task][HF] 2.3: Gradient checkpointing integration with HF transformersΒ #229 β 2.3 Gradient checkpointing integration
β€΄οΈ also Megatron [Task][Megatron] 2.4: Validate activation checkpointing compatibilityΒ #258 - [Task][HF] 2.4: Run and baseline compat/transformers tier-1 reportΒ #230 β 2.4 Run and baseline compat/transformers tier-1 report
Phase 3: Training & Fine-Tuning (Target: v0.3.0 β December 2026)
- [Task][HF] 3.1: Accelerate Accelerator.prepare() compatibilityΒ #231 β 3.1 Accelerate
Accelerator.prepare()compatibility - [Task][HF] 3.2: Quantization foundation (bitsandbytes 4-bit/8-bit)Β #232 β 3.2 Quantization foundation (bitsandbytes 4-bit/8-bit)
- [Task][HF] 3.3: PEFT adapter injection compatibility (LoRA)Β #233 β 3.3 PEFT adapter injection compatibility
- [Task][HF] 3.4: TRL (Trainer/SFT/DPO) compatibilityΒ #234 β 3.4 TRL (Trainer/SFT/DPO) compatibility
Cross-Roadmap Duplicates
| Capability | HF | vLLM | Megatron | Notes |
|---|---|---|---|---|
| Meta device | #223 | #237 | β | Resolving one closes both |
| Library() 3-arg | #226 | #235 | β | Resolving one closes both |
| _dynamo / compiler stubs | #225 | #239 | β | Partial overlap; coordinate work |
| Activation checkpointing | #229 | β | #258 | HF = basic paths; Megatron adds selective recompute + RNG |
Success Criteria
- v0.1.1:
from transformers import AutoModel; model = AutoModel.from_pretrained("bert-base-uncased")works without compat conftest - v0.2.0:
model.generate()works for GPT-2/LLaMA-class models; tier-1 compat test pass rate β₯ 80% - v0.3.0: Fine-tuning with accelerate + PEFT LoRA works end-to-end
Metadata
Metadata
Assignees
Labels
No labels
Activity