Skip to content

Pin the samples to Windows ML 2.9.42 experimental - #46

Merged
angelser merged 3 commits into
mainfrom
nieubank/2.9.42-pin
Nov 20, 2026
Merged

angelser merged 3 commits into
mainfrom
nieubank/2.9.42-pin

Conversation

@nieubank

@nieubank Nick Eubanks (nieubank) commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Moves the samples to Microsoft.Windows.AI.MachineLearning 2.9.42-experimental and the LibLlama packages to 0.7.0.113-experimental, and documents the new key and value cache type in the text generation reference. Samples/Directory.Packages.props is the only build change. All five NuGet packages are on nuget.org.

The matching windowsml 2.9.42a0 wheels aren't on PyPI yet, so Python stays on 2.9.36a0 until they are. The Python samples take their version from the installed windowsml, so they keep working, and the reference says the new Python methods need 2.9.42a0.

Since 2.9.36, 2.9.42 brings these changes.

  • Text generation from published weights can hold its attention key and value cache as INT8 or 16-bit floating point. SetKeyValueCacheType on IWinMLModelTextGenerationConfiguration sets it, and GetKeyValueCacheType on the configuration and the session reports it. INT8 needs kv_cache_scales.safetensors beside the model.
  • A session whose cache doesn't fit in dedicated GPU memory now fails CreateSession with ERROR_NOT_ENOUGH_MEMORY and names the largest capacity that fits, instead of spilling into shared memory.
  • Speculative decoding with a DFlash 2 drafter is faster, sampled speculative rounds read top-k candidates from the GPU, and prompts longer than about 104,000 tokens no longer fail.
  • WinMLServer adds --kv-cache-type and --compiled-program-directory, and enables parallel tool calls on model lanes when a request omits parallel_tool_calls.

In the package only WinMLTextGenerationTask.h and the metadata change, with methods added at the end of two existing interfaces, so no sample source changes. ONNX Runtime stays at 1.30.1, and llama.cpp at build 11847 with backend API 3.

Related issue

None.

Affected samples

  • Samples/Directory.Packages.props, which sets the package versions for every sample catalog
  • docs/api-reference/IWinMLTextGenerationTask.md, which adds the key and value cache type to the rules for sessions from a model, composed models and llama.cpp sessions, and the Python methods

Checklist

  • I built Samples/WindowsML-Samples.sln locally with Visual Studio 2022 or Visual Studio 2026 (the samples build per catalog, so I built the Runtime, Tasks and Server catalogs with build.ps1 -Rebuild and Task Studio with dotnet build, Visual Studio 2026, for ARM64 and x64)
  • I ran the affected sample(s) end-to-end on Windows 11 (x64 and/or ARM64) (ARM64 on an NVIDIA RTX Spark device, and x64 under emulation)
  • C++ changes follow the repo .clang-format (ran Samples/format-code.ps1 if available) (there's no C++ change in this PR)
  • I updated the relevant per-sample README.md (no README names the version, because the build and the docs take it from Directory.Packages.props)
  • I did not check in large model artifacts, build outputs, or secrets

Testing notes

Tested on an NVIDIA RTX Spark device (ARM64) running Windows 11, with Visual Studio 2026 and Python 3.14 ARM64.

  • .\build.ps1 -Rebuild builds the Runtime, Tasks and Server samples for ARM64 and x64 with no warnings, and Task Studio builds for both.
  • The C++, C# and run-script samples pass on ARM64. That covers image classification on the CPU and TensorRT for RTX, llm-chat, Task text generation and chat completion, text generation from a checkpoint and from a GGUF file with and without a program cache, composed text generation, llama.cpp on the CPU, speech recognition, decision, and the C++ and C# in-process Server samples.
  • The Python text generation and decision samples pass with windowsml 2.9.42a0.
  • With Qwen2.5-0.5B, a session with the default key and value cache type holds FLOAT16, FLOAT16 works with a 32,768-token capacity, and INT8 without a scales file fails CreateSession with HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), as the reference describes.
  • The x64 text generation sample gives the same reply under emulation as on ARM64.

Not covered

  • An INT8 cache, because the sample models don't include kv_cache_scales.safetensors.
  • A capacity that doesn't fit in GPU memory, because the sample models fit on this device.
  • The CUDA backend, Snapdragon devices, and x64 hardware.
Microsoft.Windows.AI.MachineLearning moves to 2.9.42-experimental and the
LibLlama packages to 0.7.0.113-experimental, which come from the same
release. Text generation from published weights can now hold its key and
value cache as INT8 or 16-bit floating point, and a capacity that doesn't
fit in dedicated GPU memory fails with an error that names the largest one
that fits. Only WinMLTextGenerationTask.h and the metadata change, with
methods appended to two existing interfaces. llama.cpp stays at build 11847
with backend API 3.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ca5b72cf-ae75-4384-9fc4-a6081b9fddea
2.9.42 adds SetKeyValueCacheType and GetKeyValueCacheType to
IWinMLModelTextGenerationConfiguration, and GetKeyValueCacheType to
IWinMLTextGenerationSession. The rules for sessions from a model, composed
models and llama.cpp sessions now say which types each holds and how
CreateSession fails, and the Python section names the new methods.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ca5b72cf-ae75-4384-9fc4-a6081b9fddea
@nieubank
Nick Eubanks (nieubank) marked this pull request as ready for review November 20, 2026 04:27
The 2.9.42a0 wheels aren't on PyPI yet, and 2.9.36a0 has no
set_key_value_cache_type, so the reference names the release that does.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ca5b72cf-ae75-4384-9fc4-a6081b9fddea
@angelser
angelser merged commit c780909 into main Nov 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants