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.
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. |
Source code in src/nemo_safe_synthesizer/generation/vllm_backend.py
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | |