# AI Execution Mechanism

### AI Node (AI Execution Extension)&#x20;

The AI node mainly includes an EVM-compatible LazVM for AI computing and gas settlement, and its main process is as follows:

<figure><img src="https://501205686-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfKp8Fyd6WWX9RFVOt8ze%2Fuploads%2FDRyKVE6WG7cUV06YVWMi%2Fimage.png?alt=media&#x26;token=925fdfff-5cbc-4b5e-94ca-2bbb0ff16b0d" alt=""><figcaption></figcaption></figure>

### Request

For AI training and inference, users send inference or training requests to AI nodes. Taking an inference request as an example, it is compatible with the OpenAI API. Users need to provide additional DAT ID for additional data acquisition, wallet signature and nonce for inference fee settlement.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcWHMXXDZzY-s00tsyCPQdExmJCC_k47v02N_bmwb7xX8XIOMhreS-dbx2QCY5w3mxqQKO7Jupzf_9NTlSSuVK5GaKdz0oCFcXztJAqjF7HvOtcHzhv7EJ47mKbHUPGjVzyJWXcmA?key=S_AVxe4Pa4t7GMdXHRa1L20C" alt=""><figcaption></figcaption></figure>

### LazVM

* EVM-Compatible: Ensures compatibility with existing Ethereum Virtual Machine tools and smart contracts.
* AI Computing: Specialized execution environment for AI workloads.
* Gas Settlement: Integrated gas mechanism to track and settle computational costs.

#### AI & Proof Precompile

* **Computation Orchestration:** Coordinates between LazVM and GPU Coprocessor including model loaders, tokenizers, embedders, tensor kernels, attention kernels and SIMD, etc.
* **Proof Verification:** Validates computation proofs returned from GPU Coprocessor including proof kernels. Besides, we will reserve op and zk proof interfaces to support multiple op and zk systems: e.g., STARKs, PLONK or any component from zkMIPS.

#### GPU Coprocessor

* Accelerated Computing: Dedicated hardware acceleration for AI computations.
* Proof Generation: Creates cryptographic proofs of correct computation execution.
* Resource Monitoring: Tracks computational resources used during inference.

The Execution Layer is designed to support verifiable AI computation, inference optimization, and seamless AI asset deployment. This layer ensures that AI agents and models operate efficiently and transparently within LazAI’s decentralized ecosystem.

By implementing trustless AI execution mechanisms, the Execution Layer ensures transparency, security, and scalability for AI applications in Web3.

### Settlement Layer

The Settlement Layer transforms AI-related data, models, and agents into tokenized assets, ensuring secure, traceable, and programmable ownership.

**GasAI = α⋅FLOPs+γ**

**GasInference = β⋅Mempeak**

**GasEstimate = P ⋅ T**

**Where:**

* α = FLOPs rate coefficient (adjustable via governance).
* β = Memory peak rate coefficient (adjustable via governance).
* γ = Base gas cost for AI operations including data store and computing resources.
* FLOPs = Floating Point Operations (computational workload metric).
* Mempeak = Peak memory usage during computation.

In addition, here we refer to EIP1559 to dynamically adjust the gas price, which includes a basic fixed fee and a part based on market conditions.

### Quorum-based BFT Consensus Protocol & iDAO

LazAI blockchain leverages a Quorum-based Byzantine Fault Tolerance (BFT) consensus mechanism, distributing data governance and storage across multiple decentralized Quorum organizations to ensure both reliability and transparency.

* Each Quorum operates as an iDAO, functioning similarly to a traditional data center but without the need to store data directly on-chain, significantly reducing on-chain storage costs.
* These iDAO organizations reach consensus to validate and ensure the trustworthiness of off-chain data, enabling its rapid and efficient delivery to both on-chain and off-chain agents, while maintaining high availability and low latency.

#### The main responsibilities of iDAO include:

1. Providing Trustworthy AI Data Sources or AI Flow\
   Offering reliable data sources or AI workflows to other individuals or organizations, ensuring high-quality and aligned data.
2. Off-Chain Dataset\
   Conducting off-chain dataset, providing AI Agent services to perform more efficient AI operations.
3. Decentralized Consensus and Data Governance\
   iDAO participates in the LazChain consensus in the form of a Quorum. Through the decentralization of multiple Quorum organizations, it ensures the reliability and transparency of data governance and storage. Each Quorum acts as an independent iDAO, similar to a traditional data center, but without storing data directly on-chain, effectively reducing on-chain storage costs. iDAO organizations achieve consensus to verify the trustworthiness of off-chain data, ensuring that data is efficiently and quickly available to both on-chain and off-chain agents while ensuring high availability and low latency.

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lazai.network/lazai-workflow-and-runtime/ai-execution-mechanism.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
