- Renamed aitbc-ai-service to aitbc-ai - Renamed aitbc-edge-api to aitbc-edge - Updated pyproject.toml files with new package names - Renamed directories and package modules - Updated references in documentation and scripts - Updated systemd service references
9.2 KiB
AI Job Submission for hermes Agents
Level: Beginner
Prerequisites: Wallet Basics (Scenario 01), AITBC CLI installed
Estimated Time: 25 minutes
Last Updated: 2026-05-02
Version: 1.0
🧭 Navigation Path:
🏠 Documentation Home → 🎭 Agent Scenarios → You are here
breadcrumb: Home → Scenarios → AI Job Submission
🎯 See Also:
- 📖 Previous Scenario: 06 Basic Trading
- 📖 Next Scenario: 08 Marketplace Bidding
- 🤖 Agent SDK: Agent SDK Documentation
- 🤖 AI Service: AI Service Documentation
📚 Scenario Overview
This scenario demonstrates how hermes agents submit AI compute jobs to the AITBC network for distributed processing on GPU resources.
Use Case
An hermes agent needs to submit AI jobs to:
- Train machine learning models
- Run inference on large datasets
- Process natural language tasks
- Execute computer vision operations
- Perform data analysis
What You'll Learn
- Submit AI compute jobs
- Specify job parameters and requirements
- Monitor job progress
- Retrieve job results
- Handle job failures
Features Combined
- Wallet Operations (Scenario 01)
- AI Service Integration: Job submission and monitoring
- Compute Resource Management: GPU resource allocation
📋 Prerequisites
Knowledge Required
- Completed Scenario 01 (Wallet Basics)
- Understanding of AI/ML workloads
- Job queue concepts
Tools Required
- AITBC CLI installed
- Python 3.13+
- Access to AITBC coordinator API
- Wallet with AIT tokens for payment
Setup Required
- Coordinator API running
- GPU marketplace available
- Wallet with AIT tokens for payment
Wallet Authentication
For AI job submission requiring wallet payments, use one of these methods:
# Interactive prompt (default)
aitbc ai submit --wallet my-wallet --model llama2 --prompt "Hello world"
# Password file (recommended for scripts)
aitbc ai submit --wallet my-wallet --model llama2 --prompt "Hello world" --password-file /path/to/password.txt
# Environment variable
export KEYSTORE_PASSWORD=mypassword
aitbc ai submit --wallet my-wallet --model llama2 --prompt "Hello world"
Security Best Practices:
- Use password files with restricted permissions (chmod 600)
- Store password files outside the repository
- Avoid hardcoding passwords in scripts
- Wallet with sufficient balance
🔧 Step-by-Step Workflow
Step 1: Submit an AI Job
Submit a simple AI inference job to the network.
aitbc ai submit \
--wallet my-agent-wallet \
--job-type inference \
--model llama2-7b \
--prompt "What is the capital of France?" \
--payment 10
Output:
AI job submitted
Job ID: job_abc123...
Type: inference
Model: llama2-7b
Payment: 10 AIT
Status: pending
Step 2: Check Job Status
Monitor the progress of your job.
aitbc ai status --job-id job_abc123...
Output:
Job ID: job_abc123...
Status: processing
Progress: 45%
GPU Provider: ait1gpu1...
Estimated Time: 120s
Step 3: Retrieve Job Results
Get the results when the job completes.
aitbc ai results --job-id job_abc123...
Output:
Job ID: job_abc123...
Status: completed
Result: The capital of France is Paris.
Duration: 95s
Cost: 10 AIT
Step 4: Submit Batch Jobs
Submit multiple jobs for processing.
aitbc ai batch \
--wallet my-agent-wallet \
--jobs jobs.json
jobs.json:
[
{
"job_type": "inference",
"model": "llama2-7b",
"prompt": "Question 1",
"payment": 10
},
{
"job_type": "inference",
"model": "llama2-7b",
"prompt": "Question 2",
"payment": 10
}
]
Step 5: List Job History
View your past AI jobs.
aitbc ai history --wallet my-agent-wallet --limit 10
💻 Code Examples Using Agent SDK
Example 1: Submit Simple Inference Job
from aitbc_agent_sdk import Agent, AgentConfig
config = AgentConfig(
name="ai-agent",
blockchain_network="mainnet",
wallet_name="ai-wallet"
)
agent = Agent(config)
agent.start()
# Submit AI inference job
job = agent.submit_ai_job(
job_type="inference",
model="llama2-7b",
prompt="What is the capital of France?",
payment=10
)
print(f"Job submitted: {job['job_id']}")
print(f"Status: {job['status']}")
# Wait for completion
result = agent.wait_for_job_completion(job['job_id'], timeout=300)
print(f"Result: {result['output']}")
Example 2: Submit Training Job with Custom Parameters
from aitbc_agent_sdk import Agent, AgentConfig
import asyncio
async def submit_training_job():
config = AgentConfig(
name="training-agent",
blockchain_network="mainnet",
wallet_name="training-wallet"
)
agent = Agent(config)
await agent.start()
# Submit training job
job = await agent.submit_ai_job(
job_type="training",
model="custom-model",
dataset_hash="QmHash123...",
epochs=10,
batch_size=32,
learning_rate=0.001,
payment=100
)
print(f"Training job submitted: {job['job_id']}")
# Monitor progress
while True:
status = await agent.get_job_status(job['job_id'])
print(f"Progress: {status['progress']}% - Epoch: {status.get('current_epoch', 0)}/{status.get('total_epochs', 10)}")
if status['status'] == 'completed':
print(f"Training completed! Model hash: {status['model_hash']}")
break
elif status['status'] == 'failed':
print(f"Training failed: {status['error']}")
break
await asyncio.sleep(30)
asyncio.run(submit_training_job())
Example 3: Distributed AI Training
from aitbc_agent_sdk import Agent, AgentConfig
import asyncio
class DistributedTrainer:
def __init__(self, config):
self.agent = Agent(config)
async def start(self):
await self.agent.start()
async def train_distributed(self, dataset_hash, num_workers=4):
"""Coordinate distributed training across multiple GPUs"""
# Split dataset into shards
shards = await self.split_dataset(dataset_hash, num_workers)
# Submit training jobs to different workers
jobs = []
for i, shard in enumerate(shards):
job = await self.agent.submit_ai_job(
job_type="training",
model="distributed-model",
dataset_hash=shard,
worker_id=i,
total_workers=num_workers,
payment=25
)
jobs.append(job)
# Wait for all jobs to complete
results = await asyncio.gather(*[
self.agent.wait_for_job_completion(job['job_id'], timeout=600)
for job in jobs
])
# Aggregate results
aggregated_model = await self.aggregate_models(results)
print(f"Distributed training complete. Aggregated model: {aggregated_model}")
async def main():
config = AgentConfig(
name="distributed-trainer",
blockchain_network="mainnet",
wallet_name="distributed-wallet"
)
trainer = DistributedTrainer(config)
await trainer.start()
await trainer.train_distributed("QmDatasetHash...", num_workers=4)
asyncio.run(main())
🎯 Expected Outcomes
After completing this scenario, you should be able to:
- Submit AI compute jobs
- Monitor job progress
- Retrieve job results
- Handle job failures
- Implement distributed AI training
🧪 Validation
Validate this scenario with the shared 3-node harness:
bash scripts/workflow/44_comprehensive_multi_node_scenario.sh
Node coverage:
aitbc1: genesis / primary node checksaitbc: follower / local node checksgitea-runner: automation / CI node checks
Validation guide:
Expected result:
- Scenario-specific commands complete successfully
- Cross-node health checks pass
- Blockchain heights remain in sync
- Any node-specific step is documented in the scenario workflow
🔗 Related Resources
AITBC Documentation
External Resources
Next Scenarios
- 22 AI Training Agent - Advanced AI workflows
- 32 AI Power Advertiser - AI for advertising
- 37 Distributed AI Training - Complex distributed training
📊 Quality Metrics
- Structure: 10/10 - Clear AI job submission workflow
- Content: 10/10 - Comprehensive AI operations
- Code Examples: 10/10 - Working Agent SDK examples
- Status: Active scenario
Last updated: 2026-05-02
Version: 1.0
Status: Active scenario document