jianjunz requested wasmtime-core-reviewers for a review on PR #7807.
jianjunz requested pchickey for a review on PR #7807.
jianjunz requested wasmtime-default-reviewers for a review on PR #7807.
jianjunz opened PR #7807 from jianjunz:winml
to bytecodealliance:main
:
This change adds Windows Machine Learning backend for wasi-nn. Since WinML is a built-in feature of Windows, this change makes it possible to run wasi-nn on Windows without a third-party machine learning framework.
WinML backend is only available on Windows.
WinML: https://learn.microsoft.com/en-us/windows/ai/windows-ml/
jianjunz updated PR #7807.
jianjunz updated PR #7807.
jianjunz submitted PR review.
jianjunz created PR review comment:
It looks like
cargo vet
doesn't like this git link. We'll need to release a new version for image2tensor and update the version number here.
jianjunz updated PR #7807.
abrown updated PR #7807.
jianjunz updated PR #7807.
jianjunz updated PR #7807.
jianjunz updated PR #7807.
@jianjunz:now that #7846 is merged you should be able to rebase on that and get
cargo vet
to pass.
abrown submitted PR review.
abrown submitted PR review.
abrown created PR review comment:
Probably an editor auto-format thing: following this project's convention, we can leave this trailing new line in.
abrown created PR review comment:
This won't work when both features are enabled. Features are additive, so both backends can be present at the same time.
abrown created PR review comment:
I believe this is another place where the tensor item type is hard-coded: we need to be able to handle other types.
abrown created PR review comment:
Is this resolved? Looking at the binding code below, I believe we need to handle more than just the
f32
case — there are other possible models with other tensor item types.
abrown created PR review comment:
Are all of these features needed? I would have assumed that only
"AI_MachineLearning"
is needed, which adds the right dependent features (see here). The reason I'm thinking about this is that thewindows
crate totals 11MB and I don't want to unnecessarily bloat Wasmtime binaries on Windows.
abrown created PR review comment:
This should handle any kind of model, not just mobilenet. Perhaps just look for the
.onnx
suffix?
abrown created PR review comment:
You will want to double-check that this test is actually run. Right now in Wasmtime's CI, only a subset of jobs run to preserve runner time. The Windows "test" job does not run by default but if you add the string
prtest:full
in any commit, then all jobs will run. Then we can check the logs for the Windows job to ensure this test actually ran.
jianjunz updated PR #7807.
jianjunz updated PR #7807.
jianjunz submitted PR review.
jianjunz created PR review comment:
This dependency has been removed. Test image was converted to tensor data offline.
jianjunz submitted PR review.
jianjunz created PR review comment:
Done. Restored the trailing new line.
jianjunz submitted PR review.
jianjunz created PR review comment:
"Storage_Streams" and "Foundation_Collections" are needed because some WinML APIs need data structures defined by these two features. "Foundation" is removed.
jianjunz submitted PR review.
jianjunz submitted PR review.
jianjunz created PR review comment:
We run openvino and winml backend in two different test cases, with different inputs, so only one backend is specified here for testing purpose.
backend.list() is able to list all available backends.
jianjunz created PR review comment:
4 is the size of TensorFloat, which is the output data type for probability.
jianjunz submitted PR review.
jianjunz created PR review comment:
Only f32 is supported right now. A check is added for rejecting unsupported tensor types.
I'm planning to add support for other types in a separate PR since more test data is needed for converging these new tensor types. It may need additional changes for image2tensor to generate the input data.
jianjunz submitted PR review.
jianjunz created PR review comment:
Renamed to model.onnx to align with openvino backend.
jianjunz submitted PR review.
jianjunz created PR review comment:
With prtest:full, this test failed on Windows Server. I guess GitHub Windows Server runner doesn't have Desktop Experience enabled.
jianjunz submitted PR review.
jianjunz created PR review comment:
I'm afraid we need to disable this test at this time. GitHub Actions Windows Server image doesn't have Desktop Experience available, so it cannot be installed.
List of installed or available features:
https://github.com/jianjunz/wasmtime/actions/runs/7752997447/job/21143496106#step:9:1
jianjunz updated PR #7807.
jianjunz has marked PR #7807 as ready for review.
jianjunz updated PR #7807.
jianjunz commented on PR #7807:
Thanks for auditing windows-* crates, but
cargo vet
still fails after #7900. Only 1 unvetted dependency now.1 unvetted dependencies: windows:0.52.0 missing ["safe-to-deploy"]
abrown updated PR #7807.
abrown submitted PR review.
abrown created PR review comment:
What I mean is: if someone runs
cargo test --all-features
, both the OpenVINO and WinML statements that assign tolet mut backend
will be present in the code. Some background: thisall.rs
file is compiled once bycargo test
into a single binary that runs multiple tests, so that compilation will be incorrect because the secondlet mut backend
will shadow the first.
abrown submitted PR review.
abrown created PR review comment:
Yeah, that's unfortunate. Why don't we add a function like
check_openvino_is_installed
but for WinML:check_winml_is_available
. There's probably a way to check with the Windows API if ML system calls are possible and that function could return false if they are not.That extra runtime check would be in addition to the
#[cfg_attr(not(feature = "winml"), ignore)]
. That can stay there for the case where thewinml
feature isn't even enabled.
abrown submitted PR review:
@jianjunz, this looks good to me with a couple of final points:
- let's resolve the shadowing for the
cargo test --all-features
case- let's add the
check_winml_is_available
dynamic check- can you rebase on
main
? If it's not too much trouble, I might suggest squashing some of the commits since the entire commit history will get dropped into the merge commit (but this is a personal preference thing: feel free to leave as-is).
jianjunz updated PR #7807.
jianjunz commented on PR #7807:
The code is rebased. No conflict. However, your commit https://github.com/bytecodealliance/wasmtime/commit/f81c59d0495630fe82e16d352786aa10358aa281 was dropped because I forgot to pull the code first before rebasing. Could you please submit it again to fix the
cargo vet
failure? Thanks and sorry for the mistake.
jianjunz submitted PR review.
jianjunz submitted PR review.
jianjunz created PR review comment:
check_winml_is_available
is added. It returns ok for my Windows 11, but I'll need to find an environment to check if it returns an error when WinML is not available.
jianjunz created PR review comment:
Thanks for the background. It's fixed.
jianjunz updated PR #7807.
jianjunz edited a comment on PR #7807:
The code is rebased. No conflict. However,
cargo vet
reported more unvetted dependencies. I'll check if there is any unnecessary change for cargo.lock.
abrown updated PR #7807.
abrown merged PR #7807.
jianjunz commented on PR #7807:
Thanks for your review and merging this PR.
Last updated: Dec 23 2024 at 12:05 UTC