Documentation

Introduction

Sansqrit is a hybrid quantum-classical visual programming environment. Drag blocks onto a canvas, connect them with wires, run quantum circuits — or write code directly in the Sanskrit DSL.

What is Sansqrit?

Vision

Quantum computing sits behind a wall of notation, prerequisites, and physics. Sansqrit tears that wall down. A drug discovery researcher should be able to run a molecular docking simulation without knowing what a Toffoli gate is. An ML engineer should be able to quantum-enhance their models by dragging a block.

At the same time, the physicist who does know what a Toffoli gate is should have full access to every primitive — and be able to export to IBM Quantum, IonQ, Google Sycamore, or Amazon Braket in one click.

Name
"Sansqrit" is a deliberate portmanteau — Sanskrit (ancient structured language) + quantum. The 'q' marks the quantum dimension. Pronounced "san-skrit."

Who Is It For?

CHEMISTS

Run VQE on molecules. Build Hamiltonians visually. Get energies, orbital analysis, dissociation curves.

PHYSICISTS

Ising models, many-body systems, Lindblad dynamics, topological phases. All as blocks or code.

ML ENGINEERS

QSVM, VQC, quantum kernels, quantum transformers. Hybrid classical-quantum pipelines.

EDUCATORS

Teach Bell states, superposition, entanglement — visually, interactively, with real results.

Architecture

Three Layers

Sansqrit has three layers, each independently useful:

LAYER 1
Visual Canvas
Drag-and-drop 528 blocks. No code required. Generates Sanskrit code automatically.
LAYER 2
Sanskrit DSL
Python-like language. Gates, algorithms, stats, ML as first-class functions. .sq files.
LAYER 3
Rust WASM Engine
Core quantum simulation in Rust. 15-30× faster. Browser and Node.js compatible.

The Rust Engine

The quantum simulator is written in Rust and compiled to WebAssembly. It implements:

Full Rust Docs →

The Sanskrit DSL Interpreter

The interpreter is written in JavaScript (~1,064 lines). It parses and executes .sq files and the code editor. Features:

Quick Start

Installation

# 1. Install Node.js (v18+) from nodejs.org
# 2. Install Rust from rustup.rs

# Clone the repository
git clone https://github.com/your-org/sansqrit.git
cd sansqrit

# Install Node.js dependencies
npm install

# Build Rust → WASM (takes ~60 seconds first time)
bash build.sh

# Generate pre-computed tables
python3 precompute.py

# Run tests (should show 39/39 + 32/32)
npm test

First Run

# Start the server
npm start
# → ✓ Sanskrit Rust/WASM engine loaded — ~15-30x speedup active
# → 📦 528 blocks loaded across 42 categories
# → Server running at http://localhost:3000

Open http://localhost:3000 in Chrome or Firefox.

Core Concepts

Qubits

A qubit is the quantum analog of a classical bit. Unlike a bit (always 0 or 1), a qubit can be in superposition: simultaneously partially 0 and partially 1 until measured.

let q = qubits(4)   -- create 4 qubits, all start as |0⟩
-- q[0], q[1], q[2], q[3] are the individual qubit references
-- state vector has 2^4 = 16 complex amplitudes

Gates

Quantum gates are reversible operations on qubits. They are represented as unitary matrices.

H(q[0])              -- Hadamard: creates superposition |0⟩ → (|0⟩+|1⟩)/√2
X(q[1])              -- Pauli-X: bit flip |0⟩ ↔ |1⟩
CNOT(q[0], q[1])   -- Entangle: flip q[1] if q[0]=|1⟩
Rx(q[2], PI/2)      -- Rotate qubit 2 around X-axis by π/2

Measurement

Measuring a qubit collapses its superposition to a definite 0 or 1, with probabilities given by the squared amplitudes.

-- Single shot: collapses the state
let bit = measure(q[0])   -- returns 0 or 1

-- Multi-shot: samples the probability distribution (non-destructive)
let r = measure_all(q, shots=1000)
print(r.histogram)    -- {"00": 503, "11": 497}
Remember
With shots=1, the quantum state collapses. With shots>1, the engine samples from the probability distribution without destroying the state — allowing you to get statistics efficiently.