Skip to content

Main content

Grouped Query Head Replication Factor Tool

Contiguous grouped-query head assignment with equal-sized groups.

Loading tool…

Description

Return grouped-query head replication and mapping.

Multihead attention partitions representation coordinates among heads. Grouped-query layouts share key/value heads among query heads, so embedding divisibility and the number of queries per key/value group are separate constraints. A head-index map or dimension check describes supplied layout arithmetic rather than allocating tensors or running a model.

Return grouped-query head replication and mapping.

When to use this tool

Use Grouped Query Head Replication Factor when checking the stated attention coordinate, visibility, angle or head-layout convention.

How to use the tool and how it works

  1. Enter queryHeads, keyValueHeads. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read queriesPerKv, mapping. Use the output convention below.

Return grouped-query head replication and mapping. Require whole queryHeads 1..256 and keyValueHeads 1..queryHeads dividing queryHeads; queriesPerKv = query/KV, mapping groups consecutive query-head indexes by that factor.1

Grouped-query attention shares key/value heads among query heads. The contiguous index mapping here is an explicit local layout convention, not a claim about every implementation.2

Input fieldMeaning and unitsAccepted input
queryHeadsQuery HeadsRequired. Safe integer; minimum 1; maximum 256.
keyValueHeadsKey Value HeadsRequired. Safe integer; minimum 1.
Output fieldInterpretationReturned shape
queriesPerKvQueries Per KvRequired. Safe integer.
mappingZero-based KV-head assignment for contiguous equal-sized query-head groups; not a universal tensor layout.Required. Array of safe integer; maximum items 256.
json
{
  "input": {
    "queryHeads": 8,
    "keyValueHeads": 2
  },
  "output": {
    "queriesPerKv": 4,
    "mapping": [
      0,
      0,
      0,
      0,
      1,
      1,
      1,
      1
    ]
  }
}

Limitations and assumptions

  • This is a contiguous grouping convention, not a universal tensor layout or an actual attention operation.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Inspect the complete model configuration and implementation for positional schedules, masking, softmax and actual inference behavior.

References

  1. Calculation and input contract: artificial-intelligence/grouped-query-head-replication-factor — tool.io

  2. GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints — Joshua Ainslie and coauthors

Similar or alternative tools