Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/docs/codeflash-concepts/how-codeflash-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ Codeflash currently only runs tests that directly call the target function in th

## Optimization Generation

To optimize code, Codeflash first gathers all necessary context from the codebase. It then calls our backend to generate several candidate optimizations. These are called "candidates" because their speed and correctness haven't been verified yet. Both properties will be verified in later steps.

To optimize code, Codeflash first gathers all necessary context from the codebase. It also line-profiles your code to understand where the bottlenecks might reside. It then calls our backend to generate several candidate optimizations. These are called "candidates" because their speed and correctness haven't been verified yet. Both properties will be verified in later steps.
## Verification of correctness

![Verification](/img/codeflash_arch_diagram.gif)

The goal of correctness verification is to ensure that when the original code is replaced by the new code, there are no behavioral changes in the code and the rest of the system. This means the replacement should be completely safe.
The goal of correctness verification is to ensure that when the new code replaces the original code, there are no behavioral changes in the code and the rest of the system. This means the replacement should be completely safe.

To verify correctness, Codeflash calls the function with numerous inputs, confirming that the new function behaves identically to the original.

Expand Down Expand Up @@ -60,4 +59,4 @@ Codeflash implements several techniques to measure code performance accurately.

## Creating Pull Requests

Once an optimization passes all checks, Codeflash creates a pull request through the Codeflash GitHub app directly in your repository. The pull request includes the new code, the speedup percentage, an explanation of the optimization, test statistics including coverage, and the test content itself. You can review and merge the new code if it meets your standards. Feel free to modify the code as needed—we welcome your improvements!
Once an optimization passes all checks, Codeflash creates a pull request through the Codeflash GitHub app directly in your repository. The pull request includes the new code, the speedup percentage, an explanation of the optimization, test statistics including coverage, and the test content itself. You can review, edit, and merge the new code.
22 changes: 9 additions & 13 deletions docs/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
sidebar_position: 1
slug: /
---
# Introduction
Welcome to the Codeflash documentation!

## What is Codeflash?

Welcome! Codeflash is an AI performance optimizer for Python code.
Codeflash speeds up Python code by figuring out the best way to rewrite a particular function, while verifying the behavior of the code is unchanged.
Codeflash speeds up Python code by figuring out the best way to rewrite your code while verifying that the behavior of the code is unchanged.

The optimizations Codeflash finds are generally better algorithms, opportunities to remove wasteful compute, better logic, and utilization of more efficient library methods.
The optimizations Codeflash finds are generally better algorithms, opportunities to remove wasteful compute, better logic, and utilization of more efficient library methods. Codeflash
does not modify the architecture of your code, but it tries to find the most efficient implementation of that architecture.

### How does Codeflash verify correctness?

Codeflash verifies the correctness of the optimizations it finds by generating and running new regression tests, as well as any existing tests you may already have.
This offers additional confidence that the behavior of your code remains unchanged.
Codeflash verifies the correctness of the optimizations it finds by generating and running new regression tests, as well as any existing tests you may already have. Codeflash tries to ensure that your
code behaves the same way before and after the optimization.
This offers high confidence that the behavior of your code remains unchanged.

### Continuous Optimization

Because Codeflash is an automated process, you can install it as a GitHub action and have it run on every pull request made to your codebase.
Because Codeflash is an automated process, you can install it as a GitHub action and have it optimize the new code on every pull request.
When Codeflash finds an optimization, it will ask you to review it. It will write a detailed explanation of the changes it made, and include all relevant info like % speed increase and proofs of correctness.

Having Codeflash installed on your Github repository gives you the peace of mind that your code is always written optimally. We call it *Continuous Optimization*.
This is a great way to ensure that your code, your team's code and your AI Agent's code are optimized for performance before it causes a performance regression. We call this *Continuous Optimization*.

### Features

Expand All @@ -34,9 +33,6 @@ Having Codeflash installed on your Github repository gives you the peace of mind
| [Optimize all code in a repo](optimizing-with-codeflash/codeflash-all) | Codeflash discovers all functions in a repo and optimizes all of them! |
| [Optimize every new pull request](optimizing-with-codeflash/optimize-prs) | Codeflash runs as a GitHub action and GitHub app and reviews all new code for Optimizations |
| [Optimize a whole workflow by Tracing it](optimizing-with-codeflash/trace-and-optimize) | End to end optimization for all the functions called in a workflow, by tracing to collect real inputs seen during execution and ensuring correctness and performance optimization with those inputs |
| Correctness Verification | The way Codeflash gains high confidence that the newly generated optimization has the same behavior as the originally written function. |
| Performance Measurement | Measuring execution times on a set of inputs to estimate runtime performance. |


## How to use these docs

Expand All @@ -45,4 +41,4 @@ Start by installing Codeflash, then explore the different ways of using it to op

## Questions or Feedback?

We love feedback! If you have any questions or feedback, use the Intercom button in the lower right, or drop us a note at [founders@codeflash.ai](mailto:[email protected]) - we read every message!
We love feedback! If you have any questions or feedback, use the Intercom button in the lower right, join our [Discord](https://www.codeflash.ai/discord), or drop us a note at [contact@codeflash.ai](mailto:[email protected]) - we read every message!
2 changes: 1 addition & 1 deletion docs/docs/optimizing-with-codeflash/benchmarking.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 5
---
# Using Benchmarks

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/optimizing-with-codeflash/trace-and-optimize.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
sidebar_position: 4
---
# Optimize Workflows End-to-End
# Optimize Workflows End-to-End by Tracing them.

Codeflash supports optimizing an entire Python script end to end by tracing the execution of the script and generating Replay Tests. These Replay Tests can be used to optimize all the functions called in the script.
Codeflash supports optimizing an entire Python script end to end by tracing the execution of the script and generating Replay Tests. Tracing means following the execution of a script and capturing the inputs to all the functions called, so they can be replayed again while optimizing. These Replay Tests can be used to optimize all the functions called in the script.

## Motivation for Tracing a workflow

Expand Down
Loading