You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/ai-agent-cpu-orchestration/1-overview.md
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
---
2
-
title: Understand the agent and the CPU/GPU split
2
+
title: Understand the agent and how work is split between CPU and GPU
3
+
description: See how a local Ollama AI concierge agent on Arm splits search, web I/O, text processing, and model reasoning between the CPU and GPU.
3
4
weight: 2
4
5
5
6
### FIXED, DO NOT MODIFY
6
7
layout: learningpathall
7
8
---
8
9
9
-
## What you'll build
10
+
## What you will run
10
11
11
-
In this Learning Path, you'll build and run a *local concierge agent*: a terminal application that answers research-style questions, such as finding restaurants, comparing products, or summarizing a topic, by searching the web, reading multiple pages, and writing a fact-checked summary.
12
-
13
-
Everything runs on your own Arm machine. The agent uses an LLM served locally by [Ollama](https://ollama.com/), so your prompts and the pages you browse never leave the device. The same code runs on an Apple silicon MacBook, an Arm Linux laptop, or an NVIDIA DGX Spark.
12
+
You'll run a local concierge agent: a terminal application that answers research-style questions, such as finding restaurants, comparing products, or summarizing a topic. The agent answers these questions by searching the web, reading multiple pages, and writing a fact-checked summary.
14
13
14
+
You'll run everything on your local Arm machine. The agent uses an LLM served locally by [Ollama](https://ollama.com/), so your prompts and the pages you browse never leave the device. The same code runs on an Apple silicon MacBook, an Arm Linux laptop, or an NVIDIA DGX Spark.
15
15
16
16
The agent is interesting not just because it runs locally, but because of *how the work is divided*. A common assumption is that an AI agent is "just the model." In practice, the model is only one stage in a longer pipeline, and most of the surrounding work runs on the CPU.
17
17
@@ -30,7 +30,7 @@ Your question
30
30
-> Write a fact-checked summary (GPU: model reasoning)
31
31
```
32
32
33
-
The model is called several times, but between every model call the CPU does a large amount of orchestration: generating query variants, dispatching parallel network requests, merging and deduplicating results, scoring pages for relevance, and extracting structured data.
33
+
The model is called several times, but between every model call, the CPU does a large amount of orchestration. The CPU generates query variants, dispatches parallel network requests, merges and deduplicates results, scores pages for relevance, and extracts structured data.
34
34
35
35
## Why the CPU matters in an agentic workflow
36
36
@@ -43,7 +43,8 @@ It's easy to focus only on token generation, because that's the visible "thinkin
43
43
| Web I/O | CPU | Calling the search API, downloading and parsing web pages |
44
44
| Text processing | CPU | TF-IDF ranking, deduplication, entity extraction, indexing |
45
45
46
-
This division is a natural fit for Arm platforms. On an Apple silicon MacBook or an Arm Linux machine, the CPU handles all orchestration and I/O while the GPU accelerates the model. On an NVIDIA DGX Spark, the Arm CPU coordinates the workflow while the GPU runs inference. In every case, the model is only as good as the context the CPU prepares for it.
46
+
This division is a natural fit for Arm platforms. On an Apple silicon MacBook or an Arm Linux machine, the CPU handles all orchestration and I/O and the GPU accelerates the model.
47
+
On an NVIDIA DGX Spark, the Arm CPU coordinates the workflow while the GPU runs inference. In every case, the model is only as good as the context the CPU prepares for it.
47
48
48
49
## How the agent shows you the split
49
50
@@ -56,6 +57,8 @@ The program is instrumented so you can see this division directly. As it runs, i
56
57
57
58
By the end of this Learning Path, you'll be able to look at a single query and see exactly how much of the work happened on the CPU before and after the model produced its answer.
58
59
59
-
## What's next
60
+
## What you've learned and what's next
61
+
62
+
You've now learned about the agent you'll build and the role the CPU plays in orchestrating the agent's workflow.
60
63
61
-
In the next section, you'll set up your environment: create a Python virtual environment, install the required packages, and get a Serper API key for web search.
64
+
Next, you'll set up your environment: create a Python virtual environment, install the required packages, and get a Serper API key for web search.
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/ai-agent-cpu-orchestration/2-setup.md
+18-13Lines changed: 18 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,19 @@
1
1
---
2
-
title: Set up your environment
2
+
title: Set up your environment before running the agent
3
+
description: Set up a Python virtual environment, Serper API key, required packages, and the concierge agent script before running the local AI agent on Arm.
3
4
weight: 3
4
5
5
6
### FIXED, DO NOT MODIFY
6
7
layout: learningpathall
7
8
---
8
9
9
-
## Set up your environment
10
+
## Install and configure prerequisites for the agent
10
11
11
-
In this section, you'll prepare everything the agent needs before running it: a Serper API key for web search, a Python virtual environment, the required packages, and the agent script itself.
12
+
Prepare the following before running the agent: a Serper API key for web search, a Python virtual environment, the required packages, and the agent script.
12
13
13
14
These steps are identical on an Apple silicon MacBook, an Arm Linux machine, and an NVIDIA DGX Spark.
14
15
15
-
## Create a project directory and virtual environment
16
+
###Create a project directory and virtual environment
16
17
17
18
A virtual environment keeps the agent's dependencies isolated from your system Python, so you always run against the right package versions.
18
19
@@ -30,9 +31,9 @@ python3 -m venv .venv
30
31
source .venv/bin/activate
31
32
```
32
33
33
-
Your shell prompt now shows`(.venv)`, which confirms the environment is active.
34
+
Your shell prompt will now show`(.venv)`, which confirms the environment is active.
34
35
35
-
## Install the required packages
36
+
###Install the required packages
36
37
37
38
The agent uses `requests` for HTTP calls and `beautifulsoup4` to parse web pages.
The agent searches the web through [Serper](https://serper.dev/), a Google Search API. The free tier is enough to complete this Learning Path.
48
49
49
50
1. Go to [serper.dev](https://serper.dev/) and create a free account.
50
-
2.Once logged in, you will see the dashboard. On the left, click**API Keys**.
51
+
2.After logging in, you'll see the dashboard. On the left, select**API Keys**.
51
52
3. Copy the Default key.
52
53
4. Export your API key as an environment variable in the same terminal session as your virtual environment:
53
54
54
-
```bash
55
-
export SERPER_API_KEY="your-serper-api-key"
56
-
```
55
+
```bash
56
+
export SERPER_API_KEY="your-serper-api-key"
57
+
```
57
58
58
59
{{% notice Tip %}}
59
60
This variable only lasts for the current terminal session. To keep it across sessions, add the same line to your shell profile, for example `~/.zshrc` on macOS or `~/.bashrc` on Linux.
60
61
{{% /notice %}}
61
62
62
-
## Download the agent script
63
+
### Download the agent script
63
64
64
-
Download the complete agent script, <ahref="/learning-paths/cross-platform/ai-agent-cpu-orchestration/concierge_agent.py"download>concierge_agent.py</a>, and move it into your `concierge-agent` directory. You'll run it at the end of this Learning Path, and the next sections walk through how the important parts work.
65
+
Download the complete agent script <a href="/learning-paths/cross-platform/ai-agent-cpu-orchestration/concierge_agent.py" download>concierge_agent.py</a>, and move it into your `concierge-agent` directory.
65
66
66
67
Alternatively, download it directly from the command line:
67
68
@@ -75,4 +76,8 @@ Confirm the file is in your project directory:
75
76
ls concierge_agent.py
76
77
```
77
78
78
-
With the environment ready and the script in place, the next step is to serve a model locally with Ollama.
79
+
## What you've accomplished and what's next
80
+
81
+
You've now obtained and set a Serper API key, created a virtual environment, and downloaded the agent script.
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/ai-agent-cpu-orchestration/3-ollama.md
+16-9Lines changed: 16 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
---
2
2
title: Serve a model locally with Ollama
3
+
description: Install Ollama, pull Gemma 3, and verify the local model endpoint before connecting it to the Arm-based concierge agent.
3
4
weight: 4
4
5
5
6
### FIXED, DO NOT MODIFY
@@ -8,15 +9,15 @@ layout: learningpathall
8
9
9
10
## Run AI models locally with Ollama
10
11
11
-
The agent's reasoning steps, such as choosing search terms, selecting URLs, and writing the final summary, are handled by an LLM. Instead of calling a cloud API, this Learning Path serves the model locally with [Ollama](https://ollama.com/).
12
+
The agent's reasoning steps, such as choosing search terms, selecting URLs, and writing the final summary, are handled by an LLM. Instead of calling a cloud API, you'll serve the model locally with [Ollama](https://ollama.com/).
12
13
13
-
Ollama is a lightweight runtime that downloads open models, loads them into memory, and exposes a local HTTP API at `http://localhost:11434`. When the agent calls that endpoint, the model runs directly on your machine: the CPU and GPU on your MacBook, Arm Linux laptop, or NVIDIA DGX Spark. Nothing is sent to an external service or cloud.
14
+
Ollama is a lightweight runtime that downloads open models, loads them into memory, and exposes a local HTTP API at `http://localhost:11434`. When the agent calls that endpoint, the model runs directly on your machine: the CPU and GPU on your MacBook, Arm Linux laptop, or NVIDIA DGX Spark.
14
15
15
16
Running locally has three benefits that matter for an agent:
16
17
17
-
-**Privacy**: your prompts and the web content the agent reads stay on the device.
18
-
-**Cost**: there are no per-token API charges, so you can run many queries freely.
19
-
-**Control**: you choose the exact model and keep it resident in memory for fast repeated calls.
18
+
- Privacy: your prompts and the web content the agent reads stay on the device.
19
+
- Cost: there are no per-token API charges, so you can run many queries freely.
20
+
- Control: you choose the exact model and keep it resident in memory for fast repeated calls.
20
21
21
22
## Install and start Ollama
22
23
@@ -50,7 +51,7 @@ With the install script, `ollama serve` runs in the foreground. Keep that termin
50
51
51
52
## Pull the Gemma model
52
53
53
-
This Learning Path uses [Gemma 3](https://ai.google.dev/gemma), Google's family of open models, in its 4-billion-parameter size (`gemma3:4b`). This size is a good default: it's capable enough for the agent's reasoning steps and small enough to run on a laptop.
54
+
You'll use [Gemma 3](https://ai.google.dev/gemma), Google's family of open models. The 4-billion-parameter size (`gemma3:4b`) is a good default: it's capable enough for the agent's reasoning steps and small enough to run on a laptop.
54
55
55
56
Download the model:
56
57
@@ -66,7 +67,7 @@ ollama list
66
67
67
68
You'll see `gemma3:4b` in the list of installed models.
68
69
69
-
## Choose a different model (optional)
70
+
## (Optional) Choose a different model
70
71
71
72
The agent reads the model name from the `OLLAMA_MODEL` environment variable, so you can switch models without editing the code. The default in the script is `gemma3:4b`.
72
73
@@ -75,7 +76,9 @@ The agent reads the model name from the `OLLAMA_MODEL` environment variable, so
75
76
|`gemma3:4b`| 4B | Laptops and modest hardware; the default |
76
77
|`gemma3:27b`| 27B | High-memory systems such as DGX Spark, for stronger reasoning |
77
78
78
-
To use a larger model on a DGX Spark, pull it and set the environment variable before running the agent:
79
+
To use a larger model on a DGX Spark, pull it and set the environment variable before running the agent.
80
+
81
+
For example, to use a model with 27 billion parameters:
79
82
80
83
```bash
81
84
ollama pull gemma3:27b
@@ -102,4 +105,8 @@ Summarize what a local AI agent does in one sentence.
102
105
103
106
Type `/bye` to exit the model session.
104
107
105
-
With Ollama serving `gemma3:4b`, you're ready to look at how the agent code uses it.
108
+
## What you've accomplished and what's next
109
+
110
+
You've now set up Ollama, served a Google `gemma3:4b` model locally, and tested the model.
111
+
112
+
Next, you'll look at how the agent code uses the model.
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/ai-agent-cpu-orchestration/4-code-walkthrough.md
+25-20Lines changed: 25 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
---
2
-
title: Walk through the agent code
2
+
title: Understand the concierge agent code
3
+
description: Review the concierge agent code to see where web search, page scraping, Ollama model calls, and CPU orchestration happen in the workflow.
3
4
weight: 5
4
5
5
6
### FIXED, DO NOT MODIFY
@@ -8,18 +9,18 @@ layout: learningpathall
8
9
9
10
## How the code is organized
10
11
11
-
The `concierge_agent.py` script you downloaded earlier is organized into four parts. This section walks through the important pieces so you understand what runs on the CPU, what runs on the GPU, and how the agent chains them together.
12
+
The `concierge_agent.py` script you downloaded earlier is organized into four parts. You'll understand what runs on the CPU, what runs on the GPU, and how the agent chains them together.
12
13
13
14
| Part | Responsibility | Runs on |
14
15
|---|---|---|
15
-
|Part 1: Tools | Web search, page scraping, optional email | CPU |
16
-
|Part 2: The brain | Calls the local Gemma model through Ollama | GPU |
| The agentic chain | Ties everything together into one query workflow | CPU + GPU |
19
20
20
-
##Part 1: The tools
21
+
###The tools
21
22
22
-
The tools are the agent's connection to the outside world. `search_web()` calls the Serper API and returns the top five results;`browse_website()` downloads a page and strips it down to clean text. Both run entirely on the CPU and both log their activity with `log_cpu()`:
23
+
The tools are the agent's connection to the outside world. `search_web()` calls the Serper API and returns the top five results.`browse_website()` downloads a page and strips it down to clean text. Both run entirely on the CPU and both log their activity with `log_cpu()`:
`browse_website()` uses BeautifulSoup to remove `<script>` and `<style>` tags, collapse whitespace, and cap the result at 8,000 characters so a single large page can't dominate the pipeline.
38
39
39
-
##Part 2: The brain
40
+
###The brain
40
41
41
42
A single function, `call_gemma_ollama()`, is the only place the model is used. It sends a prompt to the local Ollama API and streams the response back token by token:
-`keep_alive: -1` tells Ollama to keep the model resident in memory between calls. The agent calls the model several times per query, so this avoids reloading the weights each time.
59
60
- The function records timing as it streams. The time until the *first* token arrives is the model's input-token processing (prefill); the time spent streaming the rest is token generation. Separating these two values is what lets the agent show you the GPU breakdown later.
60
61
61
62
Because every model call goes through this one function, the agent only ever uses the GPU in clearly marked places.
62
63
63
-
##Part 3: The CPU orchestration pipeline
64
+
###The CPU orchestration pipeline
64
65
65
-
Between the model calls, the CPU prepares the context. Each stage below runs entirely on the CPU:
66
+
Between the model calls, the CPU prepares the context. Each of the following stages runs entirely on the CPU:
66
67
67
68
| Stage | Function | What it does |
68
69
|---|---|---|
@@ -74,14 +75,18 @@ Between the model calls, the CPU prepares the context. Each stage below runs ent
74
75
| Extract data |`extract_entities()`| Pulls out phone numbers, hours, and prices |
75
76
| Build index |`build_keyword_index()`| Indexes the most frequent terms |
76
77
77
-
##Part 4: The agentic chain
78
+
###The agentic chain
78
79
79
-
`run_concierge_agent()` ties the pipeline together. Reading it top to bottom shows how CPU and GPU steps alternate:
80
+
`run_concierge_agent()` ties the pipeline together. When you read the function from top to bottom, you can see how CPU and GPU steps alternate:
80
81
81
-
1.**GPU** – `call_gemma_ollama()` turns your question into a search query.
82
-
2.**CPU** – `generate_search_queries()` and `parallel_search()` expand and run the searches.
83
-
3.**GPU** – the model selects which URLs to open.
84
-
4.**CPU** – `parallel_browse()`, `rank_and_filter_content()`, `deduplicate_sentences()`, `extract_entities()`, and the indexing stages prepare the context.
85
-
5.**GPU** – the model writes the final, fact-checked summary.
82
+
1. GPU – `call_gemma_ollama()` turns your question into a search query.
83
+
2. CPU – `generate_search_queries()` and `parallel_search()` expand and run the searches.
84
+
3. GPU – the model selects which URLs to open.
85
+
4. CPU – `parallel_browse()`, `rank_and_filter_content()`, `deduplicate_sentences()`, `extract_entities()`, and the indexing stages prepare the context.
86
+
5. GPU – the model writes the final, fact-checked summary.
86
87
87
-
Now that you understand the structure, you'll run the agent and watch the CPU and GPU work in real time.
88
+
## What you've learned and what's next
89
+
90
+
You've now learned about the structure of the agent code and what functions work on the CPU and the GPU respectively.
91
+
92
+
Next, you'll run the agent and watch the CPU and GPU work in real time.
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/ai-agent-cpu-orchestration/5-run-and-examples.md
+14-9Lines changed: 14 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,17 @@
1
1
---
2
2
title: Run the agent and read the timeline
3
+
description: Run the local concierge agent, ask research questions, and interpret the CPU and GPU timing breakdown produced for each query.
3
4
weight: 6
4
5
5
6
### FIXED, DO NOT MODIFY
6
7
layout: learningpathall
7
8
---
8
9
9
-
## Run the agent
10
+
## Start the agent
10
11
11
-
Make sure both pieces are in place before you start:
12
+
Make sure the following are in place before you start:
12
13
13
-
- Ollama is running and serving `gemma3:4b` (from the previous section).
14
+
- Ollama is running and serving `gemma3:4b`.
14
15
- Your virtual environment is active and `SERPER_API_KEY` is set in the current terminal.
15
16
16
17
From your project directory, start the agent:
@@ -39,7 +40,7 @@ Type a question that benefits from searching and reading several pages. For exam
39
40
Find three highly rated ramen restaurants in San Francisco that are open late
40
41
```
41
42
42
-
As the agent works, watch the log lines. Cyan `[CPU]` lines show orchestration and web I/O; yellow `[GPU]` lines show each model call:
43
+
As the agent works, watch the log lines. Cyan <codestyle="color:#00aaaa"><strong>[CPU]</strong></code> lines show orchestration and web I/O; yellow <codestyle="color:#aaaa00"><strong>[GPU]</strong></code> lines show each model call:
43
44
44
45
```output
45
46
[GPU] Thinking with local Gemma model...
@@ -71,17 +72,17 @@ GPU total: 4.991s
71
72
72
73
These numbers separate the three kinds of work:
73
74
74
-
-**CPU operations** – every orchestration and text-processing stage combined.
75
-
-**GPU input token processing** – the time the model spends reading each prompt before producing output (prefill).
76
-
-**GPU token generation** – the time spent writing the answers.
75
+
-`CPU operations` – every orchestration and text-processing stage combined.
76
+
-`GPU input token processing` – the time the model spends reading each prompt before producing output (prefill).
77
+
-`GPU token generation` – the time spent writing the answers.
77
78
78
79
{{% notice Note %}}
79
80
Your exact numbers depend on your hardware, the model size, and how many pages the agent reads. The point isn't the absolute values, but the fact that CPU work is a substantial share of every query.
80
81
{{% /notice %}}
81
82
82
83
## Read the timeline
83
84
84
-
Below the breakdown, the agent prints a text-based timeline. Each character is a slice of wall-clock time, color-coded by what was active:
85
+
The agent also prints a text-based timeline. Each character is a slice of wall-clock time, color-coded by what was active:
0 commit comments