Skip to content

Commit 2e92dc7

Browse files
committed
Remove Chronos2 pin memory option
1 parent 99f0af1 commit 2e92dc7

2 files changed

Lines changed: 82 additions & 1 deletion

File tree

integration-test/src/test/java/org/apache/iotdb/ainode/it/AINodeSharedClusterIT.java

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import java.util.Set;
5151
import java.util.concurrent.TimeUnit;
5252

53+
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.BUILTIN_LTSM_MAP;
5354
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.BUILTIN_MODEL_MAP;
5455
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.checkHeader;
5556
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.checkModelNotOnSpecifiedDevice;
@@ -90,6 +91,9 @@ public class AINodeSharedClusterIT {
9091
"CALL INFERENCE(%s, \"SELECT s%d FROM root.AI LIMIT 256\")";
9192
private static final int DEFAULT_INPUT_LENGTH = 256;
9293
private static final int DEFAULT_OUTPUT_LENGTH = 48;
94+
private static final int LOADED_MODEL_SMOKE_OUTPUT_LENGTH = 8;
95+
private static final List<String> LTSM_LOAD_DEVICE_COMBINATIONS =
96+
Arrays.asList("cpu", "0", "cpu,0");
9397

9498
private static final String FORECAST_TABLE_FUNCTION_SQL_TEMPLATE =
9599
"SELECT * FROM FORECAST("
@@ -438,6 +442,84 @@ public static void forecastTableFunctionErrorTest(
438442

439443
// ========== Concurrent forecast tests ==========
440444

445+
@Test
446+
public void largeTimeSeriesModelLoadInferenceAndForecastTest()
447+
throws SQLException, InterruptedException {
448+
try (Connection treeConnection = EnvFactory.getEnv().getConnection(BaseEnv.TREE_SQL_DIALECT);
449+
Statement treeStatement = treeConnection.createStatement();
450+
Connection tableConnection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
451+
Statement tableStatement = tableConnection.createStatement()) {
452+
for (FakeModelInfo modelInfo : BUILTIN_LTSM_MAP.values()) {
453+
for (String devices : LTSM_LOAD_DEVICE_COMBINATIONS) {
454+
loadRunAndUnloadModelOnDevices(
455+
treeStatement, tableStatement, modelInfo.getModelId(), devices);
456+
}
457+
}
458+
}
459+
}
460+
461+
private void loadRunAndUnloadModelOnDevices(
462+
Statement treeStatement, Statement tableStatement, String modelId, String devices)
463+
throws SQLException, InterruptedException {
464+
boolean loadSubmitted = false;
465+
try {
466+
treeStatement.execute(String.format("LOAD MODEL %s TO DEVICES '%s'", modelId, devices));
467+
loadSubmitted = true;
468+
checkModelOnSpecifiedDevice(treeStatement, modelId, devices);
469+
assertLoadedModelCallInferenceSucceeds(treeStatement, modelId);
470+
assertLoadedModelForecastSucceeds(tableStatement, modelId);
471+
} finally {
472+
if (loadSubmitted) {
473+
treeStatement.execute(String.format("UNLOAD MODEL %s FROM DEVICES '%s'", modelId, devices));
474+
checkModelNotOnSpecifiedDevice(treeStatement, modelId, devices);
475+
}
476+
}
477+
}
478+
479+
private void assertLoadedModelCallInferenceSucceeds(Statement statement, String modelId)
480+
throws SQLException {
481+
String callInferenceSQL =
482+
String.format(
483+
CALL_INFERENCE_SQL_TEMPLATE,
484+
modelId,
485+
0,
486+
DEFAULT_INPUT_LENGTH,
487+
LOADED_MODEL_SMOKE_OUTPUT_LENGTH);
488+
try (ResultSet resultSet = statement.executeQuery(callInferenceSQL)) {
489+
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
490+
checkHeader(resultSetMetaData, "Time,output");
491+
Assert.assertEquals(Types.DOUBLE, resultSetMetaData.getColumnType(2));
492+
int count = 0;
493+
while (resultSet.next()) {
494+
resultSet.getDouble("output");
495+
count++;
496+
}
497+
Assert.assertEquals(LOADED_MODEL_SMOKE_OUTPUT_LENGTH, count);
498+
}
499+
}
500+
501+
private void assertLoadedModelForecastSucceeds(Statement statement, String modelId)
502+
throws SQLException {
503+
String forecastTableFunctionSQL =
504+
String.format(
505+
FORECAST_TABLE_FUNCTION_SQL_TEMPLATE,
506+
modelId,
507+
0,
508+
5760,
509+
DEFAULT_INPUT_LENGTH,
510+
5760,
511+
LOADED_MODEL_SMOKE_OUTPUT_LENGTH,
512+
1,
513+
"time");
514+
try (ResultSet resultSet = statement.executeQuery(forecastTableFunctionSQL)) {
515+
int count = 0;
516+
while (resultSet.next()) {
517+
count++;
518+
}
519+
Assert.assertEquals(LOADED_MODEL_SMOKE_OUTPUT_LENGTH, count);
520+
}
521+
}
522+
441523
@Test
442524
public void concurrentForecastTest() throws SQLException, InterruptedException {
443525
for (FakeModelInfo modelInfo : CONCURRENT_FORECAST_MODELS) {

iotdb-core/ainode/iotdb/ainode/core/model/chronos2/pipeline_chronos2.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ def forecast(self, inputs, **infer_kwargs) -> list[torch.Tensor]:
309309
test_loader = DataLoader(
310310
test_dataset,
311311
batch_size=None,
312-
pin_memory=True,
313312
shuffle=False,
314313
drop_last=False,
315314
)

0 commit comments

Comments
 (0)