Skip to content

Inference with vLLM

Insert projected scientific vectors into prompt embeddings and generate with vLLM.

The serving path inserts projected scientific vectors into a language model’s full templated prompt embeddings and sends them to vLLM through prompt_embeds at /v1/completions. Scientific features and projection are prepared in the client; the language-model service generates the answer.

Start the language-model service

Install vLLM in a compatible inference environment. Run it on suitable GPUs and set tensor parallelism for that model and hardware. This command shows an eight-way deployment example:

vllm serve /path/to/matching-base-model \
  --served-model-name sage-sciperception \
  --enable-prompt-embeds \
  --tensor-parallel-size 8 \
  --generation-config vllm \
  --max-model-len 8192 \
  --host 127.0.0.1 --port 8000
Use the exact snapshot the checkpoint declares

Serve the language-model snapshot named in the selected checkpoint’s config.json. A different snapshot changes the embedding table the client reads from.

Generate from prepared crystal features

The crystal client renders the checkpoint’s native chat template, looks up text embeddings, inserts scientific vectors, and sends the completed prompt embeddings to the server.

Prepare cif_features.pt as a tensor of shape [num_atoms, 64], containing the real CHGNet 0.3.0 atom states specified in cif/jarvis, in atom order. Once the server is ready, run:

python -m pip install --upgrade transformers
python examples/vllm_cif.py \
  --component ./checkpoints/projectors/glm-5.3-flash/cif/jarvis \
  --base-model /path/to/matching-base-model \
  --features /path/to/cif_features.pt \
  --api-base http://127.0.0.1:8000/v1 \
  --model sage-sciperception

The local language-model directory supplies the tokenizer, configuration, and sharded input embedding table used by the server. The client reads the needed text embedding rows without loading the full language model.

Other tasks

Scientific feature extraction and task-adapted scientific models are separate dependencies; some adapted scientific weights are not yet included in the release. Match each task’s scientific_inputs before preparing predictions. The crystal example starts from prepared features, while other tasks require their corresponding input preparation and prompt assembly.

For a second worked path, including feature extraction from raw signals, see the NEU06 example.

References