Skip to content

Commit cf4e672

Browse files
fix(ltx2): cast positions double/float to avoid MSVC C4244 (#968)
MSVC refuses the implicit narrowing in the two `StreamState` <-> `Ltx2LatentState` position copies under `/WX`, so the native Windows build cannot compile `ltx2_video.cpp` at all. The range-assign is replaced by an explicit `static_cast` loop in each direction. The cast is not a claim that precision does not matter here; it is a claim that none is lost, and the file already carries the argument. `ltx2_video.cpp:193-196` records that the positions round trip exactly because every value in the `double` buffer was widened from a `float` in the first place -- the `double` exists only because the DiT surface takes one. Both writers agree: the video axis is `static_cast<double>(float_expr)` at `:2463-2466`, and the audio axis comes from `Ltx2AudioPatchTimings`, which returns `std::vector<float>`, at `:2535`. So `float -> double -> float` reproduces the bits, and the explicit cast performs exactly the conversion the implicit assign already performed. This closes the last MSVC compile blocker in the #503 class. The lane still fails afterwards, later and for a different reason -- `test_openai_api_server.exe` exits `0xC0000409` with no doctest summary, a runtime defect the build never reached before. That is tracked separately and is not this change. A second commit refreshes the READER ANCHORS comment. The casts add nine net lines above `kKnownLoadExtras`, shifting every recorded anchor by nine, and `test_ltx2_video` derives and compares that list on every run so the drift is caught rather than silently rotting. The replacement list was derived against main at `0f8580e26` with this branch merged, because main moved this file twice since the branch base (`332aed738`, `3ce1cf7c7`). Fixes #968 FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: ClaudeCode:claude-opus-5 [ClaudeCode] Signed-off-by: harleywilsoneng <harleywilsoneng@users.noreply.github.com>
1 parent a332fb9 commit cf4e672

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/vllm/multimodal/ltx2_video.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@ Ltx2LatentState ToLatentState(const StreamState& s, int64_t pos_dims) {
203203
out.latent = s.latent;
204204
out.clean = s.clean;
205205
out.mask = s.mask;
206-
out.positions.assign(s.positions.begin(), s.positions.end());
206+
// Explicit cast: StreamState stores positions as double for the DiT surface,
207+
// Ltx2LatentState keeps float32. Range-assign would narrow implicitly and
208+
// trip MSVC C4244 under /WX (mudler/vllm.cpp#968).
209+
out.positions.resize(s.positions.size());
210+
for (size_t i = 0; i < s.positions.size(); ++i) {
211+
out.positions[i] = static_cast<float>(s.positions[i]);
212+
}
207213
out.keyframes_mask = s.keyframes_mask;
208214
return out;
209215
}
@@ -214,7 +220,10 @@ void FromLatentState(const Ltx2LatentState& in, StreamState* s) {
214220
s->latent = in.latent;
215221
s->clean = in.clean;
216222
s->mask = in.mask;
217-
s->positions.assign(in.positions.begin(), in.positions.end());
223+
s->positions.resize(in.positions.size());
224+
for (size_t i = 0; i < in.positions.size(); ++i) {
225+
s->positions[i] = static_cast<double>(in.positions[i]);
226+
}
218227
s->keyframes_mask = in.keyframes_mask;
219228
}
220229

@@ -364,7 +373,7 @@ constexpr char kLtx2DurationHeadPathExtra[] = "duration_head_path";
364373
// they are no longer trusted: the list below is derived from this file on every
365374
// run and compared, and the failure prints the replacement to paste in.
366375
// READER ANCHORS (derived and gated by test_ltx2_video):
367-
// 782 792 793 855 951 967 969 1060 1085 1190 1231
376+
// 791 801 802 864 960 976 978 1069 1094 1199 1240
368377
const char* const kKnownLoadExtras[] = {
369378
kLtx2AudioPromptEmbedsExtra, kLtx2PipelineKindExtra, kLtx2ModelVersionExtra,
370379
kLtx2AllowUnportedExtra, kLtx2MaxPhaseExtra, kLtx2DitConfigPathExtra,

0 commit comments

Comments
 (0)