Views
No views yet
pip install torch transformers accelerate numpy rich1pip install flashinfer-python
2pip install sglang[all]
3pip install vllm[!WARNING] Selecting a non-Huggingface MoE backend is highly encouraged for faster generation. Note however that non-HF backends currently support a single GPU only, so you need to set e.g.export CUDA_VISIBLE_DEVICES=0before running the script. If you useflashinfer-python, JIT compilation the first time the code is run may take a while unlessflashinfer-jit-cacheis installed.
1from transformers import AutoTokenizer, AutoModelForMaskedLM
2
3# Load tokenizer
4tokenizer = AutoTokenizer.from_pretrained("radicalnumerics/RND1-Base-0910", trust_remote_code=True)
5
6# Load model
7model = AutoModelForMaskedLM.from_pretrained(
8 "radicalnumerics/RND1-Base-0910",
9 dtype="bfloat16",
10 device_map="auto",
11 trust_remote_code=True,
12 moe_backend="vllm", # hf, sglang, vllm, flashinfer
13)
14
15# Generate - Task mode (for instructions and questions)
16prompt = "Write a Python function that finds the longest common subsequence of two strings. Include comments explaining the algorithm."
17inputs = tokenizer(f"Question: {prompt}\nAnswer:", return_tensors="pt")
18input_ids = inputs.input_ids.to(model.device)
19
20# Generate
21output = model.generate(
22 inputs=input_ids,
23 max_new_tokens=256,
24 num_diffusion_steps=256,
25 temperature=0.01,
26)
27
28# Decode only the generated part
29text = tokenizer.decode(output[0], skip_special_tokens=True)
30print(text)max_new_tokens: Number of tokens to generate (default: 256)num_diffusion_steps: Diffusion denoising steps (default: 256)temperature: Sampling temperature, 0.0 for greedy (default: 0.0)top_k: Top-k filtering for samplingtop_p: Nucleus filtering for sampling1# Completion mode example
2prompt = "The key to understanding quantum computing lies in"
3inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
4output = model.generate(
5 inputs=inputs.input_ids,
6 max_new_tokens=256,
7 num_diffusion_steps=256,
8 temperature=0.01,
9)1# Task mode (default) - for instructions, questions, or requests
2python demo_rnd_generation.py --prompt "Write a Python function that finds the longest common subsequence of two strings. Include comments explaining the algorithm." --moe_backend hf
3
4# Completion mode - for text continuation
5python demo_rnd_generation.py --mode completion --prompt "The key to understanding quantum computing lies in" --moe_backend hf
6
7# Sampling parameters
8python demo_rnd_generation.py --top_k 50 --temperature 0.7 --prompt "Explain how neural networks learn in simple terms" --moe_backend hf@misc{rnd1-report,
title={Training Diffusion Language Models at Scale using Autoregressive Models},
author={Radical Numerics},
year={2025},
}