-
Notifications
You must be signed in to change notification settings - Fork 45
Spatz Platform #168
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
Open
Bumblebee00
wants to merge
107
commits into
pulp-platform:devel
Choose a base branch
from
Bumblebee00:spatz-integration
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Spatz Platform #168
Changes from all commits
Commits
Show all changes
107 commits
Select commit
Hold shift + click to select a range
ba01027
add placeholdeer code for spatz platform
Bumblebee00 9fc201d
code generation with generic c code
Bumblebee00 8dd7d32
modified spatz c code to use proper memory allocation and copying fun…
Bumblebee00 f04f3c0
tmp commit to send to badie103
Bumblebee00 9e26bb0
modified Makefile and cmakefiles to build and use spatz runtime. ugly…
9136b05
vsim simulator runnable by deeployRunner
f7456f9
Removed reverence to conda environment and added commands to create v…
6e565f4
typo
0bc60d4
double gvsoc temporaney configuration
c780baa
reunited gvsoc build for spatz and other platforms
8c6bfdd
forgot comment
cc1d7b6
forgot comment
49f2ce8
added topk generic binding (hardcoded k=10)
e1fa310
added matmul softmax and topk generic bindings to spatz
4788bac
switched default simulator to gvsoc bc is faster
204d522
added topk test network
bff3402
added sparse attention test network
5e12f08
added topk binding to generic platform
3167dda
improved generic gather node to support more than one index
68b5e7d
added gather binding for spatz
621cc87
now for any k inot the graph
4780de4
added big attention
24b4031
first draft of tiling (not working)
dbe43e9
minimalloc fix
ba347e1
fixed makefile adding missing things
9d0b187
added yaml for my conda environment
a1f7cb7
modified bindings to use snrt_dma_wait_all function
b872a2e
added different dimensions of FP32/MatMul
bb818db
fixed simulation staling issue
94d6357
fixed memory levels
b9bb792
added cycles indication
0c35b57
added fp32 matmul kernel that uses vector instructions
39d45a8
went back to not using snrt_l3alloc because its not working
2c0d624
[tiling] enable tiling extension on Spatz
cdfa5e0
[template] Add proper allocation template and fix DMA template
cea39d7
[sw] use memcpy instead of DMA for DRAM buffer init
df652e8
changed commit hash to include new version of spatz that has snrt_l3a…
27c6ccc
removed redundant memcpy
bddacf8
added gather only test
878a3fd
improved gather template
eb0c971
added nice dimensions of Matmul
0e2a78a
improved main
dec2ba2
spatz matmulfunction now splits work between cores
8bca32e
fixed name of input in graph
366af52
removed unnecessary print
9a7b3aa
gather tiling
585e49f
topk tiling
fe70c52
updated tiling to work with constant buffers
4871b1b
updated tiling to work with nodes with >1 output
ca2112c
fixed topk template
4ea8c14
added softmax tiled (not working)
7523a2b
added another softmax test
76d7cef
added softmax function with custom exp and inv functions
585321c
detect quiet nan float output
9e6c79c
use non vector for when one dim is one
80e43a4
fixed matmul kernel
6698acd
divide on p to have double performance
06e391e
added benchmarking code transformation pass
82eeecd
include necessary for benchmark code
eb75093
improved code transformation passes for allocation of all necessary b…
3dfaf23
split gather workload on two cores
d352d87
cleaner matmul template
c322c7a
initial version of dynamic dma code
6ed9ede
fixed sizes of gather template
e1aee4f
fixed sizes of gather template
61a4220
fixed gather tile contraint (removed contraint on tile fo data_in)
82593e7
removed unnecessary prints
9ae2f48
modified matmul variable to be bigger integers
43fafe8
removed very long memcopy
3f4467a
added hw barrier
2036eea
added new tests
1973309
added another main.c for spatz
17ce78a
improved hack to avoid memcpy
ffaaa34
new faster expf function, and softmax smartly devided between cores
d20847c
minor fixes
9dbea0a
added new template for topk that uses min heap
e303796
smal fix
18621e9
added topk function
3cb8165
added new test networks
bbd9306
work on matmul kernel
c6a9828
[fix] enforce 8-byte alignment for memory allocation
267ea2d
[fix] 8-byte aligned tiling constraints
0732873
cleaned topk template
07ae93f
added matmul columns reduction function
61d5f08
better condition for column matmul
e40dd50
how to do double buffering on spatz
c7c37ea
investigated double buffering
8a41c8d
[cleanup] removed deadcode, cleaned allocation template and bindings
16a97ef
[cleanup] revert debug print
f44e89a
[cleanup] only keep necessary changes in tiling extension
e36e505
[cleanup] fix lint issues (partially)
d149968
removed unnecessary tests
179a7c2
modified tests
bc2b8bd
removed unised comments
5ff85c6
necessary spatz makefile modification
68875c5
unecessary comment
520518b
missing slash in makefile
fd83c34
removed old gather templates
096571e
removed comments
2ee09ac
removed unnecessary matmuls
f8c6a6f
rmoved unnecessary softmax
d06e15a
renamed .yml
903eaeb
tmp commit
e917a03
fix merge error
Bumblebee00 ce4526f
fix merge error 2
Bumblebee00 ae6d3b9
updated readme and changelog
Bumblebee00 b76080b
added CI for Spatz
Bumblebee00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # SPDX-FileCopyrightText: 2024 ETH Zurich and University of Bologna | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| --- | ||
| name: _runner-spatz-tiled | ||
|
|
||
| "on": | ||
| workflow_call: | ||
| inputs: | ||
| runner: | ||
| required: true | ||
| type: string | ||
| docker-image: | ||
| required: true | ||
| type: string | ||
| pytest-marker: | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| test-runner-spatz-tiled: | ||
| runs-on: ${{ inputs.runner }} | ||
| container: | ||
| image: ${{ inputs.docker-image }} | ||
| steps: | ||
| - name: Mark workspace as safe | ||
| run: git config --global --add safe.directory '*' | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| - name: Build Deeploy | ||
| shell: bash | ||
| run: pip install -e . | ||
| - name: Run Test | ||
| run: | | ||
| cd DeeployTest | ||
| mkdir -p /app/.ccache | ||
| export CCACHE_DIR=/app/.ccache | ||
| pytest test_platforms.py -v -n 4 -m "spatz_tiled and ${{ inputs.pytest-marker }}" | ||
| shell: bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # SPDX-FileCopyrightText: 2025 ETH Zurich and University of Bologna | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| --- | ||
| name: CI • Spatz (Tiled) | ||
|
|
||
| "on": | ||
| push: | ||
| branches: | ||
| - "**" | ||
| tags: | ||
| - "v*.*.*" | ||
| pull_request: | ||
| workflow_dispatch: | ||
| inputs: | ||
| docker_image_deeploy: | ||
| description: "Deeploy Image to use" | ||
| required: false | ||
| default: "ghcr.io/pulp-platform/deeploy:devel" | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| select-env: | ||
| uses: ./.github/workflows/_select-env.yml | ||
| with: | ||
| docker_image_deeploy: ${{ inputs.docker_image_deeploy }} | ||
|
|
||
| spatz-kernels-tiled-singlebuffer-L2: | ||
| needs: select-env | ||
| uses: ./.github/workflows/_runner-spatz-tiled-sequential.yml | ||
| with: | ||
| runner: ${{ needs.select-env.outputs.runner }} | ||
| docker-image: ${{ needs.select-env.outputs.image }} | ||
| pytest-marker: "kernels" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,18 @@ | |
| width = int(data_in_type.referencedType.typeWidth/8) | ||
| %> | ||
| BEGIN_SINGLE_CORE | ||
| % if num_indices == 1: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we have this case here? what is the meaning of
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is to not generate a loop with one iteration: is cleaner c code |
||
| for (uint32_t i=0; i<${batch}; ++i) { | ||
| memcpy(${data_out} + i * ${axis_length}, ${data_in} + i * ${batch_length} + ${index} * ${axis_length}, ${axis_length} * ${width}); | ||
| } | ||
| % else: | ||
| for (uint32_t i=0; i<${batch}; ++i) { | ||
| for (uint32_t j=0; j<${num_indices}; ++j) { | ||
| memcpy(${data_out} + i * (${num_indices} * ${axis_length}) + j * ${axis_length}, | ||
| ${data_in} + i * ${batch_length} + ${indices}[j] * ${axis_length}, | ||
| ${axis_length} * ${width}); | ||
| } | ||
| } | ||
| % endif | ||
| END_SINGLE_CORE | ||
| """) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from typing import Dict, List, Tuple | ||
|
|
||
| from Deeploy.DeeployTypes import NetworkContext, NodeTemplate, OperatorRepresentation | ||
|
|
||
|
|
||
| referenceTemplate = NodeTemplate(""" | ||
| // TopK (Name: ${nodeName}, Op: ${nodeOp}) | ||
| BEGIN_SINGLE_CORE | ||
| // Find the top ${k_value} values and their indices | ||
| // Assumes 1D input for simplicity | ||
| typedef struct { | ||
| ${data_in_type.referencedType.typeName} value; | ||
| uint32_t index; | ||
| } topk_pair_t; | ||
|
|
||
| topk_pair_t pairs[${data_in_size}]; | ||
| for (uint32_t i = 0; i < ${data_in_size}; ++i) { | ||
| pairs[i].value = ((${data_in_type.referencedType.typeName}*)${data_in})[i]; | ||
| pairs[i].index = i; | ||
| } | ||
| // Simple selection sort for top-k | ||
| for (uint32_t i = 0; i < ${k_value}; ++i) { | ||
| uint32_t max_idx = i; | ||
| for (uint32_t j = i + 1; j < ${data_in_size}; ++j) { | ||
| if (pairs[j].value > pairs[max_idx].value) { | ||
| max_idx = j; | ||
| } | ||
| } | ||
| // Swap | ||
| if (max_idx != i) { | ||
| topk_pair_t tmp = pairs[i]; | ||
| pairs[i] = pairs[max_idx]; | ||
| pairs[max_idx] = tmp; | ||
| } | ||
| // Write output | ||
| ((${values_out_type.referencedType.typeName}*)${values_out})[i] = pairs[i].value; | ||
| ((${indices_out_type.referencedType.typeName}*)${indices_out})[i] = pairs[i].index; | ||
| } | ||
| END_SINGLE_CORE | ||
| """) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Validate
kas a constant scalar and bound it to input size.Line 2916 assumes
k_in.values[0]exists and is valid. Ifkis non-constant, scalar-shaped differently, ork > data_in_size, the generated TopK loop indexes beyond the localpairsbuffer.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents