Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

13 Commits

Folders and files

Repository files navigation

๐Ÿ‘จโ€๐Ÿ’ป Quantum Developer Agent

Expert agent in quantum code generation and quantum computing concept explanations.

๐ŸŽฏ Overview

The Quantum Developer Agent is a specialized AI agent that generates quantum code (QASM and Qiskit), explains quantum computing concepts, and implements classical quantum algorithms like Grover, Shor, Deutsch-Jozsa, and more.

Key Features

  • ๐Ÿ”ฌ Quantum Code Generation: Creates clean and efficient QASM 2.0/3.0 and Qiskit code
  • ๐Ÿ“š Concept Explanations: Provides detailed explanations of quantum computing concepts
  • ๐Ÿงฎ Algorithm Implementation: Implements classical quantum algorithms (Grover, Shor, Deutsch-Jozsa, QFT, etc.)
  • โšก Code Optimization: Suggests optimizations to reduce gates and circuit depth
  • ๐Ÿ“– Documentation: Generates well-documented code with helpful comments

๐Ÿ—๏ธ Architecture

  • Model: Granite 4.2 8B via Ollama (ollama:granite4.2:8b)
  • Port: 8001
  • Type: AgentStack Server with A2A protocol
  • Tools: None (Pure LLM for code generation)
  • Framework: BeeAI + Granite/Ollama + A2A

๐Ÿ“‹ Prerequisites

  • Python 3.11+
  • Ollama with granite4.2:8b (Watsonx remains an optional fallback)

๐Ÿ“ฆ Project Dependencies

Main Dependencies (pyproject.toml)

[project]
requires-python = ">=3.11,<4.0"
dependencies = [
    "agentstack-sdk==0.4.0rc1",      # Framework for creating agents
    "beeai_framework>=0.1.76",        # BeeAI Framework for agents
    "python-dotenv>=1.0.0",           # Environment variable management
]

System Dependencies

  1. Python 3.11+

    python --version  # Must be 3.11 or higher
  2. uv (Package Manager - Recommended)

    # Install uv
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
    # Verify installation
    uv --version
  3. IBM Watsonx (Credentials required)

๐ŸŽฏ Specific Purpose

This agent is the quantum code generation specialist of the multi-agent system:

Responsibilities:

  • โœ… Generate clean and efficient QASM 2.0/3.0 code
  • โœ… Create documented Qiskit code
  • โœ… Explain quantum computing concepts
  • โœ… Implement classical quantum algorithms
  • โœ… Optimize quantum circuits
  • โœ… Provide educational examples

Does NOT:

  • โŒ Does not execute circuits (use Computing Agent for that)
  • โŒ Does not query backend status (use Status Agent)
  • โŒ Does not retrieve job results (use Status Agent)

Communication:

  • Receives requests via A2A from Operations Agent (port 8000)

  • Responds with QASM/Qiskit code and explanations

  • Can be invoked directly on port 8001

  • uv package manager (recommended) or pip

๐Ÿš€ Quick Start

1. Clone and Setup

cd quantum-developer-agent

# Install dependencies
uv sync
# or
pip install -e .

2. Configure Environment

Create .env file from template:

cp .env.example .env

Edit .env with your credentials:

# Watsonx
WATSONX_API_KEY=your_watsonx_api_key_here
WATSONX_PROJECT_ID=your_project_id_here
WATSONX_API_URL=https://us-south.ml.cloud.ibm.com/ml/v1/text/chat?version=2023-05-29

# Developer Agent Configuration
OLLAMA_API_BASE=http://127.0.0.1:11434
DEVELOPER_MODEL=ollama:granite4.2:8b
DEVELOPER_HOST=127.0.0.1
DEVELOPER_PORT=8001

3. Start the Agent

# Using the start script (recommended)
./start.sh

# Or directly with uv
uv run server

# Or with Python
python -m quantum_developer_agent.agent

4. Verify Agent is Running

curl http://localhost:8001/.well-known/agent-card.json

๐Ÿ’ฌ Usage Examples

Example 1: Generate a Bell State Circuit

curl -X POST http://localhost:8001 \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [{
      "role": "user",
      "content": "Create a Bell state circuit in QASM"
    }]
  }'

Response includes:

  • Complete QASM 2.0 code
  • Detailed explanation of the circuit
  • Expected measurement results
  • Practical applications

Example 2: Implement Grover's Algorithm

curl -X POST http://localhost:8001 \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [{
      "role": "user",
      "content": "Implement Grover'\''s algorithm for 3 qubits"
    }]
  }'

Response includes:

  • Complete Grover's algorithm implementation
  • Oracle and diffuser components
  • Step-by-step explanation
  • Quantum advantage analysis

Example 3: Explain Quantum Concepts

curl -X POST http://localhost:8001 \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [{
      "role": "user",
      "content": "Explain what quantum entanglement is"
    }]
  }'

Response includes:

  • Detailed 3-4 paragraph explanation
  • QASM code example demonstrating entanglement
  • How the code works
  • Practical applications

๐Ÿงฎ Supported Algorithms

The agent has deep knowledge of these quantum algorithms:

Search & Optimization

  • Grover's Algorithm: Quantum search with O(โˆšN) complexity
  • Amplitude Amplification: Generalization of Grover

Function Analysis

  • Deutsch-Jozsa Algorithm: Determine if function is constant or balanced
  • Bernstein-Vazirani Algorithm: Find hidden binary string
  • Simon's Algorithm: Find period of function with hidden symmetry

Transforms & Factorization

  • Quantum Fourier Transform (QFT): Quantum analog of DFT
  • Shor's Algorithm: Integer factorization in polynomial time

Basic Circuits

  • Bell States, GHZ States, W States
  • Quantum Teleportation
  • Superdense Coding
  • Swap Test

๐Ÿ”ง Development

Project Structure

quantum-developer-agent/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ quantum_developer_agent/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ””โ”€โ”€ agent.py          # Main agent implementation
โ”œโ”€โ”€ .env.example              # Environment template
โ”œโ”€โ”€ .gitignore               # Git ignore rules
โ”œโ”€โ”€ Dockerfile               # Docker configuration
โ”œโ”€โ”€ pyproject.toml           # Project dependencies
โ”œโ”€โ”€ start.sh                 # Start script
โ””โ”€โ”€ README.md                # This file

Dependencies

dependencies = [
    "agentstack-sdk==0.4.0rc1",
    "beeai_framework>=0.1.76",
    "python-dotenv>=1.0.0",
]

Running with Docker

# Build image
docker build -t quantum-developer-agent .

# Run container
docker run -p 8001:8001 --env-file .env quantum-developer-agent

# Run in background
docker run -d -p 8001:8001 --env-file .env --name quantum-dev quantum-developer-agent

# View logs
docker logs -f quantum-dev

# Stop container
docker stop quantum-dev

Running with uv

The project is configured to use uv for dependency management and execution:

# Install dependencies
uv sync

# Run the server
uv run server

# Run with custom port
DEVELOPER_PORT=9001 uv run server

๐Ÿ”— Integration with Other Agents

This agent is designed to work as part of the Quantum Lab Agent System:

  • Invoked by: Quantum Lab Agent (Port 8000)
  • Communication: A2A protocol (Agent-to-Agent)
  • Purpose: Generate quantum code when requested by the orchestrator

Standalone Usage

While designed for A2A communication, the agent can also be used standalone:

import requests

response = requests.post(
    "http://localhost:8001",
    json={
        "messages": [{
            "role": "user",
            "content": "Create a superposition circuit"
        }]
    }
)

print(response.json())

๐Ÿ› Troubleshooting

Agent Won't Start

Problem: Port already in use

# Find process using port 8001
lsof -i :8001

# Kill process
kill -9 <PID>

Problem: Missing dependencies

# Reinstall dependencies
uv sync --reinstall

Agent Not Responding

Problem: Watsonx API errors

  • Check your API key in .env
  • Verify project ID is correct
  • Check Watsonx service status
  • For local inference, run ollama pull granite4.2:8b

Code Generation Issues

Problem: Agent generates wrong algorithm

  • Be specific in your request
  • Use exact algorithm names (e.g., "Grover's algorithm" not "search algorithm")
  • The agent is trained to distinguish between different algorithms

๐Ÿ”— Related Repositories

This agent is part of the Quantum Computing Multi-Agent System. Here are the related repositories:

๐Ÿ“š Additional Resources

๐Ÿค Contributing

This agent is part of the Quantum Lab Agent System. For contributions, please refer to the main system repository.

๐Ÿ“„ License

Apache 2.0 License

๐Ÿ™ Acknowledgments


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages