DEV Community

Cover image for Comparing Model Performance: Without MTP vs. With MTP vs. With MTP + QAT
0xkoji
0xkoji

Posted on

Comparing Model Performance: Without MTP vs. With MTP vs. With MTP + QAT

google--gemma-4-12B-it-Q4_K_M.gguf

baxin/quantized-models at main

We’re on a journey to advance and democratize artificial intelligence through open source and open science.

huggingface.co

gemma-4-12B-it-qat-UD-Q4_K_XL.gguf

unsloth/gemma-4-12B-it-qat-GGUF · Hugging Face

We’re on a journey to advance and democratize artificial intelligence through open source and open science.

huggingface.co

prompt: hello

[ Prompt: 21.0 t/s | Generation: 10.6 t/s ]
[ Prompt: 19.5 t/s | Generation: 5.0 t/s ]
[ Prompt: 25.4 t/s | Generation: 17.6 t/s ]
Enter fullscreen mode Exit fullscreen mode

prompt: write fizzbuzz in typescript

[ Prompt: 23.1 t/s | Generation: 9.2 t/s ]
[ Prompt: 25.0 t/s | Generation: 10.6 t/s ]
[ Prompt: 32.2 t/s | Generation: 11.3 t/s ]
Enter fullscreen mode Exit fullscreen mode

Without MTP

▄▄ ▄▄
██ ██
██ ██ ▀▀█▄ ███▄███▄ ▀▀█▄ ▄████ ████▄ ████▄
██ ██ ▄█▀██ ██ ██ ██ ▄█▀██ ██ ██ ██ ██ ██
██ ██ ▀█▄██ ██ ██ ██ ▀█▄██ ██ ▀████ ████▀ ████▀
██ ██
▀▀ ▀▀

build : b9536-308f61c31
model : google--gemma-4-12B-it-Q4_K_M.gguf
modalities : text

available commands:
/exit or Ctrl+C stop or exit
/regen regenerate the last response
/clear clear the chat history
/read add a text file
/glob add text files using globbing pattern

hello

[Start thinking]
The user said "hello".
The user is initiating a conversation.
A friendly, helpful, and polite greeting is required.

*   Option 1: "Hello! How can I help you today?" (Standard, polite)
*   Option 2: "Hi there! What's on your mind?" (Friendly)
*   Option 3: "Hello! Is there anything specific you'd like to talk about or any questions I can answer?" (Informative)
Enter fullscreen mode Exit fullscreen mode

Keep it simple and inviting.
[End thinking]

Hello! How can I help you today?

[ Prompt: 21.0 t/s | Generation: 10.6 t/s ]

write fizzbuzz in typescript

[Start thinking]
The user wants a FizzBuzz implementation in TypeScript.

*   Iterate from 1 to a given number (usually 100).
*   If a number is divisible by 3, print "Fizz".
*   If a number is divisible by 5, print "Buzz".
*   If a number is divisible by both 3 and 5, print "FizzBuzz".
*   Otherwise, print the number itself.

*   *Approach 1: Basic Loop.* Simple, easy to understand.
*   *Approach 2: Functional Programming.* Using `.map()` or `.filter()`.
*   *Approach 3: Clean/Modular.* Separation of concerns (logic vs. output).

*   *Option 1: The Classic Loop (Standard implementation)*
Enter fullscreen mode Exit fullscreen mode
    ```typescript
    function fizzBuzz(n: number): void {
      for (let i = 1; i <= n; i++) {
        if (i % 3 === 0 && i % 5 === 0) {
          console.log("FizzBuzz");
        } else if (i % 3 === 0) {
          console.log("Fizz");
        } else if (i % 5 === 0) {
          console.log("Buzz");
        } else {
          console.log(i);
        }
      }
    }
    fizzBuzz(100);
    ```
Enter fullscreen mode Exit fullscreen mode
*   *Option 2: More "TypeScripty" (Clean/Scalable)*
    Instead of nested `if-else`, check conditions and append strings. This is more extensible (e.g., adding "Bazz" for 7).
Enter fullscreen mode Exit fullscreen mode
    ```typescript
    function fizzBuzzImproved(n: number): void {
      for (let i = 1; i <= n; i++) {
        let output = "";
        if (i % 3 === 0) output += "Fizz";
        if (i % 5 === 0) output += "Buzz";
        console.log(output || i.toString());
      }
    }
    ```
Enter fullscreen mode Exit fullscreen mode
*   Briefly explain the logic.
*   Provide a "Standard" version.
*   Provide a "Clean/Scalable" version.
*   Explain the TypeScript features used (types, etc.).

*   *Standard Version:* Use `number` types.
*   *Scalable Version:* Show how `output || i.toString()` handles the "else" case.
Enter fullscreen mode Exit fullscreen mode

[End thinking]

Here are two ways to write FizzBuzz in TypeScript.

1. The Standard Way

This is the most common way to write it. It uses a standard if/else if/else structure, which is easy to read and understand.

function fizzBuzz(limit: number): void {
    for (let i = 1; i <= limit; i++) {
        if (i % 3 === 0 && i % 5 === 0) {
            console.log("FizzBuzz");
        } else if (i % 3 === 0) {
            console.log("Fizz");
        } else if (i % 5 === 0) {
            console.log("Buzz");
        } else {
            console.log(i);
        }
    }
}

fizzBuzz(100);
Enter fullscreen mode Exit fullscreen mode

2. The "Clean" (Scalable) Way

This version is often preferred in professional coding because it's easier to extend. For example, if you wanted to add "Bazz" for numbers divisible by 7, you wouldn't have to add dozens of new else if combinations.

function fizzBuzzScalable(limit: number): void {
    for (let i = 1; i <= limit; i++) {
        let output = "";

        if (i % 3 === 0) output += "Fizz";
        if (i % 5 === 0) output += "Buzz";

        // If output is still an empty string, it means the number
        // wasn't divisible by 3 or 5, so we print the number.
        console.log(output || i.toString());
    }
}

fizzBuzzScalable(100);
Enter fullscreen mode Exit fullscreen mode

Key TypeScript Features Used:

  1. Type Annotations: We explicitly define limit: number to ensure the function only accepts numbers.
  2. Type Inference: In the second example, TypeScript automatically knows output is a string.
  3. Logical OR (||): In the second example, we use output || i.toString(). Since an empty string is "falsy" in JavaScript/TypeScript, if output is empty, it defaults to the string version of the number.

How to run this:

If you have ts-node installed, you can run it directly:

ts-node fizzbuzz.ts
Enter fullscreen mode Exit fullscreen mode

Otherwise, compile it with tsc and run it with node:

tsc fizzbuzz.ts
node fizzbuzz.js
Enter fullscreen mode Exit fullscreen mode

[ Prompt: 23.1 t/s | Generation: 9.2 t/s ]

With MTP

▄▄ ▄▄
██ ██
██ ██ ▀▀█▄ ███▄███▄ ▀▀█▄ ▄████ ████▄ ████▄
██ ██ ▄█▀██ ██ ██ ██ ▄█▀██ ██ ██ ██ ██ ██
██ ██ ▀█▄██ ██ ██ ██ ▀█▄██ ██ ▀████ ████▀ ████▀
██ ██
▀▀ ▀▀

build : b9569-1e1aca09d
model : google--gemma-4-12B-it-Q4_K_M.gguf
modalities : text

available commands:
/exit or Ctrl+C stop or exit
/regen regenerate the last response
/clear clear the chat history
/read add a text file
/glob add text files using globbing pattern

hello

[Start thinking]
The user said "hello".
The user is initiating a conversation.

*   Acknowledge the greeting.
*   Offer assistance.
*   Maintain a friendly and helpful tone.
*   *Draft 1 (Simple):* Hello! How can I help you today?
*   *Draft 2 (Friendly):* Hi there! How are you doing? Is there anything I can help you with?
*   *Draft 3 (Detailed):* Hello! I'm an AI assistant. I can help you with writing, coding, answering questions, or just chatting. What's on your mind?
Enter fullscreen mode Exit fullscreen mode

[End thinking]

Hello! How can I help you today?

[ Prompt: 19.5 t/s | Generation: 5.0 t/s ]

write fizzbuzz in typescript

[Start thinking]
The user wants a "FizzBuzz" implementation in TypeScript.

*   Iterate through numbers 1 to 100 (standard).
*   If divisible by 3, print "Fizz".
*   If divisible by 5, print "Buzz".
*   If divisible by both 3 and 5, print "FizzBuzz".
*   Otherwise, print the number.

*   *Approach 1: Simple Loop.* Good for beginners, easy to read.
*   *Approach 2: Functional Approach.* Using `.map()` or `.filter()`. More "modern" style.
*   *Approach 3: Modular/Reusable.* Separating logic from the printing.

*   *Step 1: Basic version.*
Enter fullscreen mode Exit fullscreen mode
    ```typescript
    for (let i = 1; i <= 100; i++) {
      if (i % 3 === 0 && i % 5 === 0) {
        console.log("FizzBuzz");
      } else if (i % 3 === 0) {
        console.log("Fizz");
      } else if (i % 5 === 0) {
        console.log("Buzz");
      } else {
        console.log(i);
      }
    }
    ```
Enter fullscreen mode Exit fullscreen mode
*   *Step 2: Refining for TypeScript.* Use types (though for a simple loop, `let i: number` is implicit, it's good to be explicit or clean).

*   *Step 3: Adding a "Cleaner" version.* Use a string concatenation method to avoid the double check of `3 && 5`.
Enter fullscreen mode Exit fullscreen mode
    ```typescript
    for (let i = 1; i <= 100; i++) {
      let output = "";
      if (i % 3 === 0) output += "Fizz";
      if (i % 5 === 0) output += "Buzz";
      console.log(output || i.toString());
    }
    ```
Enter fullscreen mode Exit fullscreen mode
*   *Explanation:* Briefly explain how it works.
*   *Code block 1:* The standard implementation (easiest to understand).
*   *Code block 2:* A more concise/elegant implementation (better for interviews or clean code).
*   *Instructions:* How to run it (ts-node or tsc).
Enter fullscreen mode Exit fullscreen mode

[End thinking]

Here are a few ways to implement FizzBuzz in TypeScript, ranging from a standard approach to a more concise version.

1. The Standard Approach

This is the most common way to write it. It uses a simple if-else chain which is easy to read and understand.

function fizzBuzz(limit: number): void {
  for (let i = 1; i <= limit; i++) {
    if (i % 3 === 0 && i % 5 === 0) {
      console.log("FizzBuzz");
    } else if (i % 3 === 0) {
      console.log("Fizz");
    } else if (i % 5 === 0) {
      console.log("Buzz");
    } else {
      console.log(i);
    }
  }
}

fizzBuzz(100);
Enter fullscreen mode Exit fullscreen mode

2. The "Clean Code" Approach

This version is more scalable. If you wanted to add "Bazz" for numbers divisible by 7, you wouldn't have to keep adding complex && conditions.

function fizzBuzz(limit: number): void {
  for (let i = 1; i <= limit; i++) {
    let output = "";

    if (i % 3 === 0) output += "Fizz";
    if (i % 5 === 0) output += "Buzz";

    // If output is still an empty string, it means not divisible by 3 or 5
    console.log(output || i.toString());
  }
}

fizzBuzz(100);
Enter fullscreen mode Exit fullscreen mode

Key Differences:

  • Approach 1 is the classic way. It is very explicit.
  • Approach 2 is more "programmatic." By building a string, you avoid checking i % 3 === 0 && i % 5 === 0 separately, because if both are true, the string naturally becomes "FizzBuzz".

How to run this:

If you have ts-node installed, you can run it directly:

ts-node filename.ts
Enter fullscreen mode Exit fullscreen mode

Or, you can compile it to JavaScript first:

tsc filename.ts
node filename.js
Enter fullscreen mode Exit fullscreen mode

[ Prompt: 25.0 t/s | Generation: 10.6 t/s ]

With MTP + qat

▄▄ ▄▄
██ ██
██ ██ ▀▀█▄ ███▄███▄ ▀▀█▄ ▄████ ████▄ ████▄
██ ██ ▄█▀██ ██ ██ ██ ▄█▀██ ██ ██ ██ ██ ██
██ ██ ▀█▄██ ██ ██ ██ ▀█▄██ ██ ▀████ ████▀ ████▀
██ ██
▀▀ ▀▀

build : b9569-1e1aca09d
model : gemma-4-12B-it-qat-UD-Q4_K_XL.gguf
modalities : text

available commands:
/exit or Ctrl+C stop or exit
/regen regenerate the last response
/clear clear the chat history
/read add a text file
/glob add text files using globbing pattern

hello

[Start thinking]
The user said "hello".
The user is initiating a conversation.

*   Acknowledge the greeting.
*   Offer assistance.
*   Maintain a helpful, polite, and friendly tone.
Enter fullscreen mode Exit fullscreen mode

"Hello! How can I help you today?" or "Hi there! How's it going? Is there anything I can assist you with?"
[End thinking]

Hello! How can I help you today?

[ Prompt: 25.4 t/s | Generation: 17.6 t/s ]

write fizzbuzz in typescript

[Start thinking]
The user wants a FizzBuzz implementation in TypeScript.

*   Input: A range of numbers (usually 1 to 100).
*   Rules:
    *   If a number is divisible by 3, print "Fizz".
    *   If a number is divisible by 5, print "Buzz".
    *   If a number is divisible by both 3 and 5, print "FizzBuzz".
    *   Otherwise, print the number.

*   Option 1: A simple `for` loop with `if-else` statements. (Most common/clear for beginners).
*   Option 2: A function that returns an array of strings. (Good for functional programming).
*   Option 3: A concise version using ternary operators.

*   *Draft 1 (Basic Loop):*
Enter fullscreen mode Exit fullscreen mode
    ```typescript
    for (let i = 1; i <= 100; i++) {
        if (i % 3 === 0 && i % 5 === 0) {
            console.log("FizzBuzz");
        } else if (i % 3 === 0) {
            console.log("Fizz");
        } else if (i % 5 === 0) {
            console.log("Buzz");
        } else {
            console.log(i);
        }
    }
    ```
Enter fullscreen mode Exit fullscreen mode
*   *Draft 2 (More "TypeScript-y" / Functional):*
    Let's make a function that takes a limit.
Enter fullscreen mode Exit fullscreen mode
    ```typescript
    function fizzBuzz(limit: number): void {
        for (let i = 1; i <= limit; i++) {
            // logic...
        }
    }
    ```
Enter fullscreen mode Exit fullscreen mode
*   Show the standard approach first.
*   Provide an explanation of the logic.
*   Provide a more modular/clean version (using a function).
*   Briefly explain how to run it (e.g., `tsc` or `ts-node`).

*   *Code Block 1: Standard implementation.*
*   *Code Block 2: Clean/Functional implementation (returning an array).*
*   *Explanation of the modulo operator (`%`).*
Enter fullscreen mode Exit fullscreen mode

[End thinking]

Here are a few ways to write FizzBuzz in TypeScript, ranging from a simple loop to a more functional approach.

1. The Standard Approach (Most Common)

This is the most straightforward way to solve the problem using a for loop and if/else statements.

function fizzBuzz(limit: number): void {
    for (let i = 1; i <= limit; i++) {
        if (i % 3 === 0 && i % 5 === 0) {
            console.log("FizzBuzz");
        } else if (i % 3 === 0) {
            console.log("Fizz");
        } else if (i % 5 === 0) {
            console.log("Buzz");
        } else {
            console.log(i);
        }
    }
}

fizzBuzz(100);
Enter fullscreen mode Exit fullscreen mode

2. The Clean/Modular Approach

In a real-world application, you might want a version that returns an array of strings rather than just logging them, or one that uses a more concise logic.

function getFizzBuzz(limit: number): string[] {
    const result: string[] = [];

    for (let i = 1; i <= limit; i++) {
        let output = "";

        if (i % 3 === 0) output += "Fizz";
        if (i % 5 === 0) output += "Buzz";

        result.push(output || i.toString());
    }

    return result;
}

// Usage
const output = getFizzBuzz(15);
console.log(output.join("\n"));
Enter fullscreen mode Exit fullscreen mode

Key Explanations:

  1. The Modulo Operator (%): This returns the remainder of a division. i % 3 === 0 means "if $i$ is perfectly divisible by 3."
  2. The Order of Logic: In the first example, we check for i % 3 === 0 && i % 5 === 0 first. If we checked for 3 first, the program would print "Fizz" for the number 15 and skip the "FizzBuzz" check.
  3. Type Annotations: Because this is TypeScript, we define limit as a number and the return type of the second function as string[] (an array of strings).

How to run this:

If you have Node.js installed, you can run this by following these steps:

  1. Install TypeScript: npm install -g typescript
  2. Save the code as fizzbuzz.ts.
  3. Compile it: tsc fizzbuzz.ts
  4. Run it: node fizzbuzz.js

(Or simply use ts-node fizzbuzz.ts to run it directly without manual compilation).

[ Prompt: 32.2 t/s | Generation: 11.3 t/s ]

Top comments (0)