SQL
AuraScore 83/100

Multimodal Inference Cost and Sampling Matrix Architect

Design an analytical SQL query matrix to evaluate image generation compute costs across diffusion samplers and prompt token lengths.

Use this template when configuring GPU cost attribution and latency trade-off queries across high-volume image synthesis pipelines. It produces production-ready SQL scripts structured into a comparative performance matrix.

Template

Role: Principal Data Platform Architect specializing in generative inference telemetry and GPU cost optimization.

Context

  • Query Engine: {{warehouse_engine}}
  • Raw Log Source: {{telemetry_table}}
  • Cost Calculation Basis: {{inference_cost_metric}}
  • Target Samplers: {{sampling_methods}}
  • Prompt Stratification: {{prompt_length_buckets}}
  • SLA Objective: {{target_sla_ms}}

Task

Develop an analytical SQL diagnostic matrix that aggregates image generation runtime metrics, evaluates inference cost variance across diffusion parameters, and benchmarks latency against SLA limits to isolate unoptimized prompt archetypes.

Method

  1. Inspect {{telemetry_table}} to identify schema partition keys, timestamp encodings, and GPU hardware tags.
  2. Write structured Common Table Expressions (CTEs) to segment prompt tokens into {{prompt_length_buckets}} using regex-based token counters.
  3. Compute percentile distributions (p50, p90, p99) for end-to-end inference duration filtered by {{sampling_methods}}.
  4. Calculate unit economic expenditure per successful render leveraging {{inference_cost_metric}}.
  5. Flag anomalies where runtime exceeds {{target_sla_ms}} using windowed standard deviation thresholds.
  6. Aggregate generation success, failure, and safety truncation rates across all sampler-token intersections.
  7. Formulate the final cross-tabulated query output organized as a comparative multidimensional matrix.

Constraints

  • MUST write dialect-pure SQL native to {{warehouse_engine}} without pseudo-code.
  • MUST NOT perform full-table scans; all filtering must leverage partition pruning.
  • Window functions MUST include explicit partition and order specifications.
  • All cost figures must be rounded to six decimal places for sub-penny GPU accounting.

Output format

1. Architectural Logic Overview

Summary of query execution plan, indexing strategy, and partition handling.

2. Analytical SQL Script

Fully commented SQL script containing CTE pipeline and final aggregation.

3. Sampling vs Cost Telemetry Matrix

Markdown matrix comparing samplers across token buckets, average cost, p95 latency, and SLA breach percentages.

Self-review

  • Confirm all 6 variables ({{warehouse_engine}}, {{telemetry_table}}, {{inference_cost_metric}}, {{sampling_methods}}, {{prompt_length_buckets}}, {{target_sla_ms}}) are integrated.
  • Verify query syntax contains no unindexed cartesian joins.
  • Ensure all markdown tables align precisely with the schema definitions.
AuraScore breakdown
83/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency7/10 · Adequate

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

data-analytics
data-sql
image-multimodal-prompting
sql
image-generation
diffusion-models