Documentation
Compute plans and streams
View .mdOpenAPI

Fill a stream's pending lookahead

POSThttps://weights.fyi/run/v1/compute/plans/{plan_id}/stages/{stage_id}/materializescope: submit
text
POST https://weights.fyi/run/v1/compute/plans/{plan_id}/stages/{stage_id}/materialize
Authorization: Bearer <token>                    scope: submit
Content-Type: application/json
Available since
2026-10-28: included in this build; see What is live for deployment status.
Answer time
synchronous registration of the next pack window; does not wait for processing or upload input bytes.

Fills a stream's pending-pack lookahead using its lazy_materializer policy. Existing lazy packs are promoted first, in ordinal order; additional registrations can be generated from a manifest or templates up to the declared total. Here materialization makes pack metadata runnable; it does not create or verify the remote data those registrations name.

The stage must be ready or actively executing, its dependencies satisfied, its tenant grant valid and its scheduling window open. A terminal plan, non-stream stage, missing or disabled policy, or ineligible stage produces zero work. force_fill lifts the policy's batch-size limit while preserving eligibility, lookahead, admission and total-pack limits.

Request

NameWhereRequiredMeaning
AuthorizationheaderyesBearer token with submit.
plan_id, stage_idpathyesYour plan and stream stage identifiers.
force_fillJSON bodynoBoolean, default false. True fills the available lookahead in this call.

Send {} or an object containing only force_fill, at most 1 MiB. An empty body is invalid JSON. Configure the policy during plan admission:

Policy fieldMeaning
lazy_materializerObject on stage, metadata or workload; the first declaration in that order wins.
enabled, auto_sealOptional booleans, effective default true. Sealing occurs once the declared total is registered beyond the lazy state.
lookahead_packs, batch_sizePositive integers. Lookahead defaults to 16 pending packs; omitted batch size permits the full gap.
packs_totalPositive integer; otherwise workload packs_total, expected_packs, or manifest length supplies the total. Without a total, only existing lazy packs are promoted.
manifest, shards, packsAlternative arrays of pack objects, considered in this order. Entries override generated defaults.
start_index, pack_id_templatePositive index, default 1; ordinal defaults to index minus one. Identifier template defaults to pack-{index:04d}; a literal prefix gets -{index:04d} appended. A template containing placeholders must include index or pack_index.
Template bindingsindex, pack_index, plan_id, authored stage_id, policy source_uri, and generated pack_id for input/output/digest templates.
Input templatesFirst of r2_input_uri_template, input_uri_template, source_uri_template, source_uri. With placeholders, format directly; otherwise append /<pack_id>.jsonl.zst. The result is r2_input_uri and must pass tenant storage validation.
Output/digest templatesr2_output_uri_template or output_uri_template; sha256_template unless each entry supplies sha256. Supply actual source paths and digests. Absent path templates generate paths under r2://tenants/<tenant_id>/campaigns/<plan_id>/<stage_id>/input/ and output/. Missing byte digests are rejected; the scheduler does not fabricate source identity.
Manifest overridesNon-null entry fields replace generated values. Provide prepared r2_input_uri, actual sha256, compressed_bytes and item_count; source_uri replaces the generated input when no staged r2_input_uri is supplied. Existing lazy entries use their stored fields rather than a matching manifest entry.
Pack defaultsitem_count or items_per_pack (positive; required), compressed_bytes (nonnegative; required), est_input_tokens (nonnegative; 512000), est_output_tokens (nonnegative; 128000).
max_pending_packsPositive limit declared on stage, workload or stream_spec; counts pending and active packs together.

Return value

200 OK with:

FieldMeaning
materializedInteger count of packs promoted or registered in this call.
stagesArray containing {plan_id, stage_id, materialized} for the addressed stage.

An eligible plan can register its first policy batch during plan admission, before you call this endpoint. Read the stream backlog after admission to establish the pending count. For example, with lookahead_packs: 4 and batch_size: 1, admission can register one pack, a subsequent {} call adds one, and {"force_fill":true} then adds the remaining two. Each call's materialized counts only the work added by that call.

Repeated calls may add more packs as earlier work drains; they are not replay-key operations. Read the stream backlog to inspect remaining work. When automatic sealing is enabled, reaching the declared total can seal the stream in this transaction.

This call does not accept verify_source or perform source probes. For direct external sources, prepare and repost lazy packs through pack registration, which can verify their sources.

Errors

StatusCodeMeaning
400invalid_json, invalid_compute_planInvalid body, unknown field, nonboolean flag or invalid generated pack.
401unauthorized, invalid_token, token_revoked, token_expiredSupply a valid token.
403scope_required, account_suspended, compute_tenancy_unauthorizedMissing scope, active account or tenant grant.
404compute_plan_not_found, compute_stage_not_foundPlan or stage is absent or inaccessible to this account.
409compute_plan_conflictGenerated pack identity, promotion or sealing conflicts with durable data.
413body_too_largeBody exceeds 1 MiB.
429stream_backpressurePack registration would exceed the pending-pack limit. Wait for work to drain.
429rate_limitedWait for Retry-After before retrying.

Examples

sh
curl -s https://weights.fyi/run/v1/compute/plans/PLAN_ID/stages/STAGE_ID/materialize \
  -H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/json" \
  -d '{"force_fill":true}'
json
{"materialized":8,"stages":[{"plan_id":"example-plan","stage_id":"pages","materialized":8}]}

Patterns

Declare this lazy_materializer on the stage at admission, after uploading the actual input. The sample digest and size describe {} plus a newline; replace them and the count with your workload's records. auto_seal: false leaves sealing to the caller.

json
{"lookahead_packs":2,"batch_size":1,"auto_seal":false,"manifest":[{"pack_id":"p0","r2_input_uri":"r2://tenants/demo/inputs/p0.jsonl","r2_output_uri":"r2://tenants/demo/results/p0.parquet","sha256":"ca3d163bab055381827226140568f3bef7eaac187cebd76878e0b63e9e442356","compressed_bytes":3,"item_count":1,"est_input_tokens":0,"est_output_tokens":0,"format":"jsonl"}]}

History

  • 2026-10-28: documented bounded lookahead materialization and forced fill.

See also