Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use cublaslt #230

Closed
wants to merge 1 commit into from
Closed

Conversation

lucasavila00
Copy link
Contributor

@lucasavila00 lucasavila00 commented Apr 27, 2024

fn lt_mul(x: &Tensor, w: &QMatMul, lt: CublasLt) -> Result<Tensor> {
    // w.forward(x)
    match w {
        QMatMul::QTensor(ref qt) => {
            let w = qt.dequantize(x.device())?;

            let w = match *x.dims() {
                [b1, b2, _, _] => w.broadcast_left((b1, b2))?,
                [bsize, _, _] => w.broadcast_left(bsize)?,
                _ => w,
            };
            fused_batch_matmul(&w, &x, None, None, None, None, None, lt)

            // let w = match *x.dims() {
            //     [b1, b2, _, _] => w.broadcast_left((b1, b2))?.t()?,
            //     [bsize, _, _] => w.broadcast_left(bsize)?.t()?,
            //     _ => w.t()?,
            // };
            // x.matmul(&w)
        }
        QMatMul::Tensor(_) => todo!(),
    }
}

image


fn lt_mul(x: &Tensor, w: &QMatMul, lt: CublasLt) -> Result<Tensor> {
    // w.forward(x)
    match w {
        QMatMul::QTensor(ref qt) => {
            let w = qt.dequantize(x.device())?;

            // let w = match *x.dims() {
            //     [b1, b2, _, _] => w.broadcast_left((b1, b2))?,
            //     [bsize, _, _] => w.broadcast_left(bsize)?,
            //     _ => w,
            // };
            // fused_batch_matmul(&w, &x, None, None, None, None, None, lt)

            let w = match *x.dims() {
                [b1, b2, _, _] => w.broadcast_left((b1, b2))?.t()?,
                [bsize, _, _] => w.broadcast_left(bsize)?.t()?,
                _ => w.t()?,
            };
            x.matmul(&w)
        }
        QMatMul::Tensor(_) => todo!(),
    }
}

image

Candle already uses CublasLT

Copy link

Code Metrics Report
  ───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
Rust                        70     22354     1540       502    20312       1261
───────────────────────────────────────────────────────────────────────────────
Total                       70     22354     1540       502    20312       1261
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop 37,875
Estimated Schedule Effort 11.593474 months
Estimated People Required 4.888076
───────────────────────────────────────────────────────────────────────────────
Processed 738139 bytes, 0.738 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────
  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant