Skip to content

Neural-RX - #143

Draft
mbertuletti wants to merge 77 commits into
mainfrom
mbertuletti/neural_rx
Draft

mbertuletti wants to merge 77 commits into
mainfrom
mbertuletti/neural_rx

Conversation

@mbertuletti

@mbertuletti mbertuletti commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds software to run heterogeneous network layers and full neural receivers on TensorPool.

Added

  • Added nn layers
  • Added neural receivers appllications (l1_transformer)

Changed

  • Changed structure of the apps folder, to divide between blas, gnb, nn applications

Checklist

  • Automated tests pass
  • Changelog updated
  • Code style guideline is observed

Add fused depthwise and pointwise layer conv2d_f16
@mbertuletti
mbertuletti requested a review from Paolo309 November 23, 2026 13:39
mbertuletti and others added 28 commits November 23, 2026 15:41
- Move attention_block into kernels/baremetal/mempool_attention_f16.h.
- Multi-cluster: inline the layernorm and conv wrappers and at_cluster,
  move the VERIFY helpers into verify.h, add the section banners of the
  single-cluster app.
- Single-cluster: size the L1 buffers with the TILESHIFT formulas also
  without TILESHIFT.
The runtime contains the headers of its default multi-cluster
configuration (tensorpool, 256 cores, 16 RedMulE 8x32) in
runtime/multi_cluster/arch. For other configurations, generate them with
pulp/chips/mc_pool/common/utils/config.py in GVSoC and pass them with
MC_ARCH_DIR. The build checks that the headers match num_cores and
num_redmule_tiles, and takes the L1 bank size from them.
With -DCHECKSUM, core 0 fills l2_I and l2_F with deterministic fp16 values
and prints a checksum of the output of every layer, to compare the
results of two builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- __VFCPKAHS wrote its result into the pointer argument, so the softmax
  constants (1, 0.5, 0.167) were uninitialized registers.
- softmax and layernorm: pv.shuffle2.h with mask 0x00030002 is the
  identity, so the row maximum, sum and variance were not reduced across
  the two lanes. [a b] => [b a] is 0x00020003.
- layernorm: the loads of the normalization loop were mislabeled, so
  elements j + 2, j + 3 of row i were normalized with the statistics of
  row i + 1 and stored to the other row.
- permute_qkv read the QKV projection, [Beam][3 * Embed][tdSamples], as
  (b * Embed + e) * 3 * tdSamples: K and V of most channels came from the
  next beam, which the pipelined convolution may not have computed yet,
  so V depended on the timing. The rows of Q, K and V are
  b * 3 * Embed + e, + Embed, + 2 * Embed.

With -DCHECKSUM, the serial and the pipelined (one attention round)
builds now give the same output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With -DVFEXP, both fp16 softmax kernels compute exp with vfexp.h (exp of
each fp16 lane, 1000111 00001 rs1 010 rd 0110011) instead of the cubic
Taylor series, 4 instructions instead of 28 per 4 x 2 elements.

The softmax gets within 0.11% of the exact one (Taylor: 6.8% on inputs in
[-1, 0]). l1_transformer_f16: 150,788 -> 145,540 cycles (-3.5%)
(512 cores, 64 O-POPE 8x8, gvsoc; PIPELINED TILESHIFT ATTENTION_ROUNDS=2 LOG_BARRIER=5 VFEXP, B=128 E=32 T=32).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
conv1d_pipelined_im2col_f16 takes the im2col of a chunk as a callback
(conv1d_pipelined_f16 passes the dense one). The pipelined output
projection gathers its im2col directly from the attention output layout
(im2col_att_ebt, im2col_att_tbe), so the "Permute result" pass is gone.
Without RedMulEs, the callback now transforms the whole input before the
GEMMs.

l1_transformer_f16: 145,540 -> 142,901 cycles (-1.8%)
(512 cores, 64 O-POPE 8x8, gvsoc; PIPELINED TILESHIFT ATTENTION_ROUNDS=2 LOG_BARRIER=5 VFEXP, B=128 E=32 T=32).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
layernorm_im2col_w3_parallel_2x4_f16vec writes the layernorm output as
the 1D im2col (Wf = 3) of the convolution. With PIPELINED, l1_transformer
passes it as the im2col callback of the QKV projection and of the FFN
up-projection: the layernorm of a chunk overlaps with the GEMMs of the
previous one, and the layernorm and im2col passes are gone.

The output of these convolutions shares l1_arena with their input, so
conv1d_pipelined_im2col_f16 now goes from the last chunk to the first
when Co > Ci (from the first to the last otherwise): a chunk's output
never overwrites input that is not transformed yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
conv1d_pipelined_f16 computes S convolutions, each reading the output of 
the previous one beam by beam, as one pipeline: the GEMM tasks are numbered
stage by stage, chunk by chunk (one beam per RedMulE), and in round k the
RedMulEs compute task k - 1 while the cores compute the im2col of task k.
Consecutive stages only touch different chunks of a shared buffer within a
round.

With -DFUSE_CHAIN, l1_transformer_f16 runs the output projection, the FFN
up-projection, the FFN down-projection (its im2col applies the gelu) and
the QKV projection and permutation of the next layer as one chain
(chain()): the pipeline fills and drains once per layer instead of once
per convolution. attention() returns the attention output; the second one
skips its input transfer and QKV projection. The weights of a layer are in
l1_Fw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With -DATTENTION_SOFTMAX_ONLINE, attention_block_f16 computes the softmax
with softmax_online_parallel_2x4_f16vec: one pass for the running maximum
and sum of exp(x - max), one for the output. It reads the scores twice
instead of three times and writes Aw once instead of twice, which matters
when the softmax runs next to the RedMulE jobs of the pipelined attention.

l1_transformer_f16 with -DFUSE_CHAIN: 103,138 -> 97599 cycles
(1024 cores, 64 O-POPE 8x8, gvsoc; PIPELINED TILESHIFT ATTENTION_ROUNDS=2 LOG_BARRIER=5 VFEXP, B=128 E=32 T=32).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mbertuletti
mbertuletti force-pushed the mbertuletti/neural_rx branch from f9e81ea to e21d1ea Compare November 23, 2026 14:47
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.

2 participants