metadata: {"signature": "0x444f1ea207b4d4d5f6eeeb70eca4acfb91c4fbab72d03a1dcee0d31b5ce2790a49fac98d96d2a4714ba5a0fbdb62e34e62582b780dff70a23f2267002326c63d1b", "application": {"round": "0x8de918f0163b2021839a8d84954dd7e8e151326d", "answers": [{"type": "email", "hidden": true, "question": "Email Address", "questionId": 0, "encryptedAnswer": {"ciphertext": "5Cr80M+o+7fDjYyMtH5ISohRb8qOH3wNulrMK65lLv5rFhuN6LZlXLXRSLREMInI", "encryptedSymmetricKey": "9e70d88807f9af51477bd3e6ce4dcd2f6d5d009a7bb51e73f3f932cea4397492852f64d81a54fe2f050220bd07355218fad0d4332d24545228f74d4f5664bdc42c7bdb8a8455007cf8babb4d215fe475f85398dbadb1f177129046bf3f4feb85e4dfe21b5391c50531a7a40e3140fbdda027d13fa6e5c9bf3dd419fa2c09076000000000000000207df3776fb7f231399b5fe3642520a80605c372af373d8e1eb15c8980395f049ce7b991dc7bfb71dfe66bb8e0caf93583"}}, {"type": "link", "answer": "https://github.com/OPML-Labs/opml", "hidden": false, "question": "Project GitHub Repo (Not team page)", "questionId": 1}, {"type": "short-answer", "hidden": true, "question": "Telegram Handle", "questionId": 2, "encryptedAnswer": {"ciphertext": "d0BBbK/4BXjrDo3HB4n8xRtOvIsiYx+P56sDDX/+JJulYUn3maj3h+q85itPg8I5", "encryptedSymmetricKey": "f9a1d18c6aa5f837c1b91f6c2c59bd67fc8a3bb64cf71110019ee73fe8d68bd41312fae3b3977469ef1c1b29317bbe1845496cbb06383f43687cf0375511fe5f1e7ce14c6e01c1d49fa4e208b1355d2135e27ef7bc3162a4c3aa1b1c712870887aaf79d1c2154c59efe49e980167a6a4d7608902a534aa0a9f5f05e74a7c3ab100000000000000203b8d9f646a8af052639058074f017355c59c0fa32537adeb52925a2490d2ad4128403b4e7d5b096753ecfebc1a7068b3"}}, {"type": "link", "answer": "https://t.me/OPML_Labs", "hidden": false, "question": "Link to your Public Group Chat (Discord or Telegram)", "questionId": 3}, {"type": "number", "answer": "0", "hidden": false, "question": "Total prior funding for the project in USD", "questionId": 4}, {"type": "paragraph", "answer": "No funding", "hidden": false, "question": "Please expand on how much funding you\u2019ve received from each funding source and when (VC, grants, token sales, etc)", "questionId": 5}, {"type": "number", "answer": "1", "hidden": false, "question": "Total team size", "questionId": 6}, {"type": "number", "answer": "5", "hidden": false, "question": "How old (in Months) is the project?", "questionId": 7}, {"type": "address", "answer": "", "hidden": true, "question": "If you participated in past grant rounds using a different project payout wallet address, please share it here:", "questionId": 8}, {"type": "paragraph", "hidden": false, "question": "Profiles or socials of other main team members publicly associated with the project: ", "questionId": 9}, {"type": "multiple-choice", "answer": "Yes", "hidden": true, "question": "Have you read and confirmed your grant abides by the Program General Eligibility Policy? https://gitcoin.notion.site/GG18-Eligibility-cb4a5754c56043d4b3ed34eddbac261c?pvs=4", "questionId": 10}, {"type": "paragraph", "answer": "- We propose OPML (Optimistic Machine Learning), which enables AI model inference and training/fine-tuning on the blockchain system using optimistic approach (OPML is also called **FPML**, where \"FP\" refers to fraud proof).\n- OPML can provide ML service with low cost and high efficiency compared to ZKML. The participation requirement for OPML is low: We are now able to run OPML with a large language model, e.g., 7B-LLaMA (the model size is around 26GB) on a common PC without GPU.\n- OPML adopts a verification game (similar to Truebit and Optimistic Rollup systems) to guarantee decentralized and verifiable consensus on the ML service. \n  - The requester first initiates an ML service task.\n  - The server then finishes the ML service task and commits results on chain.\n  - The verifier will validate the results. Suppose there exists a verifier who declares the results are wrong. It starts a verification game with verification game (dispute game) with the server and tries to disprove the claim by pinpointing one concrete erroneous step.\n  - Finally, arbitration about a single step will be conducted on smart contract.\n- OPML is still under development, and is open-sourced: [OPML-Labs/opml: OPML: OPtimistic Machine Learning on Blockchain (github.com)](https://github.com/OPML-Labs/opml) \n", "hidden": false, "question": "Please explain how your project meets the round-specific eligibility criteria", "questionId": 11}, {"type": "paragraph", "hidden": false, "question": "If you've participated in past grant rounds, please share any new updates or milestones from the prior months", "questionId": 12}, {"type": "paragraph", "answer": "OPML supports on-chain AI service using fraud proof with low cost and high efficiency compared to ZKML", "hidden": false, "question": "How do you measure the impact of your project? Please provide examples and/or standard metrics. This might be used in future impact reports", "questionId": 13}, {"type": "paragraph", "hidden": false, "question": "Anything else you'd like to share about your project, previous work, or other project affiliations? Anything you'd like to add that may help in determining project eligibility?", "questionId": 14}, {"type": "multiple-choice", "answer": "Yes", "hidden": true, "question": "Would you like to opt-in to future messages from Gitcoin for updates, information, and/or interviews?", "questionId": 15}, {"type": "multiple-choice", "answer": "Yes", "hidden": true, "question": "Would you like to opt-in to us sharing your information with select third-parties for investment opportunities?", "questionId": 16}, {"type": "multiple-choice", "answer": "Asia", "hidden": false, "question": "Location/Region where the project is based", "questionId": 17}], "project": {"id": "10:0x8e1bD5Da87C14dd8e08F7ecc2aBf9D1d558ea174:597", "title": "OPML: OPtimistic Machine Learning on Blockchain", "logoImg": "bafkreifjoma6ooc2grplnatqm66ilr5ozwcjueyravrgci6ufyeecq4k2q", "metaPtr": {"pointer": "bafkreih32y36fdyyb6h5rlpjdjc2lxkw2isyegsal5aqdvkcvt7simvsii", "protocol": "1"}, "website": "https://github.com/OPML-Labs/opml", "createdAt": 1691026830077, "userGithub": "0x1cc", "credentials": {"github": {"type": ["VerifiableCredential"], "proof": {"jws": "eyJhbGciOiJFZERTQSIsImNyaXQiOlsiYjY0Il0sImI2NCI6ZmFsc2V9..ckzm4Q8aNxkI8A_XghXnGtgHyIsKD3lYTihPWvtc5rUHTPTiWN1GKA8XIbEqpin9VAehmfq5tR7CwTCxtyf0Cg", "type": "Ed25519Signature2018", "created": "2023-08-03T02:42:02.862Z", "proofPurpose": "assertionMethod", "verificationMethod": "did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC#z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC"}, "issuer": "did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC", "@context": ["https://www.w3.org/2018/credentials/v1"], "issuanceDate": "2023-08-03T02:42:02.862Z", "expirationDate": "2023-11-01T02:42:02.862Z", "credentialSubject": {"id": "did:pkh:eip155:1:0x0b0D63B8d7Aa3037c61316A8050F2f0cFdAD8f89", "hash": "v0.0.0:SxXlV1BHqIoHTYVNOt7UVIWCvGGIoOu8FFOVpLO1zak=", "@context": [{"hash": "https://schema.org/Text", "provider": "https://schema.org/Text"}], "provider": "ClearTextGithubOrg#OPML-Labs#138547070"}}}, "description": "OPML: OPtimistic Machine Learning on Blockchain\n\n## TL;DR\n\n- We propose OPML (Optimistic Machine Learning), which enables AI model inference and training/fine-tuning on the blockchain system using optimistic approach (OPML is also called **FPML**, where \"FP\" refers to fraud proof).\n- OPML can provide ML service with low cost and high efficiency compared to ZKML. The participation requirement for OPML is low: We are now able to run OPML with a large language model, e.g., 7B-LLaMA (the model size is around 26GB) on a common PC without GPU.\n- OPML adopts a verification game (similar to Truebit and Optimistic Rollup systems) to guarantee decentralized and verifiable consensus on the ML service. \n  - The requester first initiates an ML service task.\n  - The server then finishes the ML service task and commits results on chain.\n  - The verifier will validate the results. Suppose there exists a verifier who declares the results are wrong. It starts a verification game with verification game (dispute game) with the server and tries to disprove the claim by pinpointing one concrete erroneous step.\n  - Finally, arbitration about a single step will be conducted on smart contract.\n- OPML is still under development, and is open-sourced: [OPML-Labs/opml: OPML: OPtimistic Machine Learning on Blockchain (github.com)](https://github.com/OPML-Labs/opml) \n\n## Single-Phase Verification Game\n\nThe one-phase pinpoint protocol works similarly to referred delegation of computation (RDoC), where two or more parties (with at least one honest party) are assumed to execute the same program. Then, the parties can challenge each other with a pinpoint style to locate the disputable step. The step is sent to a judge with weak computation power (smart contract on blockchain) for arbitration. \n\nIn one-phase OPML:\n\n- We build a virtual machine (VM) for off-chain execution and on-chain arbitration. We guarantee the equivalence of the off-chain VM and the on-chain VM implemented on smart contract.\n- To ensure the efficiency of AI model inference in the VM, we have implemented a lightweight DNN library specifically designed for this purpose instead of relying on popular ML frameworks like Tensorflow or PyTorch. Additionally, a script that can convert Tensorflow and PyTorch models to this lightweight library is provided. \n- The cross-compilation technology has been applied to compile the AI model inference code into the VM program instructions.\n- The VM image is managed with a Merkle tree, only the Merkle root will be uploaded to the on-chain smart contract. (the Merkle root stands for the VM state)\n\n![image|621x251](https://github.com/OPML-Labs/opml/raw/main/docs/assets/image.png)\n- The bisection protocol will help to locate the dispute step, the step will be sent to the arbitration contract on the blockchain\n![dispute|551x281](https://github.com/OPML-Labs/opml/raw/main/docs/assets/dispute.png)\n\n**Performance**: We have tested a basic AI model (a DNN model for MNIST classification) on a PC. We are able to complete the DNN inference within 2 seconds in the VM, and the entire challenge process can be completed within 2 minutes in a local Ethereum test environment.\n\n## Multi-Phase Verification Game\n\n### **Limitations of One-Phase Pinpoint Protocol**\n\nThe one-phase verification game has a critical drawback: all computations must be executed within the Virtual Machine (VM), preventing us from leveraging the full potential of GPU/TPU acceleration or parallel processing. Consequently, this restriction severely hampers the efficiency of large model inference, which also aligns with the current limitation of the referred delegation of computation (RDoC) protocol. \n\n### Transitioning to a Multi-Phase Protocol\n\nTo address the constraints imposed by the one-phase protocol and ensure that OPML can achieve performance levels comparable to the native environment, we propose an extension to a multi-phase protocol. With this approach, we only need to conduct the computation in the VM only in the final phase, resembling the single-phase protocol. For other phases, we have the flexibility to perform computations that lead to state transitions in the native environment, leveraging the capabilities of CPU, GPU, TPU, or even parallel processing. By reducing the reliance on the VM, we significantly minimize overhead, resulting in a remarkable enhancement in the execution performance of OPML, almost akin to that of the native environment.\n\nThe following figure demonstrates a verification game consists of two phases (k = 2). In Phase-1, the process resembles that of a single-phase verification game, where each state transition corresponds to a single VM microinstruction that changes the VM state. In Phase-2, the state transition corresponds to a \"Large Instruction\" encompassing multiple microinstructions that change the computation context.\n\nThe submitter and verifier will first start the verification game on Phase-2 using bisection protocol to locate the dispute step on a \"large instruction\". This step will be send to the next phase, Phase-1. Phase-1 works like the single-phase verification game. The bisection protocol in Phase-1 will help to locate the dispute step on a VM microinstruction. This step will be sent to the arbitration contract on the blockchain. \n\nTo ensure the integrity and security of the transition to the next phase, we rely on the Merkle tree. This operation involves extracting a Merkle sub-tree from a higher-level phase, thus guaranteeing the seamless continuation of the verification process.\n\n![multi-phase|556x500](https://github.com/OPML-Labs/opml/raw/main/docs/assets/multi-phase.png)\n\n### Multi-Phase OPML\n\nIn this demonstration, we present a two-phase OPML approach, as utilized in the LLaMA model:\n\n- The computation process of Machine Learning (ML), specifically Deep Neural Networks (DNN), can be represented as a computation graph denoted as $G$. This graph consists of various computation nodes, capable of storing intermediate computation results.\n- DNN model inference is essentially a computation process on the aforementioned computation graph. The entire graph can be considered as the inference state (computation context in Phase-2). As each node is computed, the results are stored within that node, thereby advancing the computation graph to its next state.\n\n![computation_graph|325x155](https://github.com/OPML-Labs/opml/raw/main/docs/assets/computation_graph.png)\n\n- Therefore, we can first conduct the verification game on the computation graph (At phase-2). On the phase-2 verification game, the computation on nodes of the graph can be conducted in native environment using multi-thread CPU or GPU. The bisection protocol will help to locate the dispute node, and the computation of this node will be sent to the next phase (phase-1) bisection protocol.\n- In Phase-1 bisection, we transform the computation of a single node into Virtual Machine (VM) instructions, similar to what is done in the single-phase protocol.\n\nIt is worth noting that we anticipate introducing a multi-phase OPML approach (comprising more than two phases) when the computation on a single node within the computation graph remains computationally complex. This extension will further enhance the overall efficiency and effectiveness of the verification process.\n\n### Performance Improvement\n\nHere, we present a concise discussion and analysis of our proposed multi-phase verification framework.\n\nSuppose there are $n$ nodes in the DNN computation graph, and each node needs to take $m$ VM microinstructions to complete the calculation in VM. Assuming that the speedup ratio on the calculation on each node using GPU or parallel computing is $\\alpha$. This ratio represents the acceleration achieved through GPU or parallel computing and can reach significant values, often ranging from tens to even hundreds of times faster than VM execution.\n\nBased on these considerations, we draw the following conclusions:\n\n1. Two-phase OPML outperforms single-phase OPML, achieving a computation speedup of $\\alpha$ times. The utilization of multi-phase verification enables us to take advantage of the accelerated computation capabilities offered by GPU or parallel processing, leading to substantial gains in overall performance.\n2. Two-phase OPML reduces space complexity of the Merkle tree. When comparing the space complexity of the Merkle trees, we find that in two-phase OPML, the size is $O(m + n)$, whereas in single-phase OPML, the space complexity is significantly larger at $O(mn)$. The reduction in space complexity of the Merkle tree further highlights the efficiency and scalability of the multi-phase design.\n\nIn summary, the multi-phase verification framework presents a remarkable performance improvement, ensuring more efficient and expedited computations, particularly when leveraging the speedup capabilities of GPU or parallel processing. Additionally, the reduced Merkle tree size adds to the system's effectiveness and scalability, making multi-phase OPML a compelling choice for various applications.\n\n## Consistency and Determinism\n\nIn OPML, ensuring the consistency of ML results is of paramount importance.\n\nDuring the native execution of DNN computations, especially across various hardware platforms, differences in execution results may arise due to the characteristics of floating-point numbers. For instance, parallel computations involving floating-point numbers, such as $(a + b) + c$ versus $a + (b + c)$, often yield non-identical outcomes due to rounding errors. Additionally, factors such as programming language, compiler version, and operating system can influence the computed results of floating-point numbers, leading to further inconsistency in ML results.\n\nTo tackle these challenges and guarantee the consistency of OPML, we employ two key approaches:\n\n1. Fixed-point arithmetic, also known as quantization technology, is adopted. This technique enables us to represent and perform computations using fixed precision rather than floating-point numbers. By doing so, we mitigate the effects of floating-point rounding errors, leading to more reliable and consistent results.\n2. We leverage software-based floating-point libraries that are designed to function consistently across different platforms. These libraries ensure cross-platform consistency and determinism of the ML results, regardless of the underlying hardware or software configurations.\n\nBy combining fixed-point arithmetic and software-based floating-point libraries, we establish a robust foundation for achieving consistent and reliable ML results within the OPML framework. This harmonization of techniques enables us to overcome the inherent challenges posed by floating-point variations and platform disparities, ultimately enhancing the integrity and dependability of OPML computations.\n\n## OPML vs ZKML\n\n|                      | OPML                                                         | ZKML                                                         |\n| -------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |\n| model size           | any size (available for extremely large model)               | small/limited (due to the cost of ZKP generation)            |\n| validity proof       | fraud proof                                                  | zero-knowledge proof (ZKP)                                   |\n| training support*    | \u221a                                                            | \u00d7                                                            |\n| requirement          | Any PC with CPU/GPU                                          | Large memory for ZK circuit                                  |\n| Finality             | Delay for challenge period                                   | No delays                                                    |\n| service cost         | low (inference and training can be conducted in native environment) | extremely high (generating a ZKP for ML inference is extremely high) |\n| security             | crypto-economic incentives for security                      | cryptographic security                                       |\n\n*: Within the current OPML framework, our primary focus lies on the inference of ML models, allowing for efficient and secure model computations. However, it is essential to highlight that our framework also supports the training process, making it a versatile solution for various machine learning tasks.\n\n**Note** that OPML is still under development. If you are interested in becoming part of this exciting initiative and contributing to the OPML project, please do not hesitate to reach out to us. ", "lastUpdated": 0, "projectGithub": "OPML-Labs"}, "recipient": "0x0b0D63B8d7Aa3037c61316A8050F2f0cFdAD8f89"}}