gala-diff
Work with Gala's native differentiation — parameter-shift for quantum params, reverse-mode autodiff for classical, chain-rule composition
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-diff
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-diff
Tools it pre-approves 9
From allowed-tools in SKILL.md: the agent may use these without asking you each time.
Bash(cargobuild*)testReadWriteEditGlobGrep
What's inside
- Skill name
gala-diff- Description
- Work with Gala's native differentiation — parameter-shift for quantum params, reverse-mode autodiff for classical, chain-rule composition
- License
- Apache-2.0
- Allowed tools
- Bash(cargo, build, *), Bash(cargo, test, *), Read, Write, Edit, Glob, Grep
- Instructions
- 94 lines in SKILL.md · view on GitHub
Before installing
- Pre-approves some shell commands
Files (1)
- SKILL.md
SKILL.md (first lines)
## Task
$ARGUMENTS
## Context
Gala's differentiation pass (`crates/gala-diff`) lowers `grad(f, wrt: p)` to GIR. It handles:
- **Quantum parameters** (rotation angles) → **parameter-shift rule**
- **Classical parameters** → **reverse-mode autodiff**
- **Chain rule composition** at quantum/classical boundary
> **Note on file layout:** The crate currently lives in a single `crates/gala-diff/src/lib.rs`. As it matures it may be split into `lower.rs`, `param_shift.rs`, `autodiff.rs`, `compose.rs`, `gradient.rs` (see `docs/ARCHITECTURE.md`). When in doubt, search for the relevant code in `lib.rs`.
Key files:
- `crates/gala-diff/src/lib.rs` — `grad` lowering, parameter-shift, reverse-mode autodiff, chain rule
## Common Tasks
### Add parameter-shift for new quantum gate
1. Edit `lib.rs` — add shift rule for gate's parameter
2. For `RX(θ)`, `RY(θ)`, `RZ(θ)`: shift by ±π/2, evaluate, combine
3. For controlled variants: ensure control qubit handled correctly
4. Add test in `tests/conformance/diff/` with known gradient
### Extend classical autodiff
1. Edit `lib.rs` — add reverse-mode rule for new classical op
2. Define `vjp` (vector-Jacobian product) for the op
3. Handle higher-order derivatives if needed
4. Test against finite differences
### Modify chain rule composition
1. Edit `lib.rs` — handles quantum output → classical input boundary
2. Parameter-shift produces classical gradients; autodiff consumes them
3. Ensure correct gradient flow through hybrid functions
### Add new `grad` feature (e.g., Hessian, Jacobian)
1. Extend gradient representation in `lib.rs`
2. Add lowering
3. Update `grad_matches` property test harness
## Testing
```bash
cargo test -p gala-diff # Unit tests
cargo test --workspace diff # All diff tests
cargo test --workspace conformity/diff # Conformance suite
# Property test: grad_matches finite difference
cargo test --workspace -- grad_matches
```
## Conventions
- **Gradients are first-class GIR** — visible to optimizer, backends
- **Parameter-shift is exact** (up to floating point) for quantum params
- **Autodiff is reverse-mode** — efficient for many inputs, one output
- **Chain rule at boundary** — quantum grads feed classical autodiff
- **No runtime library** — all at compile time via GIR lowering
- Diagnostic codes: E06xx for differentiation errors
## Key Concepts
```rust
// Parameter-shift for RX(θ): d/dθ RX(θ) = 0.5 * (RX(θ+π/2) - RX(θ-π/2))
pub fn param_shift_gradient_gir(
gir: &Gir,
func_id: FuncId,
param_idx: usize,
shift: f64,
) -> Result<Gir, Diagnostics>
// Reverse-mode autodiff for classical: build adjoint computation graph
pub fn reverse_mode_autodiff_gir(
gir: &Gir,
source_id: FuncId,
param_indices: &[usize],
) -> Result<(Gir, Vec<ValueId>), Diagnostics>
// Main entry point: lower all gradients for pure functions
pub fn lower_gradients(gir: &mut Gir)
```
## Debugging
```bash
# Debug gradient lowering
cargo run --bin gala -- --emit gir-diff examples/variational.gala
# Compare with finite difference
cargo run --bin gala -- run examples/variational.gala --check-grad
# Property test output
cargo test --workspace -- grad_matches -- --nocapture
```From gala-pl/gala, Apache-2.0.
More from gala-pl/gala
- 0.581score
gala-debug-programs
gala-pl
Debug Gala programs — compiler diagnostics, simulator inspection, REPL visualization, property test failures
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-performance
gala-pl
Optimize Gala program performance — gate count, circuit depth, gradient cost, compilation time
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
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.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-performance
gala-pl
Optimize Gala program performance — gate count, circuit depth, gradient cost, compilation time
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-debug-programs
gala-pl
Debug Gala programs — compiler diagnostics, simulator inspection, REPL visualization, property test failures
SkillAFreshness: A★ 1Claude Code +9
Cite this page
gala-diff skill. Agent Mart. https://agentmart.dev/skills/gala-pl-gala-diff (last updated 2026-10-24)