Synthetic Data Pipeline
Synthetic Data Pipeline - How to connect a simulator to Tensorleap and let the automatic loop calibrate it against your real data
Tensorleap can drive your simulator directly. You register a simulation function in the integration script, select a target distribution of real samples in the UI, and the platform runs an automatic calibration loop: it generates samples, embeds them in the model's latent space, measures how far they are from the target, and proposes new simulation parameters, bringing the generated data closer to your real data with each round until it finds the best match.
The outcome is a calibrated set of synthetic samples added to your dataset, the simulation recipe that produced them, and a comparison view of synthetic versus real data on the dashboard.
For the motivation behind this capability see Synthetic Data Optimization.
How the loop works
┌───────────────┐
┌─────►│ parameters │
│ └───────┬───────┘
│ ▼
│ ┌───────────────┐
│ │ simulation │
│ └───────┬───────┘
│ ▼
│ ┌───────────────┐
│ │ embed │
│ └───────┬───────┘
│ ▼
┌─────┴─────┐ ┌───────────────┐
│ optimizer │◄┤ compare to │
└───────────┘ │ target │
not yet └───────┬───────┘
│ best match found
▼
best samples addedTensorleap calls your simulation with new parameters, embeds the samples with your model, compares them to the target distribution, and repeats until it finds the parameters that best match the target. Samples from the best trials are then added to the dataset as additional data, with a comparison filter for the dashboard.
When you select more than one simulation, the loop also learns the mixing ratio between them.
Prerequisites
The project uses string sample ids in its preprocess response. Projects with integer sample ids are not supported.
The model version has been evaluated. The loop reuses the latent space built during evaluation.
The integration script declares at least one simulation with
@tensorleap_simulationand the integration test passes.
Writing a simulation function
A simulation is a function decorated with @tensorleap_simulation. It receives one value per simulation parameter plus N and seed, generates N samples, and returns them as a PreprocessResponse.
Declaring the parameter space
sim_params lists each parameter with its type, float, int or str, and its bounds: min and max for numbers, values for strings. The optimizer searches inside these bounds, so keep them to the range your simulator supports.
Rules the function must follow
Nis chosen by the platform.Two calls with the same parameters and
seedmust produce the same samples. The platform checks this on push.The response must contain at least one sample and must not use grouped sample ids.
You may return fewer than N samples when the simulator cannot satisfy a request. The platform records the shortfall; see Errors and warnings for the limits.
Several simulations
Register as many simulations as you need, each with its own parameter space. In the UI you choose which of them take part in a run, and the loop calibrates their parameters and their mixing ratio together.
Testing the simulation locally
Call every simulation from the integration test and push its output through your input encoders. Use keyword arguments; positional calls are rejected.
The integration-test status table gains a row named tensorleap simulation (optional) that reports whether every registered simulation was called and returned a valid response.
Running the automatic loop
Open the project, make sure the version is evaluated, and open Dataset Curation.
Choose Synthetic Data and the automatic mode.
Select the simulations that should take part. The list comes from the simulations declared in the integration script.
Set the Target distribution filter. This is a regular dashboard filter and must match at least one real sample. The loop calibrates the simulations toward these samples, so pick the population you want the synthetic data to resemble, for example a weak cluster found by an insight.
Optionally set an initial synthetic samples filter that selects synthetic samples already in the dataset. They are not used for calibration, but they are shown next to the new results in the comparison filter so you can see the improvement.
Start the job. Progress appears under Runs and Processes.
Only one synthetic job can be active per project at a time.
Results
The Synthetic Data panel on the dashboard summarises the run. Its ratio compares the distance to the target with the noise floor of the real data, so a ratio near 1 means the synthetic data is statistically indistinguishable from the target.
Samples from the top five trials are added to the dataset with state additional and an is_synthetic flag; samples from worse trials are dropped. The job also creates a dashboard filter, synthetic_results, holding target samples and the best synthetic samples. Apply it to a Population Exploration dashlet, colored by is_synthetic, to see how closely they overlap.
The Synthetic Data list offers the best trials as a CSV, together with the full calibration report. Use the CSV to run your simulator outside Tensorleap with the calibrated parameters.
Errors and warnings
Synthetic jobs support string-id projects only
The preprocess response uses integer sample ids. Switch the project to string sample ids.
Pinned metadata revision
The version was changed after its last evaluation. Re-run evaluate and start the job again.
Target distribution has no real samples
The target filter matched no real samples. Choose a filter that matches real data.
Simulation sample generation failed
A simulation produced fewer than 80% of the samples requested. Fix the simulation so it honours N.
Last updated
Was this helpful?

