Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. Spark
  3. spark
  4. loadLocal

spark.loadLocal

function loadLocal(key: string): Promise<ArrayBuffer | null>

Load data from local browser storage (IndexedDB).

Retrieves data previously saved with saveLocal. Returns null if the key doesn't exist, allowing for graceful fallbacks.

Parameters

keystring
Unique identifier for the data

Returns

Promise<ArrayBuffer | null>– Promise resolving to ArrayBuffer if found, null if not found

Examples

// Load and restore checkpoint
const weights = await spark.loadLocal('model-v1-best');
if (weights) {
  model.load_state_dict(torch.deserialize(weights));
  console.log('Restored from local cache');
} else {
  console.log('No local checkpoint found');
}

// Conditional loading with fallback
let modelWeights = await spark.loadLocal('latest-checkpoint');
if (!modelWeights) {
  // Fall back to loading from server
  modelWeights = await spark.load('kasumi/project/weights.pt');
}

See Also

  • saveLocal - Save to local storage
  • existsLocal - Check if key exists
Previous
loadJSON
Next
loadText