DEV Community

Cover image for Experimenting with Tabular Foundation Models for Gradle Builds
Iñaki Villar
Iñaki Villar

Posted on Edited on

Experimenting with Tabular Foundation Models for Gradle Builds

Last week, I saw an email from DeepLearning.AI announcing the course Tabular Foundation Models for Data Science Agents. I thought it could be interesting to take it. I had been thinking for some time about what we could predict from all the metrics we collect during Gradle builds, so it was a good excuse to finally try something.

What I liked about the course was the idea of using a model that is already pretrained on many datasets. With a conventional approach, we would train a model for our particular dataset. With a tabular foundation model, we can provide examples of our data and ask for predictions without going through that same training process.

I am not coming from the AI/ML side, but as part of our build monitoring and experimentation, we already store a lot of build results and metrics in tables. So why not use that data to experiment with these models?

For this article, I decided to start with a simple use case: predicting how the memory usage of a running build process will evolve.

Build Process Watcher

For this experiment, I already had the data and a place to visualize the predictions: Build Process Watcher.

Build Process Watcher is a GitHub Action that has evolved quite a bit. It started as a small utility to capture JVM metrics from the processes involved in a Gradle build. I liked the telemetry available at the build level and wanted something similar for the Gradle and Kotlin processes:

Build Process Watcher JVM metrics summary

The summary report was nice, but after some time I wanted something more interactive. So I started pushing the metrics to Firestore to see the heap usage and resident set size (RSS) of the processes while the build was running, together with the live progress of garbage collection, JIT compilation, and class loading.

Live JVM process metrics during a Gradle build

To avoid draining my Firestore quotas, I made those reports available for only 24 hours. After some months, I also added the option to export the collected data to BigQuery, thinking that at some point I could use it for ML experiments.

Build Process Watcher samples exported to BigQuery

I have been using Build Process Watcher in the GitHub Actions workflows of several of my repositories, including ProjectGenerator and the different build experiments published in Telltale. Over time, I accumulated quite a bit of data in BigQuery, and the course gave me a good reason to finally do something with it.

This time, I wanted to extend the live report with predictions for the Gradle and Kotlin daemons. Together with the actual heap and RSS measurements, could we see how much memory each process might be using 10, 30 or 60 seconds later?

The first prediction model: BigQuery ML

Before testing the tabular foundation models, I wanted to try what BigQuery ML already provides. If we have the data in BigQuery and just want to experiment with predictions, it is a very convenient starting point. We can train a model with SQL and use it for predictions without setting up our own ML service.

For the first implementation, I used a boosted-tree regression model. I had to read a little about boosted trees. My simple understanding is that instead of relying on a single decision tree, the model combines multiple trees, with each one trying to correct errors made by the previous ones.

From the 400 completed build runs, I generated around 1.17 million examples containing the current memory measurement, previous measurements, and the actual value observed 10, 30 or 60 seconds later. Since these builds had already finished, I had the target values needed to train and evaluate the model.

With that data available, I could create the model directly from SQL. This is probably the part I liked most about BigQuery ML. A simplified version of the query looks like this:

CREATE OR REPLACE MODEL `memory_prediction`
OPTIONS (
  model_type = 'BOOSTED_TREE_REGRESSOR',
  input_label_cols = ['target_value']
) AS
SELECT
  process_name,
  metric,
  horizon_s,
  value_t0,
  value_tm10,
  value_tm20,
  value_tm30,
  delta_10,
  delta_20,
  target_value
FROM training_data;
Enter fullscreen mode Exit fullscreen mode

Here, training_data is the data prepared from the historical runs, and target_value is the future memory measurement. This is not the exact query used by my training script, just an example of how little SQL is required to create the model. BigQuery takes care of the training and makes it available for predictions.

And we can also review the training progress directly in GCP:

BigQuery ML boosted-tree training progress

With the model ready, I added the backend components to request predictions and append the forecast points to the Firestore run data consumed by the dashboard. And finally, we could see the predictions while a build was running:

Live heap and RSS predictions with BigQuery ML

In my initial tests, simply using the last observed value worked better for predictions 10 seconds ahead. At 30 and 60 seconds, the model started to provide better results.

I trained the model once for this experiment, but eventually I would need to retrain it as more build data becomes available.

Predictions with foundation models in BigQuery

Now it was time to experiment with foundation models, the original topic of this article. Before deploying one myself, I wanted to check what GCP already offered. My first search brought some good news: Google had announced TabFM support in BigQuery in September 2026. Since I was already using BigQuery, this seemed a good place to start.

I found two options worth trying: AI.PREDICT with TabFM for tabular predictions, and AI.FORECAST with TimesFM for time series. They are different models, but both let me experiment without setting up another service.

TabFM with AI.PREDICT

BigQuery provides AI.PREDICT, which uses Google's TabFM model for regression and classification on tabular data.

The idea is quite simple. We provide historical examples where we already know what happened next, and another set of rows where we want the model to estimate that future value.

For example, we might have a row showing that a Gradle daemon was using 2 GiB of heap, what its memory usage had been in the previous 10, 20, and 30 seconds, and what its actual heap usage was 30 seconds later. That last measurement is target_value, the value we want to predict.

I initially limited the historical context to 120 examples per prediction horizon: 10, 30 and 60 seconds. The second input contains the current process measurements, but without the future target_value, since that is what we want to predict.

This is a simplified version of the query, showing the relevant columns and the general structure rather than a complete runnable query:

SELECT
  series_id,
  predicted_target_value
FROM AI.PREDICT(
  (
    -- Historical examples with known future values
    SELECT
      series_id, process_name, metric, phase,
      origin_s, horizon_s, history_count,
      value_t0, value_tm10, value_tm20, value_tm30,
      delta_10, delta_20, target_value
    FROM `historical_examples`
    WHERE horizon_s IN (10, 30, 60)
    QUALIFY ROW_NUMBER() OVER (
      PARTITION BY horizon_s
      ORDER BY origin_s DESC
    ) <= 120
  ),
  (
    -- Current process observations with the same feature schema;
    -- target_value is unknown (NULL)
    SELECT * FROM UNNEST([
      STRUCT(
        'series…' AS series_id,
        'GradleDaemon' AS process_name,
        'heap' AS metric
        -- Additional typed feature columns omitted here
      )
    ])
  ),
  label_col => 'target_value'
)
Enter fullscreen mode Exit fullscreen mode

And that is all we need to call the pretrained model. No CREATE MODEL and no separate training job for our dataset. Of course, we still have to prepare the information we send. Build Process Watcher collects memory samples, but the query needs rows containing the current memory value, previous measurements, changes over time, and the future result for the historical examples. So we removed the training step, not the work of preparing data.

Live memory predictions with TabFM

I tried providing 120, 250 and 500 historical examples per prediction horizon. More examples did not necessarily improve the predictions, and the response time was around 1.3 seconds in all three cases. Of the three configurations I tried, 250 examples was the only one that improved on the last-value baseline, so I continued with that configuration.

TimesFM with AI.FORECAST

There was another option I wanted to try: AI.FORECAST.

This function uses TimesFM 2.5, a pretrained model designed for time-series forecasting. Instead of preparing examples with features and their future values, we provide a sequence of measurements and ask for the next points.

This fits quite well with what Build Process Watcher already collects: a timeline of heap and RSS measurements during build execution.

There is one detail: TimesFM predicts points, not seconds. To make this work with the dashboard, I used a regular 10-second interval for the samples and requested six future points. I then used points 1, 3 and 6 to represent predictions for 10, 30 and 60 seconds.

The integration with the dashboard is similar: the backend requests a forecast, attaches the result to the run data in Firestore, and the UI can display it alongside the real measurements.

A simplified example of the query looks like this:

SELECT prediction_id, forecast_timestamp, forecast_value, ai_forecast_status
FROM AI.FORECAST(
    (SELECT * FROM UNNEST([
      STRUCT('1|GradleDaemon|heap|50' AS prediction_id, TIMESTAMP_SECONDS(0) AS ts, 100.0 AS value),
      STRUCT('1|GradleDaemon|heap|50' AS prediction_id, TIMESTAMP_SECONDS(10) AS ts, 110.0 AS value),
      STRUCT('1|GradleDaemon|heap|50' AS prediction_id, TIMESTAMP_SECONDS(20) AS ts, 120.0 AS value),
      STRUCT('1|GradleDaemon|heap|50' AS prediction_id, TIMESTAMP_SECONDS(30) AS ts, 130.0 AS value)
      -- one STRUCT per 10s grid point; heap and rss are separate prediction_ids
    ])),
    data_col => 'value',
    timestamp_col => 'ts',
    id_cols => ['prediction_id'],
    horizon => 6,
    confidence_level => 0.9
)
Enter fullscreen mode Exit fullscreen mode

And with this approach, we could also see the forecasts in the live report:

Live memory forecasts with TimesFM

Moving from BigQuery to a hosted model

After experimenting with the BigQuery options, I wanted to try TabPFN itself, the tabular foundation model from Prior Labs introduced in the DeepLearning.AI course.

For this I created a Spot VM in GCP using g2-standard-8 with an NVIDIA L4 GPU. I initially tried a regular Ubuntu image, but had some problems installing the NVIDIA drivers. I ended up using a Deep Learning image that already included them. With the VM ready, I installed Python, PyTorch with CUDA support and the TabPFN dependencies.

I decided to use TabPFN v2, mainly because of its more permissive license. More recent versions, including TabPFN 3 and 3.5, have restrictions on commercial and production use.

For TabPFN, I exported a smaller subset of the historical examples from BigQuery, following the same approach as with TabFM: recent memory measurements and their corresponding future values for both Gradle and Kotlin daemons.

Although TabPFN is already pretrained, we still need to provide examples of our data through a fitting step. The difference from the boosted-tree model is that this step does not update the model weights.

What I particularly liked about TabPFN was the possibility of caching the fitted context on the VM. With TabFM in BigQuery, I was sending the historical examples with every prediction request. With TabPFN, I could prepare that context once and reuse it for subsequent predictions.

I exposed the model through a small Python API, so the Build Process Watcher backend only needed to send the current process measurements and receive the predicted memory values.

Of course, it wasn't all smooth. The first Spot VM ran into GPU availability problems, so I ended up taking a disk snapshot and recreating it in another region. And when the Spot VM is stopped, I disable the TabPFN provider, since there is no service available to answer the requests.

With everything connected, I could finally see TabPFN predictions in the Build Process Watcher dashboard.

Live memory predictions with self-hosted TabPFN

Comparing the four models

Now that I had the four approaches integrated into Build Process Watcher, I wanted to compare them. How close were the predictions to the actual measurements? And how long did each model take to return them?

For this experiment, I executed a separate build with each model and collected predictions for heap and RSS at 10, 30 and 60 seconds. One problem with comparing the results is that memory usage can evolve differently between build executions. A lower prediction error in one build does not necessarily mean that the model is better.

So, for each run, I also calculated the error of a much simpler approach (last_value): assuming that the current memory usage will remain the same for the next 10, 30 or 60 seconds. I used that as the baseline for the model running in that build.

In the following tables, MAE (Mean Absolute Error) represents the average difference in absolute terms between the predicted and actual values. Lift represents the percentage improvement in MAE relative to the baseline. A positive lift means the model reduced the error, while a negative lift means we would have been better off using the last observed value. I also included p50 and p95 latency because these predictions are requested while the build is running.

Memory prediction comparison

Model Latency (p50 / p95) Overall MAE (Lift) RSS MAE (Lift) Heap MAE (Lift)
BQML Boosted Trees 1.00s / 1.33s 214.6 MB (+15.2%) 204.1 MB (+13.5%) 225.1 MB (+16.8%)
TabPFN GPU 3.01s / 3.05s 344.5 MB (+12.0%) 370.1 MB (+5.3%) 318.8 MB (+18.7%)
TabFM 1.32s / 1.71s 392.5 MB (+6.3%) 394.6 MB (-6.5%) 390.5 MB (+16.6%)
TimesFM 2.5 3.21s / 5.45s 556.4 MB (-12.5%) 738.5 MB (-26.4%) 370.5 MB (+8.1%)

Per-process breakdown

I was also interested in seeing whether the results were different depending on the process we were monitoring.

Model GradleDaemon RSS MAE GradleDaemon Heap MAE KotlinCompileDaemon RSS MAE KotlinCompileDaemon Heap MAE
BQML Boosted Trees 190.1 MB (+11.9%) 207.4 MB (+17.9%) 220.4 MB (+15.1%) 245.8 MB (+15.6%)
TabPFN GPU 439.9 MB (+4.7%) 375.2 MB (+13.7%) 286.0 MB (+6.4%) 250.9 MB (+26.5%)
TabFM 376.5 MB (-12.6%) 443.9 MB (+11.8%) 415.9 MB (-0.8%) 327.4 MB (+23.1%)
TimesFM 2.5 853.0 MB (-10.7%) 340.4 MB (-8.3%) 604.1 MB (-64.9%) 404.5 MB (+19.7%)

Something I didn't expect was that the first model I implemented, the boosted-tree model in BigQuery, would end up with the lowest prediction error and also the lowest latency in these runs.

With TabPFN, the best improvement was for the heap usage of the Kotlin daemon, where it reduced the error by 26.5% compared with the baseline. TabFM also improved heap predictions, but not RSS predictions in these runs. And while I initially thought TimesFM could be a good fit for memory predictions, it had more difficulties following the RSS measurements.

Of course, I would need to repeat this with more builds and evaluate the models against the same observations before making any conclusions about which model works better.

Beyond memory: predicting class loading

So far, all the experiments were around memory usage, but Build Process Watcher collects other metrics too. For my next experiment, I decided to try class loading. We already collect the number of classes loaded by Gradle and Kotlin daemons, so I added another prediction target: how many additional classes will this process load in the next 60 seconds?

I implemented it with the three approaches I was already experimenting with: TabFM through AI.PREDICT, TimesFM through AI.FORECAST, and TabPFN on the GPU VM. I left the boosted-tree model out of this experiment, since it would require training another model for class loading.

The dashboard now shows the accumulated number of loaded classes together with the predicted total for the next minute. It also shows the number of additional classes expected, so we can compare the prediction with the measurements that arrive later. Here is a comparison of the three foundation models predicting class loading in the Gradle daemon:

Gradle daemon class-loading prediction comparison

Model Latency (p50 / p95) MAE (+60s classes) Median AE Lift vs. zero
TimesFM 2.5 4.10s / 5.94s 13,018 7,902 +38.1%
TabPFN GPU 0.69s / 0.70s 13,687 8,032 +40.1%
TabFM 1.35s / 1.59s 28,686 13,871 +32.3%

For this comparison, the baseline is assuming that no additional classes will be loaded in the next 60 seconds.

The results were quite different from the memory experiment. TimesFM seemed to follow the large increments in class loading better, while TabPFN achieved similar accuracy with a median response time of less than one second. TabFM struggled more with those increments.

But beyond predicting the number of loaded classes, could we use these predictions to anticipate when class-loading activity will stabilize? This could be one indicator of JVM warm-up, together with JIT compilation activity. I still need more measurements to understand how useful these predictions are, but I liked being able to reuse the same infrastructure for a different metric.

Final words

With so much of the industry focused on LLMs these days, it was nice to explore other types of foundation models and see what we could do with the data we already collect from our builds.

I wonder whether predicting the exact memory usage in 30 seconds is what we really need. Maybe anticipating memory pressure or understanding JVM warm-up by combining class loading and JIT compilation metrics would be more useful for our builds.

I also made the dataset available on Hugging Face in case someone wants to experiment with other models or explore other metrics from our builds.

For now, I have the data, the models and a place to visualize the predictions. Let's see what else we can do with them.

References

These are some of the resources I used while exploring the different approaches:

Top comments (0)