Snowflake Native App

Install Arena from Snowflake Marketplace and post-train an open-weight model on your own Snowflake tables, all from SQL. Training normally runs on Arena’s cloud; with the app it runs on Snowpark Container Services in your account, and your rows, checkpoints and trained models stay there. It runs supervised fine-tuning, distillation, preference optimisation and reinforcement learning, scored by a built-in reward or by a Snowflake function of yours.

The examples here call the app arena_app; use the name you give it at install.

Prerequisites

  • A paid Snowflake account. On a trial account the install stops with Snowflake error 509009.

  • GPU instance families in your region. Run SHOW COMPUTE POOL INSTANCE FAMILIES; and look for one such as GPU_NV_S on AWS or GPU_GCP_NV_L4_1_24G on Google Cloud.

  • ACCOUNTADMIN, or a role with IMPORT SHARE, CREATE APPLICATION and PURCHASE DATA EXCHANGE LISTING on the account.

  • A warehouse in the session you call the app from.

  • An Arena sign-in, or an email address to create one.

Step 1: Install from Marketplace

Find AgileRL Arena: post-training for open-weight models and agents in Snowflake Marketplace, install it and choose its name.

The app asks for five account privileges: CREATE COMPUTE POOL, CREATE WAREHOUSE, CREATE EXTERNAL ACCESS INTEGRATION, EXECUTE TASK and EXECUTE MANAGED TASK. Snowflake grants them at install.

Install creates a warehouse and two external access integrations named AGILERL_APP_<APP>_..., where <APP> is the app name in upper case. It creates no compute pools yet.

If a second result row starts with Reference register_callback 'APP_CODE.REGISTER_REFERENCE(...)' does not exist, ignore it.

Approve the app’s two connections out of your account, on the app’s page in Snowsight or in SQL, as ACCOUNTADMIN or SECURITYADMIN. HF_ACCESS downloads base model weights from Hugging Face. ARENA_ACCESS reaches arena.agilerl.com to check the licence and record run start, check-ins and end.

SHOW SPECIFICATIONS IN APPLICATION arena_app;
-- Use each request's sequence_number from the SHOW output.
ALTER APPLICATION arena_app APPROVE SPECIFICATION HF_ACCESS SEQUENCE_NUMBER = 1;
ALTER APPLICATION arena_app APPROVE SPECIFICATION ARENA_ACCESS SEQUENCE_NUMBER = 1;

Step 2: Give people access

The app has two roles. app_admin connects to Arena, creates pools, binds tables, stages and reward functions, trains, publishes, exports models and cleans up. app_user checks status, reads logs and metrics, and calls served models. app_admin includes app_user.

The example grants them to roles named ml_engineer and ml_viewer. Use your own roles, or create these first with CREATE ROLE IF NOT EXISTS ml_engineer; and CREATE ROLE IF NOT EXISTS ml_viewer; and grant them to your users:

GRANT APPLICATION ROLE arena_app.app_admin TO ROLE ml_engineer;
GRANT APPLICATION ROLE arena_app.app_user TO ROLE ml_viewer;

Step 3: Connect to Arena

Each run checks its licence with Arena, so the app needs an Arena org key. It fetches the key itself; nobody sees or pastes it. As app_admin:

CALL arena_app.app_code.connect_arena();

It returns a link. Open it within an hour, sign up or sign in, and create the organization. Each Snowflake account gets a new Arena organization of its own. Then run connect_arena() again, or wait up to an hour for the app to collect the key by itself. When it has it, you see:

Connected to the Arena organisation Acme ML.

Once the app is connected, connect_arena() changes nothing and returns:

This app is already connected to Arena.
Use app_code.rotate_arena_key() for a new key.

In some regions Snowflake takes a minute or two to deliver Arena’s check to your account. If connect_arena() says it’s still waiting, run it again in a few minutes.

An organization connected this way trains inside Snowflake only. It can’t run training or deployments hosted by Arena. If AgileRL gave you an org key directly, connect with CALL arena_app.app_code.configure('arena_org_...', 'your-external-user-id'); instead.

The app rotates its key every 90 days. CALL arena_app.app_code.rotate_arena_key(); rotates it now. Neither happens while a run is going.

Step 4: Create compute pools

List the GPU families your region has and Arena prices, then create pools for the ones you want:

CALL arena_app.app_code.gpu_families();
CALL arena_app.app_code.set_pools(['GPU_NV_S', 'GPU_NV_M'], 4);

The second argument is the most GPUs each GPU pool can hold. Pass every family you want each time: set_pools drops the app’s pools for families you leave out. It won’t shrink or drop a GPU pool that a queued or running run still needs, or take a max_gpus that isn’t a multiple of a listed family’s GPUs per node. Pools start when a job starts and suspend after 5 idle minutes. A suspended pool has no Snowflake compute charge, but any month in which a pool runs counts as a month of use for the monthly fee (Costs).

Step 5: Bind a table

The app reads only tables and views you bind to it. As a role with app_admin that can grant SELECT on the table:

CALL arena_app.app_code.register_reference(
  'source_table', 'ADD',
  SYSTEM$REFERENCE('TABLE', 'analytics.public.sft_examples', 'PERSISTENT', 'SELECT')
);
SHOW REFERENCES IN APPLICATION arena_app;

SHOW REFERENCES gives each binding an alias; runs name the alias they read. For a view, use source_view and 'VIEW'. To train on custom SQL, put it in a view and bind that.

Snowflake stores unquoted column names in upper case. A table created as (prompt STRING, response STRING) has columns PROMPT and RESPONSE, and the manifest must use those names.

Step 6: Train

Pass the manifest, the GPU count, and the binding to read:

CALL arena_app.app_code.submit(
  $$
algorithm:
  name: SFT
environment:
  env_type: dataset
  objective: sft
  columns:
    prompt: PROMPT
    target: RESPONSE
network:
  pretrained_model_name_or_path: Qwen/Qwen3.5-0.8B
  max_context_length: 2048
training:
  max_steps: 200
$$,
  1,
  'source_table',
  '<alias>'
);

columns maps the trainer’s names (left) to your columns (right). submit returns a run ID such as arena-20261119013316-d15e04; keep it.

After the alias, submit takes optional arguments in this order: gpu_family, reward_file, checkpoint_steps and resume_from. Without a family it picks the one with the least GPU memory that fits. Leave reward_file unset: the app takes no reward file. To continue a cancelled run, pass its ID as resume_from.

The GPU count must be a multiple of the family’s GPUs per node. Reinforcement learning (CISPO, GRPO) needs at least 2 GPUs: one trains while another generates answers.

For reinforcement learning over table rows, add a prompt_template and a reward to the manifest’s environment. CISPO is the recommended default and usually trains better than GRPO; GRPO is also supported: change name: CISPO to name: GRPO and keep the rest. With QUESTION and ANSWER columns, on two A10G GPUs of GPU_NV_S:

CALL arena_app.app_code.submit(
  $$
algorithm:
  name: CISPO
  batch_size: 8
  group_size: 4
environment:
  env_type: rollout
  columns:
    question: QUESTION
    answer: ANSWER
  prompt_template:
    system_0: Think step by step, then give the final number inside <answer></answer>.
    user_1: "{question}"
  reward:
    type: numeric
    answer_pattern: "<answer>(.*)</answer>"
  max_reward: 1.0
network:
  pretrained_model_name_or_path: Qwen/Qwen3.5-0.8B
  max_context_length: 2048
training:
  max_steps: 200
$$,
  2,
  'source_table',
  '<alias>',
  'GPU_NV_S'
);

numeric is a built-in reward. It reads the number inside <answer></answer> and gives 1 when it equals the row’s ANSWER, else 0. The app has five built-in rewards, and you can also write the reward as a Snowflake function in your account and bind it to the app. See Snowflake Native App rewards.

The app trains only models in the Arena catalog, and refuses ones that need to run code from their Hugging Face repo.

submit refuses before anything starts when:

  • the trial has ended and the listing is not bought;

  • the manifest has a missing, misspelled or wrong-typed field, such as an unknown algorithm.name or reward type. The message names each field, what is wrong and what to change;

  • the app has no compute pools yet;

  • nothing is bound to source_table (or source_view) with that alias. The message lists the aliases that are bound and how to bind one;

  • the app has no pool for the GPU family. The message gives the set_pools call that adds one and keeps your other pools;

  • Arena has no price for the GPU family;

  • the GPU count is not a multiple of the family’s GPUs per node, or is more than the pool holds. The message lists the counts the pool can run;

  • the run needs more GPUs than you asked for, such as CISPO or GRPO on 1 GPU. The message gives the GPU count to ask for;

  • an OPD run with a separate teacher model asks for a GPU family with 1 GPU per node. Each rollout engine and its teacher run together on one node, so pick a family with at least 2 GPUs per node;

  • the run does not fit in the GPU memory of any pool.

Each of these messages ends with Nothing was started. and says what to change. The messages and fixes are under Common messages.

GPU nodes come from Snowflake. When Snowflake has little GPU capacity in your region, they can take a long time to start. A run waits up to 45 minutes for them: status shows its containers as PENDING, and training starts once every GPU node has joined.

If they have not all joined after 45 minutes, the run stops before training. It removes its worker service and suspends the GPU pool if nothing else is using it, so the pool is freed at once. status then says that not all of its nodes became available within 45 minutes and that Arena does not charge for the run. Snowflake still bills the compute pools for the time they ran, as usual. Submit the run again later, or try another GPU family.

A run that fails for another reason before training starts, for example because its message broker did not start, frees the GPU pool in the same way. So does a run you cancel before training starts. status gives the reason, and Arena does not charge for the run.

Check the run, read its logs and metrics, or stop it:

CALL arena_app.app_code.status('arena-20261119013316-d15e04');
CALL arena_app.app_code.logs('arena-20261119013316-d15e04');

SELECT seq, time, metrics
FROM arena_app.app_state.arena_metrics
WHERE run_id = 'arena-20261119013316-d15e04'
ORDER BY seq;

CALL arena_app.app_code.cancel('arena-20261119013316-d15e04');

status prints the state of the broker, head and workers, then one line for the run: state: running, succeeded, failed, cancelling, cancelled or gone. cancel drops the run’s services, so a run you cancel reads gone. cancelled means Snowflake cancelled a service, for example during node maintenance. A run whose head or worker service is gone before the run finished reads failed, because it cannot make progress; cancel it to free the nodes its other services still hold. When a run stopped before training started, status adds a reason line that says why.

logs prints one service’s log, at INFO level and above. It reads the head by default; pass 'worker', 0 for the first worker. A new node can take several minutes to start, and GPU nodes take longest. Until it has started, logs says the container has not started yet; check status and try again. Logs of finished jobs need an active event table. If your account has none, run ALTER ACCOUNT SET EVENT_TABLE = SNOWFLAKE.TELEMETRY.EVENTS;.

Snowflake can cancel jobs during its weekend node maintenance windows. Plan long runs around them, or resume.

Step 7: Publish and serve

Log the run’s newest checkpoint to the Model Registry inside the app, and serve it:

CALL arena_app.app_code.publish('arena-20261119013316-d15e04', 'support_bot', NULL, NULL, TRUE);

The arguments after the model name are the version name, the checkpoint step, and whether to serve. The service is named <model>_<version>, so this example serves SUPPORT_BOT_CHECKPOINT_200.

With serving on, publish returns once the model answers. First it logs the model, which can take 20 minutes or more. Then the inference service waits for a GPU node from Snowflake and loads the model. When Snowflake has few GPUs free in your region, the node alone can take half an hour or more. publish waits up to 60 minutes for the service. If it is still waiting after that, publish does not fail and drops nothing: it returns the chat function and says the service is still waiting for a GPU node. The app’s hourly task finishes the job once the service is ready. Arena starts charging for the served model only once it is ready; run endpoint (Step 8) to check. If the service fails to start, publish raises an error with Snowflake’s status message.

publish can run for up to about two hours and holds your warehouse while it runs. Snowflake stops any statement that runs longer than STATEMENT_TIMEOUT_IN_SECONDS, which is two days unless your account, user or warehouse sets it lower. If it stops publish, the model keeps publishing and serving, and endpoint says when it is ready.

The publish job runs on the app’s CPU head pool, so a training run does not hold it up. The served model runs on the GPU pool: if training is using every node there, the model starts once a node is free. To serve while training, call set_pools again with a higher max_gpus to give the pool more nodes. List every GPU family you still want, because set_pools drops the app’s pools for families you leave out.

Step 8: Call the model

A served model has no endpoint outside Snowflake. Roles with app_user call it from SQL through a chat function. endpoint prints the function’s name, a state: line and an example call:

CALL arena_app.app_code.endpoint('support_bot');

SELECT arena_app.app_state.SUPPORT_BOT_CHECKPOINT_200_CHAT(
  PARSE_JSON('[{"role": "user", "content": "Hello"}]')::ARRAY,
  0.7,
  256
):choices[0]:message:content::STRING AS reply;

The state: line reads ready, starting (the service has its GPU node and is loading the model), waiting for a GPU node, suspended or failed, with Snowflake’s status message when it has one. The example SELECT works once it reads ready.

The function takes the chat messages (an ARRAY in the OpenAI format), a temperature and a token limit, and returns the OpenAI chat completion as an OBJECT. Run it over a table of prompts to answer them all in one query.

For the other chat options, call the Model Registry’s own method on the service, which app_user can also use. It takes all ten arguments in this order: messages, temperature, max_completion_tokens, stop, n, stream, top_p, frequency_penalty, presence_penalty and response_format:

SELECT arena_app.app_state.SUPPORT_BOT_CHECKPOINT_200!__CALL__(
  PARSE_JSON('[{"role": "user", "content": "Hello"}]')::ARRAY, 0.7, 256, NULL, 1, FALSE, 1.0, 0.0, 0.0, NULL
);

To serve the model over HTTPS outside Snowflake, copy it to a stage of yours with export_model (see Step 9) and serve it yourself.

Snowflake suspends a service that gets no calls. endpoint then says suspended. The next call waits while it starts again, which can take a few minutes.

Step 9: Clean up

Stop serving, which also stops the serving charges:

CALL arena_app.app_code.unpublish('support_bot');

This also drops the model’s chat function. Pass the version name and TRUE as well to delete the registry version.

Uninstalling deletes everything the app holds, including checkpoints, metrics and models, and your roles can’t read those directly. To keep a model, bind a stage of your own and export to it first:

CREATE STAGE my_db.my_schema.arena_models;
CALL arena_app.app_code.register_reference('export_stage', 'ADD',
  SYSTEM$REFERENCE('STAGE', 'my_db.my_schema.arena_models', 'PERSISTENT', 'READ', 'WRITE'));
CALL arena_app.app_code.export_model('arena-20261119013316-d15e04');

That copies the run’s newest merged checkpoint, as Hugging Face files, to <run id>/checkpoint_<n>/ on your stage. Pass a step number as the second argument for an earlier checkpoint. Files of the same name are overwritten. export_model starts no service and Arena charges nothing for it; Snowflake bills the copy to your account and caps each file at 5 GB. To keep the metrics, copy them into a table of your own:

CREATE TABLE analytics.public.arena_metrics_copy AS
  SELECT * FROM arena_app.app_state.arena_metrics;

Then drop the app as the role that owns it:

DROP APPLICATION arena_app CASCADE;

Arena keeps your organization for 30 days. Reinstall within that time and connect_arena() offers to reconnect to it.

Costs

Snowflake bills you for the app’s pools, warehouse and storage as usual. AgileRL bills through the Marketplace listing: a monthly fee for each calendar month you use the app, plus usage. Usage is GPUs × hours × the family’s price per GPU-hour, for training from the first GPU node starting to the end of the run, and for serving once the model is ready to answer. A run that never reaches its first training step is not charged at all (see below). One usage unit is 1 cent; one GPU_NV_S GPU for 3 hours at $2.28 an hour is 684 units. The listing shows the fee and the price per family.

Any query that references the app in a month counts as use, status included. To skip the fee for a month, unpublish your models and make no calls to the app until the next month, or uninstall it.

A run that ends before its first training step is not charged by Arena, for example because it failed while starting up, its nodes did not all become available within 45 minutes, or you cancelled it before training started. Its row in app_state.usage_items settles with unbilled_reason set to The run ended before training started. A run that fails partway through training is charged up to the failure. A served model is charged only once it is ready to answer.

An app_admin can audit charges in app_state.usage_items, app_state.billed_hours and app_state.served_models. Usage reaches your Snowflake bill about an hour after it happens.

The first 7 days after install are a free trial. An hour before it ends, submit and publish stop working and the app drops anything still running, until you buy the listing. export_model still works, so you keep what you trained.

What leaves your account

To connect, the app sends Arena your account locator, region, account and organization names, the app’s name and version, and whether you bought the listing. For each run it sends the run ID, GPU count and family, and start and end times; for a served model, the model and version names. It sends no rows, prompts, metrics or weights. The only other connection out is to Hugging Face, for base model weights.

Common messages

Message

What to do

Arena is not connected. An app_admin calls app_code.connect_arena first.

Run Step 3.

Arena no longer accepts this app's org key.

Run connect_arena() and open the new link. It offers to reconnect to the same organization.

The app has no compute pools yet.

An app_admin runs set_pools.

Arena has no Snowflake price for <family>

Pick a family that gpu_families() lists.

Nothing is bound to source_table with the alias <alias>. (or source_view)

Pass an alias that SHOW REFERENCES IN APPLICATION arena_app; lists, or bind the table or view first.

The app has no GPU pool for <family>.

An app_admin runs the set_pools call that the message gives.

<family> has <n> GPUs per node, so it cannot run <gpus> GPUs.

Pass one of the GPU counts that the message lists.

<algorithm> needs at least <n> GPUs on <family>

Ask for the GPU count that the message gives.

The <family> pool holds <n> GPUs, so it cannot run <gpus> GPUs.

Pass a smaller GPU count, or have an app_admin raise max_gpus with set_pools.

The head container has not started yet (state: PENDING).

The node is still starting. When Snowflake has little GPU capacity in your region, this can take a long time. Check status and call logs again later.

Not all of the nodes this run needs became available within 45 minutes, so it stopped before training started.

Snowflake had too few GPU nodes free in your region. Arena does not charge for the run. Submit it again later, or try another GPU family.

The run's message broker did not start, so it stopped before training started.

Arena does not charge for the run. Submit it again.

The run failed while starting up, so it stopped before training started.

Arena does not charge for the run. Read the head’s log with logs for the error.

<model> <version> is published, but its service is still waiting for a GPU node.

publish waited 60 minutes. The model keeps starting; run endpoint until its state: line reads ready.

<model> <version> is in the Model Registry, but its service <service> failed.

The message gives Snowflake’s status message and a statement to check the service. For help, email arena@agilerl.com with both.

This app has no run <run id>.

Check the run ID. It comes from submit.

The free trial of AgileRL Arena has ended.

Buy the listing in Snowflake Marketplace.

Snowflake training is not enabled for this organization.

Contact arena@agilerl.com.

reward_file is not available in the Snowflake app.

Set environment.reward in the manifest. See Snowflake Native App rewards.

For pricing, billing or help with a run, email arena@agilerl.com with your account locator and the run ID.