FastPrepColumn and Row Parallel Linear Layers
Problems/Column and Row Parallel Linear Layers

Column and Row Parallel Linear Layers

NVIDIA logoNVIDIA● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for column-parallel and row-parallel linear-layer implementation and their trade-offs, with a Megatron comparison. This practice version matches the reported core at about 80%. The forward-only integer matrices, equal contiguous shards, bias placement, rank-output format and finite bounds make the unspecified pseudocode task runnable.

Simulate the forward pass of an integer linear layer Y = X * W + bias across shards ranks. x is a B × K batch, weight is K × N, and bias has N entries. Ranks have equal contiguous blocks in increasing feature-index order.

  • mode = "COLUMN": split the output-feature columns of W and the corresponding bias entries. Every rank uses all of X. Its local B × (N / shards) result includes its bias slice. Gather by concatenating feature chunks in rank order for each batch row.
  • mode = "ROW": split the input-feature columns of X and matching rows of W. Each rank returns a B × N partial product without bias. Sum corresponding entries across ranks, then add the full bias once.

Return a possibly ragged matrix: first all local rows of rank 0, then rank 1, and so on, with batch rows in input order inside each rank; finally append the B complete output rows. So there are (shards + 1) * B rows. Column-mode local rows have N / shards entries; row-mode local rows and all final rows have N entries.

The last B rows equal X * W + bias in both modes, but the local rows distinguish the two algorithms. Use ordinary exact integer arithmetic. You only need to do the gather and the sum with ordinary arithmetic. No GPUs, distributed code, activation function or backward pass is needed.

Function

parallelLinear(x: int[][], weight: int[][], bias: int[], shards: int, mode: String) → int[][]

Examples

Example 1

x = [[1,2]]weight = [[3,4],[5,6]]bias = [7,8]shards = 2mode = "COLUMN"return = [[20],[24],[20,24]]

There are two ranks. Rank zero owns the first output column. Its dot product is thirteen, and adding its bias of seven gives its result. Rank one owns the second output column. Its dot product is sixteen, and adding its bias of eight gives its result. Gathering [20] and [24] gives [20,24].

Example 2

x = [[1,2]]weight = [[3,4],[5,6]]bias = [7,8]shards = 2mode = "ROW"return = [[3,4],[10,12],[20,24]]

The two ranks split the two inputs. Rank zero uses the first input and the first row of the weights and gets [3,4]. Rank one uses the second input and the second row and gets [10,12]. Neither adds the bias. Summing the two results gives thirteen and sixteen. Adding the bias [7,8] once gives twenty and twenty-four.

Example 3

x = [[1,-1],[0,2]]weight = [[2,-3],[4,5]]bias = [1,-2]shards = 1mode = "ROW"return = [[-2,-8],[8,10],[-1,-10],[9,8]]

With one rank, that rank computes the whole product without the bias. The first batch row gives minus two and minus eight, and the second gives eight and ten. These two local rows come first. Adding the bias once to each row gives the two final rows: minus one and minus ten, then nine and eight.

Constraints

  • 1 <= B <= 4, 1 <= K, N <= 16.
  • Both input matrices are rectangular and have compatible dimensions; bias.length = N.
  • 1 <= shards <= 4. In column mode, N is divisible by shards; in row mode, K is divisible by shards. No divisibility is required on the other axis.
  • mode is exactly "COLUMN" or "ROW".
  • Input and weight entries lie in [-10,10]; bias entries lie in [-100,100].

More NVIDIA Phone Screen questions

  • Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
  • Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
  • Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
  • Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
  • Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
  • Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
  • Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
  • Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
  • Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
  • Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026

Similar questions at other companies

  • Logistic Regression DiagnosticsLinkedIn · PHONE SCREENLinkedIn interview questions
  • Implement Cross-Entropy LossOpenAI · PHONE SCREENOpenAI interview questions
  • Scaled Dot-Product AttentionAmazon · PHONE SCREEN
  • Scaled Dot-Product AttentionMeshy · OA
  • Implement Circular PaddingApple · ONSITE INTERVIEWApple interview questions
  • Flip Rows and Columns, Count ZerosNutanix · OANutanix interview questions
  • Robot Survival ProbabilityInMobi · ONSITE INTERVIEWInMobi interview questions
  • Transformer Attention and SwiGLU Forward PassGoogle · ONSITE INTERVIEWGoogle interview questions
  • Orthogonal Neighbor Grid TotalIMC Trading · OAIMC Trading interview questions
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN

NVIDIA interview experiences

  • NVIDIA Full-Time SWE Onsite Scheduling: 1 Experience
  • NVIDIA OA: What It Tests (2026)
  • NVIDIA DevOps, QA and Infra Intern Interviews: 12 Experiences
  • NVIDIA Ignite Internship OA Experience
  • NVIDIA Software Intern Interview Questions: 9 Experiences
  • NVIDIA Ignite SWE Intern OA Questions: 6 Experiences
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
class Solution {
    public int[][] parallelLinear(int[][] x, int[][] weight, int[] bias, int shards, String mode) {
        return new int[0][];
    }
}
Checking account…