Skip to content
Agentmart
Submit a tool

gala-vqa-programming

Build variational quantum algorithms in Gala — encoders, ansätze, optimizers, native grad

Skill by gala-pl

IndexedApache-2.0★ 1
Write a review

Chalk Labs

Need help deploying gala-vqa-programming?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/gala-pl-gala-vqa-programming

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Build variational quantum algorithms in Gala — encoders, ansätze, optimizers, native grad

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Nov 1, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/gala-vqa-programming

Tools it pre-approves 10

From allowed-tools in SKILL.md: the agent may use these without asking you each time.

  • Bash(cargo
  • run
  • --bin
  • gala
  • *)
  • Read
  • Write
  • Edit
  • Glob
  • Grep

What's inside

Skill name
gala-vqa-programming
Description
Build variational quantum algorithms in Gala — encoders, ansätze, optimizers, native grad
License
Apache-2.0
Allowed tools
Bash(cargo, run, --bin, gala, *), Read, Write, Edit, Glob, Grep
Instructions
211 lines in SKILL.md · view on GitHub

Before installing

  • Pre-approves some shell commands

Files (1)

  • SKILL.md

SKILL.md (first lines)

## Task

$ARGUMENTS

## Overview

Gala has **native differentiation** (`grad`) that works end-to-end across hybrid quantum-classical code. This skill covers building VQA/VQE/QAOA programs with parameter-shift gradients.

## VQA Standard Library

```gala
import gala.vqa.{ angle_encode, amplitude_encode, layered_ansatz, hardware_efficient_ansatz }
import gala.vqa.{ gd_optimizer, adam_optimizer, spsa_optimizer, Params }
```

## Complete VQA Example

```gala
import gala.vqa.{ angle_encode, layered_ansatz, adam_optimizer, Params }
import gala.core.{ grad, measure }

// 1. Data encoding (classical → quantum)
fn encode(x: Vec<Float>) -> Qubits<4> quantum {
    let q = qubits<4>()
    angle_encode(q, x)  // Ry(x[i]) on each qubit
    q
}

// 2. Variational ansatz (parameterized quantum circuit)
fn ansatz(q: Qubits<4>, θ: Params) -> Qubits<4> quantum {
    layered_ansatz(q, θ, depth: 3)  // Ry + CZ layers
    // Or custom:
    // for layer in 0..θ.depth {
    //     for i in 0..4 { ry(q[i], θ[layer][i]) }
    //     for i in 0..3 { cx(q[i], q[i+1]) }
    // }
    q
}

// 3. Classifier (hybrid: quantum + measure)
fn classify(x: Vec<Float>, θ: Params) -> Measured<Bool> prob {
    let q = ansatz(encode(x), θ)
    measure(q[0])  // Measure first qubit
}

// 4. Native gradient (parameter-shift for θ, autodiff for x)
let dθ = grad(classify, wrt: θ)  // Returns fn(Vec<Float>, Params) -> Params

// 5. Training loop
fn train(dataset: [(Vec<Float>, Bool)], epochs: Int) -> Params {
    let mut θ = Params::random(4, 3)  // 4 qubits, 3 layers
    let opt = adam_optimizer(lr: 0.01)
    
    for epoch in 0..epochs {
        for (x, y) in dataset {
            let g = dθ(x, θ)  // Gradient wrt θ
            θ = opt.step(θ, g)
        }
    }
    θ
}
```

## Key Components

### Encoders
```gala
// Angle encoding: Ry(x[i]) on qubit i
angle_encode(q: Qubits<N>, x: Vec<Float>) -> Qubits<N> quantum

// Amplitude encoding: prepare state ∑ x[i]|i⟩ (requires normalization)
amplitude_encode(q: Qubits<N>, x: Vec<Float>) -> Qubits<N> quantum

// Basis encoding: |x⟩ for binary data
basis_encode(q: Qubits<N>, x: Vec<Bool>) -> Qubits<N> quantum
```

### Ansatz Zoo
```gala
// Layered: alternating Ry + entangling layer
layered_ansatz(q: Qubits<N>, θ: Params, depth: Int) -> Qubits<N> quantum

// Hardware-efficient: native gate set for target backend
hardware_efficient_ansatz(q: Qubits<N>, θ: Params, topology: Topology) -> Qubits<N> quantum

// QAOA: problem + mixer Hamiltonians
qaoa_ansatz(q: Qubits<N>, θ: Params, problem: Hamiltonian) -> Qubits<N> quantum

// Custom: build from gates
fn my_ansatz(q: Qubits<4>, θ: Params) -> Qubits<4> quantum {
    for i in 0..4 { ry(q[i], θ[0][i]) }
    cx(q[0], q[1]); cx(q[2], q[3])
    for i in 0..4 { rz(q[i], θ[1][i]) }
    q
}
```

### Optimizers
```gala
// Gradient descent
gd_optimizer(lr: Float) -> Optimizer

// Adam (adaptive moments)
adam_optimizer(lr: Float, beta1: Float, beta2: Float) -> Optimizer

// SPSA (simultaneous perturbation — 2 circuit evals/step)
spsa_optimizer(lr: Float, c: Float) -> Optimizer

// Usage
let opt = adam_optimizer(lr: 0.01)
θ = opt.step(θ, gradient)
```

## How `grad` Works

```
grad(f, wrt: θ) where f: (X, θ) → Measured<T>
```

From gala-pl/gala, Apache-2.0.

More from gala-pl/gala

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
Oct 23, 2026 (9 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from gala-pl

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get gala-vqa-programming running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying gala-vqa-programming?

CallGet help
Cite this page

gala-vqa-programming skill. Agent Mart. https://agentmart.dev/skills/gala-pl-gala-vqa-programming (last updated 2026-10-24)