Datasets:
|
Download docs/ENGINEERING_NOTES.md from tesraghavan/agent-trace: direct link, hf CLI and curl.
- Browser
- Download file 2.59 kB
-
https://huggingface.co/datasets/tesraghavan/agent-trace/resolve/main/docs/ENGINEERING_NOTES.md
- Command line
-
hf download hf://datasets/tesraghavan/agent-trace/docs/ENGINEERING_NOTES.md
-
curl -L -o ENGINEERING_NOTES.md https://huggingface.co/datasets/tesraghavan/agent-trace/resolve/main/docs/ENGINEERING_NOTES.md
2.59 kB
| # Engineering Notes | |
| This file keeps short, still-useful implementation notes that previously lived in separate top-level markdown files. | |
| ## 1. smolagents `reasoning_content` | |
| ### Summary | |
| Two separate issues affected reasoning capture with Qwen3 through `OpenAIServerModel` / `OpenAIServerModel`-style tool use: | |
| 1. `tool_choice="required"` suppressed `reasoning_content` at the server level. | |
| 2. smolagents step serialization dropped `reasoning_content` even when it existed on the live OpenAI/Pydantic response object. | |
| ### What mattered in practice | |
| - For this project, `tool_choice="auto"` is required if we want reasoning traces. | |
| - Capturing reasoning from the live model response before smolagents serializes steps is the reliable workaround. | |
| ### Root cause | |
| - `tool_choice="required"` constrained generation enough that llama-server stopped returning reasoning blocks. | |
| - smolagents stored the live response object, but later step serialization did not preserve Pydantic extra fields such as `reasoning_content`. | |
| ### Project workaround | |
| We handle this in the collector by: | |
| - passing `tool_choice="auto"` to the model | |
| - monkey-patching `model.generate()` to extract `reasoning_content` before step serialization | |
| ### Environment where this was observed | |
| - `smolagents 1.24.0` | |
| - OpenAI SDK `1.82.0` | |
| - llama-server / llama.cpp serving Qwen3 GGUF models | |
| - macOS, Python 3.10 | |
| ## 2. llama.cpp + Qwen3 benchmark/config note | |
| These were the practical serving findings that mattered while tuning local collection runs on an M3 Pro. | |
| ### Main benchmark takeaways | |
| For an ~11.6k token prompt: | |
| | Model | Config | Prompt tok/s | Gen tok/s | | |
| |-------|--------|--------------|-----------| | |
| | 0.6B | baseline | 977 | 32 | | |
| | 0.6B | flash + q8_0 KV | 958 | 70 | | |
| | 0.6B | flash only | 1642 | 55 | | |
| | 1.7B | baseline | 704 | 25 | | |
| | 1.7B | flash + q8_0 KV | 694 | 42 | | |
| | 1.7B | flash only | 991 | 37 | | |
| ### Practical flag notes | |
| - `--flash-attn` | |
| - Biggest prompt-speed improvement. | |
| - `-ctk q8_0 -ctv q8_0` | |
| - KV cache quantization improved generation speed and reduced KV memory footprint. | |
| - `--jinja --chat-template-file` | |
| - Needed when using a custom no-think / reasoning-control template. | |
| ### Working heuristics | |
| - Long prompts, short outputs: | |
| - `--flash-attn` | |
| - Short prompts, long outputs: | |
| - `--flash-attn -ctk q8_0 -ctv q8_0` | |
| - Memory-constrained runs: | |
| - prefer KV quantization | |
| ### Important caveats | |
| - KV cache quantization availability depends on the serving build/config. | |
| - Custom chat templates can materially change reasoning behavior, so they should be recorded in run metadata. | |