Instructions to use domyn/Domyn-Edge-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use domyn/Domyn-Edge-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="domyn/Domyn-Edge-SFT", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("domyn/Domyn-Edge-SFT", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use domyn/Domyn-Edge-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "domyn/Domyn-Edge-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "domyn/Domyn-Edge-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/domyn/Domyn-Edge-SFT
- SGLang
How to use domyn/Domyn-Edge-SFT with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "domyn/Domyn-Edge-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "domyn/Domyn-Edge-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "domyn/Domyn-Edge-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "domyn/Domyn-Edge-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use domyn/Domyn-Edge-SFT with Docker Model Runner:
docker model run hf.co/domyn/Domyn-Edge-SFT
RoPE fp32 + gradient checkpointing + SDPA attention backend
Three fixes to modeling_domynedge.py. Default CUDA varlen path untouched (SDPA is opt-in): no GPU regression. Checks: CPU, tiny random config, no weights (torch 2.15).
1. RoPE precision β resolves the TODO in DomynEdgeRotaryEmbedding.forward
- Found: angles round to bf16 at large positions β under
autocast(bfloat16)the matmul runs bf16, and aftermodel.bfloat16()theinv_freqbuffer is bf16 (both noted in the TODO). - Why: cos/sin drift at long context. Real val rows (bf16): prob shift vs fp32 ~8% at <1k, ~53% at 4β8k; accuracy 53% β 27% at 4β8k.
- Fix: disable autocast, recompute
inv_freqin fp32 inforward(as the TODO proposes). - Proved: cos error at pos 7000 = 0.0 (fix) vs 2.0 (old).
2. Gradient checkpointing β supports_gradient_checkpointing was False
- Found: flag
Falseβgradient_checkpointing_enable()is a no-op. - Why: 16,384-token training needs ~161 GB of activations β won't fit one 141 GB GPU without recompute.
- Fix: layers are stateless β set flag, route layer loop through
_gradient_checkpointing_funcwhen training. - Proved: gradients identical to non-checkpointed (max diff 0.0).
3. SDPA attention β _supports_sdpa was False
- Found: attention hard-wired to CUDA
torch.nn.attention.varlen;attn_implementationignored, so no portable path. - Why: can't run without the flash/varlen kernel; no fp32-capable attention.
- Fix: opt-in
attn_implementation="sdpa"branch β same GQA + per-layer sliding window + padding mask viascaled_dot_product_attention; default path unchanged. - Proved: matches independent masked-attention reference to 1.5e-8; full forward runs on CPU with finite logits (impossible on varlen). GPU
varlen-vs-SDPA parity left to confirm on GPU.
Hardware
| before | after | |
|---|---|---|
| H200 / A100 (flash varlen) | β | β unchanged + gradient checkpointing |
| T4 / older GPU (no varlen) | β | β
sdpa |
| CPU | β | β
sdpa (separately tested) |
Thank you @deshwalmahesh for the PR, by pure coincidence, we had been working on the same fixes a few days earlier in the original Domyn Edge training repo https://github.com/DomynAI/domyn-forge/pull/12.
The problems with RoPE precision and SDPA attention should be fixed, while you are more than welcome to add support on Gradient Checkpointing! I will close this PR now, but feel free to open a PR on the original training repo: https://github.com/DomynAI/domyn-forge/