Skip to content

feat: pick appropiate model quanitzation for target - #22

Open
awphi wants to merge 3 commits into
mainfrom
gguf-parser
Open

awphi wants to merge 3 commits into
mainfrom
gguf-parser

Conversation

@awphi

@awphi awphi commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Demos features introduced in arm/topo#558 to demo target-aware configuration:

  • Introduces a new target memory parameter and binds it to the relevant target fact exposed by topo configure|clone --target (or manually typed if using a Topo version without this feature)
  • Uses https://github.com/gpustack/gguf-parser-go to estimate memory consumption of available supported quantizations against target memory and picks the highest possible fidelity for the target
  • Falls back to Q4_K_M if memory is not provided

NOTE: This PR demonstrates (but does not wholly rely on) a feature gated behind TOPO_EXPERIMENTAL_FEATURES=1; topo configure --target. It's best not to merge this until that feature is finalized and generally available.

awphi added 3 commits October 27, 2026 14:47
Signed-off-by: awphi <adam.hodson@arm.com>
Signed-off-by: awphi <adam.hodson@arm.com>
Signed-off-by: awphi <adam.hodson@arm.com>
@awphi
awphi requested a review from a team as a code owner October 27, 2026 15:02
@yejseo01

Copy link
Copy Markdown
Contributor

question: does this need to be run with the experimental flag enabled?

@yejseo01

yejseo01 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

I tried this. I have the experimental feature in my logs. I get this error:

yejseo01@CF7PJYX5G9 topo-llama-web-ui % /tmp/topo configure --target orion-leela
15:51:49 ERROR unknown flag: --target
yejseo01@CF7PJYX5G9 topo-llama-web-ui %

I tried again with the experimental flag on, and it worked

@awphi

awphi commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

I tried this. I have the experimental feature in my logs. I get this error:

yejseo01@CF7PJYX5G9 topo-llama-web-ui % /tmp/topo configure --target orion-leela
15:51:49 ERROR unknown flag: --target
yejseo01@CF7PJYX5G9 topo-llama-web-ui %

I tried again with the experimental flag on, and it worked

Yep that's expected while we keep the feature experimental! It's very likely the schema for binding a parameter to a fact is going to change. We've come up with a new design even today that's a bit more flexible so this is probably for the best for now.

It does mean this PR probably should not be merged until the feature is more stable. I'll make a note in the PR

Comment on lines +30 to +40
candidates.sort()
if not memory:
for quality, url in candidates:
if QUANTS[quality] == "Q4_K_M":
print(url)
return
raise ValueError("Q4_K_M is unavailable")

total = int(memory) * 1024
# Reserve RAM for the OS and background processes.
budget = total - max(4 * 1024**3, min(int(total * 0.15), 32 * 1024**3))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move the candidates.sort() down so the loop is more understandable?

Suggested change
candidates.sort()
if not memory:
for quality, url in candidates:
if QUANTS[quality] == "Q4_K_M":
print(url)
return
raise ValueError("Q4_K_M is unavailable")
total = int(memory) * 1024
# Reserve RAM for the OS and background processes.
budget = total - max(4 * 1024**3, min(int(total * 0.15), 32 * 1024**3))
if not memory:
for quality, url in candidates:
if QUANTS[quality] == "Q4_K_M":
print(url)
return
raise ValueError("Q4_K_M is unavailable")
total = int(memory) * 1024
# Reserve RAM for the OS and background processes.
budget = total - max(4 * 1024**3, min(int(total * 0.15), 32 * 1024**3))
candidates.sort()

Comment on lines +19 to +20
if context <= 0 or (memory and int(memory) <= 0):
raise ValueError("TARGET_MEMORY_KIB and CONTEXT_LENGTH must be positive")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. the error message is confusing. Reading the code, it seems like TARGET_MEMORY_KIB is optional while CONTEXT_LENGTH is necessary. The error message sounds like we need both TARGET_MEMORY_KIB and CONTEXT_LENGTH to proceed, which is not true
  2. The if condition doesn't really represent the error message either. With current logic, the error message won't show if TARGET_MEMORY_KIB is not set if CONTEXT_LENGTH is set and positive
  3. It seems like the check for value of memory is happening again in line 31. I recommend removing check of the memory here

Comment thread README.md
1. **Arm Hardware**: An Arm system (physical or virtual).
2. **Docker**: For container orchestration with Topo
3. **LLM Model**: Optional when overriding the bundled default; provide a supported single-file GGUF model (e.g., Llama 3.1, Mistral, etc.)
3. **Topo**: An experimental build supporting `configure --target` and parameter fact bindings.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a better description here? Technically, it's not an experimental build. We just need to turn on the experimental flag on the normal release build

Comment thread README.md

```bash
cd topo-lama-web-ui
cd topo-llama-web-ui

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha nice!

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