Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/amd-skills-evals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: AMD Skills Checks

on:
pull_request:
paths:
- "skills/**"
- ".github/workflows/amd-skills-evals.yml"
workflow_dispatch:
inputs:
structural:
description: Structural Tests
type: boolean
default: true
routing:
description: Routing Tests
type: boolean
default: false
behavioral:
description: Behavioral Tests
type: boolean
default: false

permissions:
contents: read

jobs:
evals:
name: AMD Skills Checks
uses: amd/skillscope/.github/workflows/reusable.yml@v0.1.3
secrets:
api_key: ${{ secrets.ANTHROPIC_API_KEY }}
with:
skills: skills/magpie
# Each step can be set to `required`, `optional`, or `off`.
structural: ${{ github.event_name != 'workflow_dispatch' && 'required' || inputs.structural && 'required' || 'off' }}
routing: ${{ github.event_name == 'workflow_dispatch' && inputs.routing && 'required' || 'off' }}
behavioral: ${{ github.event_name == 'workflow_dispatch' && inputs.behavioral && 'required' || 'off' }}
90 changes: 90 additions & 0 deletions skills/magpie/evals/evals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"evaluations": [
{
"id": "analyze-simple-hip-kernel",
"skill_should_trigger": true,
"prompt": "Use Magpie to prepare an analyze run for the existing examples/simple_hip_test/analyze_default.yaml fixture. Inspect the fixture and write analyze_plan.md with the exact command and an explanation of what the testcase validates. Do not compile or execute the kernel, install dependencies, or change the fixture, and do not claim that correctness or performance was measured.",
"workspace": "evals/files/analyze-simple-hip",
"expected_behavior": [
"Use Magpie analyze with examples/simple_hip_test/analyze_default.yaml and explain that the testcase exit code is what validates vector-add correctness"
],
"unexpected_behavior": [
"Compile or execute the HIP kernel, install dependencies, or claim measured correctness or performance results"
],
"logs_contain": [
"magpie analyze"
],
"files_exist": [
"analyze_plan.md"
]
},
{
"id": "compare-hip-variants",
"skill_should_trigger": true,
"prompt": "Use Magpie to prepare a comparison of these two existing HIP kernels: baseline/vector_add.hip and candidate/vector_add.hip. Write compare.yaml and give each implementation its own working_dir, hipcc compile_command, and testcase_command so Magpie builds and tests two separate binaries. Tell me the exact Magpie command, and treat correctness as a hard gate before any performance ranking. Keep the baseline as a named config entry instead of passing --baseline, because the comparison report does not consume that CLI selection. Do not compile or execute the kernels, and do not name a winner.",
"workspace": "evals/files/compare-hip-variants",
"expected_behavior": [
"Configure two independent Magpie compare candidates with separate working directories, compile commands, and testcase commands",
"Require correctness before performance ranking, without relying on the --baseline CLI option"
],
"unexpected_behavior": [
"Compile or execute either HIP kernel, or claim measured results or a winner"
],
"logs_contain": [
"magpie compare"
],
"files_exist": [
"compare.yaml"
]
},
{
"id": "benchmark-optimization-plan",
"skill_should_trigger": true,
"prompt": "I have a slow vLLM workload on AMD GPUs. Use Magpie to write benchmark_plan.md describing the shortest safe workflow from a clean baseline benchmark to profiling and TraceLens or gap analysis, then kernel analyze/compare, then a final clean benchmark. This environment has no model weights and no runnable benchmark setup, so do not install, download, or execute anything, and do not invent measured results.",
"expected_behavior": [
"Plan a clean baseline, a separate profiled run with TraceLens or gap analysis, correctness-gated kernel evaluation, and a final clean end-to-end benchmark"
],
"unexpected_behavior": [
"Run a benchmark, install or download anything, or claim measured results"
],
"files_exist": [
"benchmark_plan.md"
]
},
{
"id": "benchmark-vllm-ttft",
"skill_should_trigger": true,
"prompt": "Benchmark vLLM throughput and time-to-first-token for Llama 3 on this box, and capture torch traces while it runs."
},
{
"id": "compare-hip-softmax-kernels",
"skill_should_trigger": true,
"prompt": "I have two HIP implementations of a softmax kernel. Which one is faster, and is the optimized one still numerically correct?"
},
{
"id": "bottleneck-kernel-to-source",
"skill_should_trigger": true,
"prompt": "Find the top bottleneck kernels in my inference workload and map the profiler names back to the source that generates them."
},
{
"id": "rank-triton-attention-variants",
"skill_should_trigger": true,
"prompt": "Rank these three Triton attention kernel variants against each other and validate the winner end to end."
},
{
"id": "benchmark-then-optimize-kernel",
"skill_should_trigger": true,
"prompt": "Benchmark SGLang on this node, then rank two candidate HIP kernels for the biggest bottleneck and validate the winner."
},
{
"id": "write-a-cuda-transpose",
"skill_should_trigger": false,
"prompt": "Write a CUDA kernel that transposes a matrix, and explain the shared-memory tiling."
},
{
"id": "mi300x-spec-question",
"skill_should_trigger": false,
"prompt": "What is the theoretical peak FP16 throughput of an MI300X on paper?"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Simple vector_add — default correctness backend (testcase exit-code)
# Usage:
# cd /path/to/Magpie
# python -m Magpie analyze -k examples/simple_hip_test/analyze_default.yaml --no-perf
kernel:
id: "vector_add"
type: hip
source_files:
- "./vector_add.hip"
compile_command: "hipcc -g -O2 -o vector_add vector_add.hip"
testcase_command: "./vector_add"
working_dir: "examples/simple_hip_test"
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Simple HIP vector_add kernel for Magpie correctness testing.
// Compile: hipcc -g -O2 -o vector_add vector_add.hip
#include <hip/hip_runtime.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>

__global__ void vector_add(const float* a, const float* b, float* c, int n) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < n) {
c[idx] = a[idx] + b[idx];
}
}

int main() {
const int N = 1024;
const size_t bytes = N * sizeof(float);

float *h_a = (float*)malloc(bytes);
float *h_b = (float*)malloc(bytes);
float *h_c = (float*)malloc(bytes);

for (int i = 0; i < N; i++) {
h_a[i] = static_cast<float>(i);
h_b[i] = static_cast<float>(i * 2);
}

float *d_a, *d_b, *d_c;
hipMalloc(&d_a, bytes);
hipMalloc(&d_b, bytes);
hipMalloc(&d_c, bytes);

hipMemcpy(d_a, h_a, bytes, hipMemcpyHostToDevice);
hipMemcpy(d_b, h_b, bytes, hipMemcpyHostToDevice);

int blockSize = 256;
int gridSize = (N + blockSize - 1) / blockSize;
hipLaunchKernelGGL(vector_add, dim3(gridSize), dim3(blockSize), 0, 0,
d_a, d_b, d_c, N);

hipMemcpy(h_c, d_c, bytes, hipMemcpyDeviceToHost);

int errors = 0;
for (int i = 0; i < N; i++) {
float expected = h_a[i] + h_b[i];
if (fabs(h_c[i] - expected) > 1e-5f) {
fprintf(stderr, "Mismatch at %d: got %f, expected %f\n",
i, h_c[i], expected);
errors++;
}
}

hipFree(d_a);
hipFree(d_b);
hipFree(d_c);
free(h_a);
free(h_b);
free(h_c);

if (errors == 0) {
printf("PASSED: All %d elements correct.\n", N);
return 0;
} else {
printf("FAILED: %d errors.\n", errors);
return 1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Simple HIP vector_add kernel for Magpie correctness testing.
// Compile: hipcc -g -O2 -o vector_add vector_add.hip
#include <hip/hip_runtime.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>

__global__ void vector_add(const float* a, const float* b, float* c, int n) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < n) {
c[idx] = a[idx] + b[idx];
}
}

int main() {
const int N = 1024;
const size_t bytes = N * sizeof(float);

float *h_a = (float*)malloc(bytes);
float *h_b = (float*)malloc(bytes);
float *h_c = (float*)malloc(bytes);

for (int i = 0; i < N; i++) {
h_a[i] = static_cast<float>(i);
h_b[i] = static_cast<float>(i * 2);
}

float *d_a, *d_b, *d_c;
hipMalloc(&d_a, bytes);
hipMalloc(&d_b, bytes);
hipMalloc(&d_c, bytes);

hipMemcpy(d_a, h_a, bytes, hipMemcpyHostToDevice);
hipMemcpy(d_b, h_b, bytes, hipMemcpyHostToDevice);

int blockSize = 256;
int gridSize = (N + blockSize - 1) / blockSize;
hipLaunchKernelGGL(vector_add, dim3(gridSize), dim3(blockSize), 0, 0,
d_a, d_b, d_c, N);

hipMemcpy(h_c, d_c, bytes, hipMemcpyDeviceToHost);

int errors = 0;
for (int i = 0; i < N; i++) {
float expected = h_a[i] + h_b[i];
if (fabs(h_c[i] - expected) > 1e-5f) {
fprintf(stderr, "Mismatch at %d: got %f, expected %f\n",
i, h_c[i], expected);
errors++;
}
}

hipFree(d_a);
hipFree(d_b);
hipFree(d_c);
free(h_a);
free(h_b);
free(h_c);

if (errors == 0) {
printf("PASSED: All %d elements correct.\n", N);
return 0;
} else {
printf("FAILED: %d errors.\n", errors);
return 1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Simple HIP vector_add kernel for Magpie correctness testing.
// Candidate variant: 128-thread blocks where the baseline uses 256.
// Compile: hipcc -g -O2 -o vector_add vector_add.hip
#include <hip/hip_runtime.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>

__global__ void vector_add(const float* a, const float* b, float* c, int n) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < n) {
c[idx] = a[idx] + b[idx];
}
}

int main() {
const int N = 1024;
const size_t bytes = N * sizeof(float);

float *h_a = (float*)malloc(bytes);
float *h_b = (float*)malloc(bytes);
float *h_c = (float*)malloc(bytes);

for (int i = 0; i < N; i++) {
h_a[i] = static_cast<float>(i);
h_b[i] = static_cast<float>(i * 2);
}

float *d_a, *d_b, *d_c;
hipMalloc(&d_a, bytes);
hipMalloc(&d_b, bytes);
hipMalloc(&d_c, bytes);

hipMemcpy(d_a, h_a, bytes, hipMemcpyHostToDevice);
hipMemcpy(d_b, h_b, bytes, hipMemcpyHostToDevice);

int blockSize = 128;
int gridSize = (N + blockSize - 1) / blockSize;
hipLaunchKernelGGL(vector_add, dim3(gridSize), dim3(blockSize), 0, 0,
d_a, d_b, d_c, N);

hipMemcpy(h_c, d_c, bytes, hipMemcpyDeviceToHost);

int errors = 0;
for (int i = 0; i < N; i++) {
float expected = h_a[i] + h_b[i];
if (fabs(h_c[i] - expected) > 1e-5f) {
fprintf(stderr, "Mismatch at %d: got %f, expected %f\n",
i, h_c[i], expected);
errors++;
}
}

hipFree(d_a);
hipFree(d_b);
hipFree(d_c);
free(h_a);
free(h_b);
free(h_c);

if (errors == 0) {
printf("PASSED: All %d elements correct.\n", N);
return 0;
} else {
printf("FAILED: %d errors.\n", errors);
return 1;
}
}
Loading