gala-performance
Optimize Gala program performance — gate count, circuit depth, gradient cost, compilation time
Skill by gala-pl
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-performance
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.
About
Reviews
Write a reviewNo 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. Checked Oct 25, 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-performance
Tools it pre-approves 10
From allowed-tools in SKILL.md: the agent may use these without asking you each time.
Bash(cargorun--bingala*)ReadWriteEditGlobGrep
What's inside
- Skill name
gala-performance- Description
- Optimize Gala program performance — gate count, circuit depth, gradient cost, compilation time
- License
- Apache-2.0
- Allowed tools
- Bash(cargo, run, --bin, gala, *), Read, Write, Edit, Glob, Grep
- Instructions
- 220 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
Performance in Gala has multiple dimensions: **circuit quality** (gates/depth), **gradient cost** (device submissions), **simulation speed**, and **compile time**.
## Circuit Optimization (gala-opt)
### Automatic Passes
```bash
# See optimized GIR
gala build src/main.gala --emit gir-opt
# Compare gate counts
gala build src/main.gala --emit gir # Before
gala build src/main.gala --emit gir-opt # After
```
### Key Optimizations
| Pass | Effect |
|------|--------|
| `AdjacentCancellation` | `H;H` → `I`, `X;X` → `I`, `CX(a,b);CX(a,b)` → `I` |
| `RotationMerge` | `RX(a);RX(b)` → `RX(a+b)` |
| `SingleQubitFusion` | `U1;U2;U3` → single `Unitary` |
| `TwoQubitCancellation` | Adjacent inverse pairs |
| `AncillaScheduling` | Reorder to minimize live ancillae |
| `ConstantFolding` | Classical: `2+3` → `5` |
| `DeadCodeElimination` | Remove unused pure computations |
| `InlineSmallPure` | Inline small `pure` functions |
### Manual Optimization Tips
**1. Fuse rotations yourself when possible:**
```gala
// Instead of:
rx(q, a); ry(q, b); rz(q, c)
// Use single unitary if available, or let optimizer fuse
```
**2. Minimize ancilla scope:**
```gala
// Good: ancilla allocated late, dropped early
fn good() {
let a = qubit()
let b = qubit()
cx(a, b)
b // ancilla dropped here → auto-uncomputed
}
// Avoid: ancilla lives longer than needed
fn bad() {
let anc = qubit() // Lives through entire function
// ... many ops ...
drop(anc) // Late drop = more qubits simultaneously
}
```
**3. Use `Qubits<N>` for register operations:**
```gala
// Efficient: single loop over register
for i in 0..N { h(qs[i]) }
// Less efficient: individual qubits
let q0 = qubit(); let q1 = qubit(); ...
```
## Gradient Cost Optimization
### Parameter-Shift Batching (Automatic)
```gala
// Before optimization: 2N submissions for N params
// After: 2 submissions (all +π/2, all -π/2)
let dθ = grad(f, wrt: θ) // Runtime handles batching
```
### Check Gradient Cost
```bash
gala run src/vqa.gala --bench-grad
```
Output:
```
Gradient benchmark:
Parameters: 24
Submissions (unbatched): 48
Submissions (batched): 2
Speedup: 24x
Wall time: 2.3s (vs 55s unbatched)
```
### Reduce Gradient Cost
1. **Fewer parameters** — smaller ansatz, parameter sharing
2. **SPSA optimizer** — 2 evals/step vs 2N for gradient descent
3. **Analytic gradients where possible** — some gates have known gradients
4. **Shot allocation** — more shots for sensitive params, fewer for others
```gala
// SPSA: only 2 circuit evaluations per step
let opt = spsa_optimizer(lr: 0.01, c: 0.1)
θ = opt.step(θ, loss_fn) // No explicit grad needed!
```
## Compilation Performance
### Incremental Compilation
```bash
# First build (cold)
gala build src/main.gala
# Edit one file, rebuild (incremental — uses salsa)
gala build src/main.gala # Much faster
```
### Frontend-Only Check (No LLVM/QuEST)
```bash
# Fast type-check without backend compilationFrom gala-pl/gala, Apache-2.0.
More from gala-pl/gala
- 0.584score
gala-diff
gala-pl
Work with Gala's native differentiation — parameter-shift for quantum params, reverse-mode autodiff for classical, chain-rule composition
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-hardware-backends
gala-pl
Run Gala programs on quantum hardware — backend selection, capability checking, QIR emission, vendor SDKs
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-language-basics
gala-pl
Learn Gala language fundamentals — syntax, types, effects, linear qubits, basic quantum operations
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-noise-modeling
gala-pl
Model and simulate noise in Gala — typed noise models, QuEST noise channels, error mitigation
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-python-interop
gala-pl
Call Gala from Python — PyO3 bridge, Jupyter kernel, PyTorch integration, NumPy arrays
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-quantum-algorithms
gala-pl
Implement quantum algorithms in Gala — QFT, Grover, phase estimation, adders, oracles
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-vqa-programming
gala-pl
Build variational quantum algorithms in Gala — encoders, ansätze, optimizers, native grad
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-ast
gala-pl
Work with Gala's AST — add node types, implement visitors, maintain CST/AST separation
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-codegen-classical
gala-pl
Work with Gala's classical codegen — Cranelift (debug) and LLVM (release) for orchestration layer
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-driver
gala-pl
Work with Gala's compilation driver — salsa DB orchestration, incremental queries, pipeline wiring
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
debug-compiler
gala-pl
Debug a compiler error or unexpected behavior in Gala source code
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-cookbook
gala-pl
Gala recipes — common patterns, idioms, algorithms, VQA templates, error handling
SkillAFreshness: A★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 23, 2026 (5 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Repository
- github.com/gala-pl/gala
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from gala-pl
- 0.584score
gala-diff
gala-pl
Work with Gala's native differentiation — parameter-shift for quantum params, reverse-mode autodiff for classical, chain-rule composition
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-language-basics
gala-pl
Learn Gala language fundamentals — syntax, types, effects, linear qubits, basic quantum operations
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-noise-modeling
gala-pl
Model and simulate noise in Gala — typed noise models, QuEST noise channels, error mitigation
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-python-interop
gala-pl
Call Gala from Python — PyO3 bridge, Jupyter kernel, PyTorch integration, NumPy arrays
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-quantum-algorithms
gala-pl
Implement quantum algorithms in Gala — QFT, Grover, phase estimation, adders, oracles
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
gala-hardware-backends
gala-pl
Run Gala programs on quantum hardware — backend selection, capability checking, QIR emission, vendor SDKs
SkillAFreshness: A★ 1Claude Code +9
Cite this page
gala-performance skill. Agent Mart. https://agentmart.dev/skills/gala-pl-gala-performance (last updated 2026-10-24)