# US 2025/0094145 A1 · Preprocessing code using large language models for performance portability

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2025/0094145 A1
- Document ID: US20250094145A1
- Status: Published application
- Kind: A1
- Application number: 18/512,215
- Filed: 2023-11-17
- Published: 2025-03-20
- Earliest claimed: 2023-09-14
- Assignees: NEC Laboratories Europe GmbH
- Applicants: NEC Laboratories Europe GmbH
- Inventors: Nicolas Weber; Roberto Bifulco; Marc Betzwieser; Yves Ekspenszid
- Web page: https://patentgrep.com/patent/US20250094145A1

## CPC

- G06F 8/43: {Checking; Contextual analysis}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A computer-implemented, machine learning method for preprocessing code for performance portability includes extracting performance critical code segments from an application and obtaining input data. Ground truth data is generated based on the input data and the application. Original code of the application is transpiled using a large language model (LLM) into a tensor computation language (TCL) candidate. Correctness of an implementation of the TCL candidate is verified using the ground truth data. The method has applications including, but not limited to, use cases in medicine/healthcare, and other artificial intelligence applications for preprocessing and optimizing code for performance portability.

## Claims

### Claim 1

A computer-implemented method for preprocessing code for performance portability, the computer-implemented method comprising:
extracting performance critical code segments from an application;
obtaining input data;
generating ground truth data based on the input data and the application;
transpiling original code of the application using a large language model (LLM) into a tensor computation language (TCL) candidate; and
verifying correctness of an implementation of the TCL candidate using the ground truth data.

### Claim 2 (depends on 1)

The computer-implemented method according to claim 1, further comprising optimizing the TCL candidate using the LLM or another LLM.

### Claim 3 (depends on 2)

The computer-implemented method according to claim 2, wherein optimizing the TCL candidate is performed using performance data from optimizing compiler systems or runtime systems.

### Claim 4 (depends on 3)

The computer-implemented method according to claim 3, further comprising passing the TCL candidate through the optimizing compiler systems or runtime systems to generate heuristics and the performance data.

### Claim 5 (depends on 4)

The computer-implemented method according to claim 4, wherein the heuristics and the performance data are used as feedback to update the LLM that is used for optimizing the TCL candidate.

### Claim 6 (depends on 2)

The computer-implemented method according to claim 2, further comprising evaluating correctness of an implementation of the optimized TCL candidate, and accepting the implementation of the optimized TCL candidate based on a result of the implementation being correct and one or more user-provided constraints being met.

### Claim 7 (depends on 2)

The computer-implemented method according to claim 2, further comprising repeating the steps of transpiling, verifying and optimizing based on a determination that an implementation of the optimized TCL candidate is not correct.

### Claim 8 (depends on 1)

The computer-implemented method according to claim 1, wherein the performance critical code segments are identified using a trained LLM that weights performance criticality of code segments from the application.

### Claim 9 (depends on 8)

The computer-implemented method according to claim 8, wherein the trained LLM is trained based on code examples and a target function that increases a score based on a mathematical transformation being used, or data in a vectorizable data structure being accessed.

### Claim 10 (depends on 1)

The computer-implemented method according to claim 1, wherein obtaining the input data includes obtaining user provided input data and/or generating inferred or synthetically generated input data using automated checkpointing or static code analysis.

### Claim 11 (depends on 1)

The computer-implemented method according to claim 1, wherein extracting the performance critical code segments from the application includes automatically inferring data dtype, shape, and potential value ranges from code of the performance critical code segments.

### Claim 12 (depends on 11)

The computer-implemented method according to claim 11, wherein automatically inferring the potential value ranges includes analyzing loop ranges, memory access patterns, static or templated data types, and/or mathematical operations.

### Claim 13 (depends on 1)

The computer-implemented method according to claim 1, further comprising using user provided input data and/or inferred or synthetically generated input data to automatically reject invalid or corrupted code segments.

### Claim 14

A computer system for preprocessing code for performance portability, the computer system comprising one or more hardware processors which, alone or in combination, are configured to provide for execution of the following steps:
extracting performance critical code segments from an application;
obtaining input data;
generating ground truth data based on the input data and the application;
transpiling original code of the application using a large language model (LLM) into a tensor computation language (TCL) candidate; and
verifying correctness of an implementation of the TCL candidate using the ground truth data.

### Claim 15

A tangible, non-transitory computer-readable medium having instructions thereon which, upon being executed by one or more processors, provide for preprocessing code for performance portability by execution of the following steps:
extracting performance critical code segments from an application;
obtaining input data;
generating ground truth data based on the input data and the application;
transpiling original code of the application using a large language model (LLM) into a tensor computation language (TCL) candidate; and
verifying correctness of an implementation of the TCL candidate using the ground truth data.
