Run this model with HF Jobs
Run physicsrob/torchwright-calculator-simple-max-digits-9 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/physicsrob/torchwright-calculator-simple-max-digits-9. Ask me which dataset to train on, then push the LoRA adapter to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs and Transformers to run batch inference with https://huggingface.co/physicsrob/torchwright-calculator-simple-max-digits-9 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the predictions back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs and Lighteval to evaluate https://huggingface.co/physicsrob/torchwright-calculator-simple-max-digits-9. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/physicsrob/torchwright-calculator-simple-max-digits-9 with Transformers and bitsandbytes. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use physicsrob/torchwright-calculator-simple-max-digits-9 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use physicsrob/torchwright-calculator-simple-max-digits-9 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="physicsrob/torchwright-calculator-simple-max-digits-9")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("physicsrob/torchwright-calculator-simple-max-digits-9") model = AutoModelForCausalLM.from_pretrained("physicsrob/torchwright-calculator-simple-max-digits-9", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use physicsrob/torchwright-calculator-simple-max-digits-9 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "physicsrob/torchwright-calculator-simple-max-digits-9" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "physicsrob/torchwright-calculator-simple-max-digits-9", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/physicsrob/torchwright-calculator-simple-max-digits-9
- SGLang
How to use physicsrob/torchwright-calculator-simple-max-digits-9 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 "physicsrob/torchwright-calculator-simple-max-digits-9" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "physicsrob/torchwright-calculator-simple-max-digits-9", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "physicsrob/torchwright-calculator-simple-max-digits-9" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "physicsrob/torchwright-calculator-simple-max-digits-9", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use physicsrob/torchwright-calculator-simple-max-digits-9 with Docker Model Runner:
docker model run hf.co/physicsrob/torchwright-calculator-simple-max-digits-9
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("physicsrob/torchwright-calculator-simple-max-digits-9")
model = AutoModelForCausalLM.from_pretrained("physicsrob/torchwright-calculator-simple-max-digits-9", device_map="auto")
calculator_simple, max_digits=9 (torchwright)
A compiled transformer: the
torchwright compiler emitted
these weights directly from a computation graph β nothing was trained. This
bundle is the calculator_simple example built with max_digits=9: a computation graph for integer arithmetic (A op B with op in + - *).
The bundle uses the stock Phi-3 architecture and loads through transformers
without custom model code or trust_remote_code.
Run it in fp32 with greedy decoding (do_sample=False). Other
precisions and decoding modes are outside the supported contract.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
repo_id = 'physicsrob/torchwright-calculator-simple-max-digits-9'
model = AutoModelForCausalLM.from_pretrained(repo_id).eval()
tok = AutoTokenizer.from_pretrained(repo_id)
enc = tok('12*34\n', return_tensors="pt")
out = model.generate(enc["input_ids"], max_new_tokens=32, do_sample=False,
eos_token_id=tok.eos_token_id, pad_token_id=tok.eos_token_id)
print(tok.decode(out[0, enc["input_ids"].shape[1]:], skip_special_tokens=True))
Input and output
Prompts are A op B terminated by a newline: two non-negative decimal
operands of up to 9 digits, with op one of +, -, *.
Subtraction may produce a negative result. Wider operands, or any character
outside the model's small vocabulary, are outside the contract β the output
is undefined.
| prompt | output |
|---|---|
12*34 |
408 |
7+8 |
15 |
999999999*999999999 |
999999998000000001 |
999999999+1 |
1000000000 |
999999999-123456789 |
876543210 |
123456789-999999999 |
-876543210 |
Intended use and limitations
This model is a demonstration of a computation graph compiled into transformer weights. It is not a general language model or a general-purpose calculator; only the input contract above is supported.
Verification
The examples above are exact reference outputs. The Modal publishing path
reloads the emitted checkpoint through stock transformers, checks those
examples plus additional width-limit cases against Python integer arithmetic,
and refuses to upload on a mismatch. This is a functional smoke test, not
exhaustive verification of every allowed expression.
Size
The checkpoint stores 93.54 GB of dense fp32 weights (23,384,571,904 entries) at compile width d=8192. 100.00% of those entries are exactly zero: the vast majority of the model is unused canvas, so size reflects the compile geometry rather than stored knowledge.
The zero entries are not compressed, and dense transformers execution still
pays their memory and compute cost. CPU execution is supported; allow
additional RAM beyond the checkpoint size.
Family
One example of many compiled with torchwright. Calculator siblings β
calculator-simple (serial arithmetic, depth grows with the digit count),
calculator-advanced (carry-lookahead, near-flat depth),
calculator-scratchpad (flat depth; the serial work streams out as visible
thinking tokens), and calculator-memorize (no arithmetic at all: a fact
table, exponential in the digit count) β are published at several digit
widths. Browse the
torchwright calculator models
on Hugging Face.
- Downloads last month
- 14
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="physicsrob/torchwright-calculator-simple-max-digits-9")