Implement Inter-Blockchain Communication (IBC) SDK with full ICS protocol support across all 12 programming languages: - JavaScript/TypeScript, Python, Go, Rust - Java, Kotlin, Swift, Flutter/Dart - C, C++, C#/.NET, Ruby Features: - Light client management (Tendermint, Solo Machine, WASM) - Connection handshake (4-way: Init, Try, Ack, Confirm) - Channel management with ordered/unordered support - ICS-20 fungible token transfers - HTLC atomic swaps with hashlock (SHA256) and timelock - Packet relay with timeout handling |
||
|---|---|---|
| .. | ||
| src | ||
| package.json | ||
| README.md | ||
Synor Compute SDK for JavaScript/TypeScript
Access distributed heterogeneous compute at 90% cost reduction.
Installation
npm install synor-compute
# or
pnpm add synor-compute
# or
yarn add synor-compute
Quick Start
import { SynorCompute, Tensor } from 'synor-compute';
const client = new SynorCompute('your-api-key');
// Matrix multiplication on GPU
const a = Tensor.random([512, 512]);
const b = Tensor.random([512, 512]);
const result = await client.matmul(a, b, {
precision: 'fp16',
processor: 'gpu'
});
console.log(`Execution time: ${result.executionTimeMs}ms`);
console.log(`Cost: $${result.cost}`);
Tensor Operations
// Create tensors
const zeros = Tensor.zeros([3, 3]);
const ones = Tensor.ones([2, 2]);
const random = Tensor.random([10, 10]);
const randn = Tensor.randn([100]); // Normal distribution
// From array
const data = Tensor.from([1, 2, 3, 4, 5, 6], [2, 3]);
// Operations
const reshaped = data.reshape([3, 2]);
const transposed = data.transpose();
Matrix Operations
// Matrix multiplication
const result = await client.matmul(a, b, {
precision: 'fp16',
processor: 'gpu',
strategy: 'speed'
});
// 2D Convolution
const conv = await client.conv2d(input, kernel, {
stride: [1, 1],
padding: [1, 1]
});
// Flash Attention
const attention = await client.attention(query, key, value, {
numHeads: 8,
flash: true
});
LLM Inference
// Single response
const response = await client.inference('llama-3-70b', 'Explain quantum computing', {
maxTokens: 512,
temperature: 0.7
});
console.log(response.result);
// Streaming response
for await (const chunk of client.inferenceStream('llama-3-70b', 'Write a poem')) {
process.stdout.write(chunk);
}
Configuration
const client = new SynorCompute({
apiKey: 'your-api-key',
baseUrl: 'https://api.synor.io/compute/v1', // or localhost:17250 for local
defaultProcessor: 'gpu',
defaultPrecision: 'fp16',
defaultStrategy: 'balanced',
timeout: 30000,
debug: false
});
Job Management
// Submit async job
const job = await client.submitJob('matmul', { a, b });
// Poll for status
const status = await client.getJobStatus(job.jobId);
// Cancel job
await client.cancelJob(job.jobId);
Error Handling
import { SynorError } from 'synor-compute';
try {
const result = await client.matmul(a, b);
} catch (error) {
if (error instanceof SynorError) {
console.error(`API Error: ${error.message} (${error.statusCode})`);
}
}
TypeScript Support
Full TypeScript support with exported types:
import type {
Tensor,
ProcessorType,
Precision,
BalancingStrategy,
JobStatus,
SynorConfig,
MatMulOptions,
InferenceOptions,
JobResult
} from 'synor-compute';
Testing
npm test
# or
pnpm test
License
MIT