vllm_backend
vllm_backend
¶
vLLM-based generation backend for tabular data synthesis.
Classes:
| Name | Description |
|---|---|
VllmBackend |
Generation backend using vLLM for high-throughput inference. |
VllmBackend(config, model_metadata, workdir, **kwargs)
¶
Bases: GeneratorBackend
Generation backend using vLLM for high-throughput inference.
Loads the base model with a LoRA adapter via vLLM and generates synthetic records in batches. Supports optional structured generation (regex or JSON schema) to constrain outputs.
LoRARequest("lora", 1, str(adapter_path)) is passed to
llm.generate when an adapter is available. The vLLM engine uses
config.training.lora_r as max_lora_rank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SafeSynthesizerParameters
|
Pipeline configuration. |
required |
model_metadata
|
ModelMetadata
|
Model metadata (prompt template, adapter path, sequence length, etc.). |
required |
workdir
|
Workdir
|
Working directory containing the adapter and schema. |
required |
**kwargs
|
Additional options. |
{}
|
Methods:
| Name | Description |
|---|---|
teardown |
Release GPU memory and distributed resources. Idempotent -- safe to call multiple times. |
initialize |
Initialize and load the model into memory. |
prepare_params |
Parse parameters and configure the generation method. |
generate |
Generate synthetic tabular data in batches until the target count is reached. |
Source code in src/nemo_safe_synthesizer/generation/vllm_backend.py
teardown()
¶
Release GPU memory and distributed resources. Idempotent -- safe to call multiple times.
Source code in src/nemo_safe_synthesizer/generation/vllm_backend.py
initialize(**kwargs)
¶
Initialize and load the model into memory.
Creates the vLLM engine and then builds the record processor with the engine's tokenizer so that exact token counts are available during generation.
Source code in src/nemo_safe_synthesizer/generation/vllm_backend.py
prepare_params(**kwargs)
¶
Parse parameters and configure the generation method.
Parses a dictionary of parameters into SamplingParams, applying
necessary transformations from the Safe Synthesizer API to vLLM's API.
num_beams is mapped to beam_width only when greater than 1;
otherwise it is omitted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Sampling parameters to configure. |
{}
|
Source code in src/nemo_safe_synthesizer/generation/vllm_backend.py
generate(data_actions_fn=None)
¶
Generate synthetic tabular data in batches until the target count is reached.
Iterates over generation batches, applying the processor to each
LLM output, until the configured num_records target is met or
a stopping condition fires.
Non-tabular processors need BOS/EOS delimiters in the raw text, so
generation keeps special tokens for those processors and strips them
only for TabularDataProcessor. Native EOS stopping remains enabled
through ignore_eos=False.
Wrapped in an :class:NvmlPeakSampler context so a
generation-complete observability event is emitted at end of
the call carrying peak device VRAM, host loadavg pre/post, vLLM's
kv_cache_usage_perc / prefix_cache_hit_rate / spec_accept_rate
(read at end-of-generation), and the engine's effective runtime
config probed at engine-init time. Sampler is degraded-mode when
NVML is unavailable; the event still emits with peak_vram_gb=None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_actions_fn
|
DataActionsFn | None
|
Optional post-processing / validation function applied to each batch of generated records. |
None
|
Returns:
| Type | Description |
|---|---|
GenerateJobResults
|
Results containing the generated DataFrame and statistics. |